// Path: compiler/src/test/java/com/contentful/vault/compiler/lib/TestUtils.java
// public static Iterable<? extends Processor> processors() {
//   return Arrays.asList(new Processor());
// }
// 
// Path: compiler/src/test/java/com/contentful/vault/compiler/lib/TestUtils.java
// public static String readTestResource(String fileName) throws IOException {
//   URL resource = TestUtils.class.getClassLoader().getResource(fileName);
//   return FileUtils.readFileToString(new File(resource.getPath()), Charset.defaultCharset());
// }


import com.google.common.base.Joiner;
import com.google.testing.compile.JavaFileObjects;
import org.junit.Test;
import javax.tools.JavaFileObject;
import static com.contentful.vault.compiler.lib.TestUtils.processors;
import static com.contentful.vault.compiler.lib.TestUtils.readTestResource;
import static com.google.common.truth.Truth.assert_;
import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource;
  @Test public void failsDuplicateId() throws Exception {
    JavaFileObject source = JavaFileObjects.forSourceString("test.Test", Joiner.on('\n').join(
        "import com.contentful.vault.ContentType;",
        "import com.contentful.vault.Field;",
        "import com.contentful.vault.Resource;",
        "import com.contentful.vault.Space;",
        "class Test {",
        "  @ContentType(\"cid\")",
        "  static class Test1 extends Resource {",
        "    @Field String foo;",
        "  }",
        "  @ContentType(\"cid\")",
        "  static class Test2 extends Resource {",
        "    @Field String foo;",
        "  }",
        "  @Space(value = \"sid\", models = { Test1.class, Test2.class }, locales = \"foo\")",
        "  static class Test3 {}",
        "}"));

    assert_().about(javaSource()).that(source)
        .processedWith(processors())
        .failsToCompile()
        .withErrorContaining(
            "@Space includes multiple models with the same id \"cid\". (Test.Test3)");
  }

  @Test public void failsDuplicateLocale() throws Exception {
    JavaFileObject source = JavaFileObjects.forSourceString("Test", Joiner.on('\n').join(
        "import com.contentful.vault.ContentType;",
        "import com.contentful.vault.Field;",
// Path: compiler/src/test/java/com/contentful/vault/compiler/lib/TestUtils.java
// public static Iterable<? extends Processor> processors() {
//   return Arrays.asList(new Processor());
// }
// 
// Path: compiler/src/test/java/com/contentful/vault/compiler/lib/TestUtils.java
// public static String readTestResource(String fileName) throws IOException {
//   URL resource = TestUtils.class.getClassLoader().getResource(fileName);
//   return FileUtils.readFileToString(new File(resource.getPath()), Charset.defaultCharset());
// }


// Path: compiler/src/test/java/com/contentful/vault/compiler/SpaceTest.java
import com.google.common.base.Joiner;
import com.google.testing.compile.JavaFileObjects;
import org.junit.Test;
import javax.tools.JavaFileObject;
import static com.contentful.vault.compiler.lib.TestUtils.processors;
import static com.contentful.vault.compiler.lib.TestUtils.readTestResource;
import static com.google.common.truth.Truth.assert_;
import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource;

  @Test public void failsDuplicateId() throws Exception {
    JavaFileObject source = JavaFileObjects.forSourceString("test.Test", Joiner.on('\n').join(
        "import com.contentful.vault.ContentType;",
        "import com.contentful.vault.Field;",
        "import com.contentful.vault.Resource;",
        "import com.contentful.vault.Space;",
        "class Test {",
        "  @ContentType(\"cid\")",
        "  static class Test1 extends Resource {",
        "    @Field String foo;",
        "  }",
        "  @ContentType(\"cid\")",
        "  static class Test2 extends Resource {",
        "    @Field String foo;",
        "  }",
        "  @Space(value = \"sid\", models = { Test1.class, Test2.class }, locales = \"foo\")",
        "  static class Test3 {}",
        "}"));

    assert_().about(javaSource()).that(source)
        .processedWith(processors())
        .failsToCompile()
        .withErrorContaining(
            "@Space includes multiple models with the same id \"cid\". (Test.Test3)");
  }

  @Test public void failsDuplicateLocale() throws Exception {
    JavaFileObject source = JavaFileObjects.forSourceString("Test", Joiner.on('\n').join(
        "import com.contentful.vault.ContentType;",
        "import com.contentful.vault.Field;",
        "import com.contentful.vault.Resource;",