Java Code Examples for com.google.testing.compile.Compilation

The following examples show how to use com.google.testing.compile.Compilation. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: deptective   Author: moditect   File: AnalyzeWithDefinedComponentsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailUponAnalyzeWithPackageMatchedByMultipleComponents() throws Exception {
    Compilation compilation = Compiler.javac()
            .withOptions(
                    TestOptions.deptectiveOptions(
                            Options.MODE, "ANALYZE",
                            Options.COMPONENTS,
                            "foo1:org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo;" +
                                    "foo2:org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo"
                    )
            )
            .compile(forTestClass(Foo.class));

    assertThat(compilation).failed();
    assertThat(compilation).hadNoteCount(0);
    assertThat(compilation).hadErrorContaining(
            "Multiple components match package org.moditect.deptective.plugintest.packagecontainedtwiceanalyze.foo: foo1, foo2"
    );
}
 
Example #2
Source Project: auto   Author: google   File: AutoValueCompilationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void noMultidimensionalPrimitiveArrays() {
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Baz",
          "package foo.bar;",
          "",
          "import com.google.auto.value.AutoValue;",
          "",
          "@AutoValue",
          "public abstract class Baz {",
          "  public abstract int[][] ints();",
          "",
          "  public static Baz create(int[][] ints) {",
          "    return new AutoValue_Baz(ints);",
          "  }",
          "}");
  Compilation compilation =
      javac().withProcessors(new AutoValueProcessor()).compile(javaFileObject);
  assertThat(compilation)
      .hadErrorContaining(
          "@AutoValue class cannot define an array-valued property "
              + "unless it is a primitive array")
      .inFile(javaFileObject)
      .onLineContaining("int[][] ints()");
}
 
Example #3
Source Project: dart   Author: f2prateek   File: IntentBuilderGeneratorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void intentBuilderGenerator_should_fail_when_extraIsInvalidType() {
  JavaFileObject source =
      JavaFileObjects.forSourceString(
          "test.navigation.TestNavigationModel",
          Joiner.on('\n')
              .join(
                  "package test.navigation;",
                  "import dart.BindExtra;",
                  "public class TestNavigationModel {",
                  "    @BindExtra Object extra;",
                  "}"));

  Compilation compilation = javac().withProcessors(hensonProcessor()).compile(source);
  assertThat(compilation)
      .hadErrorContaining(
          "The fields of class annotated with @DartModel must be primitive, Serializable or Parcelable (test.navigation.TestNavigationModel.extra).");
}
 
Example #4
Source Project: auto   Author: google   File: AutoAnnotationErrorsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExtraParameters() {
  JavaFileObject testSource =
      JavaFileObjects.forSourceLines(
          "com.foo.Test",
          "package com.foo;",
          "",
          "import com.example.TestAnnotation;",
          "import com.google.auto.value.AutoAnnotation;",
          "",
          "class Test {",
          "  @AutoAnnotation static TestAnnotation newTestAnnotation(int value, int other) {",
          "    return new AutoAnnotation_Test_newTestAnnotation(value);",
          "  }",
          "}");
  Compilation compilation =
      javac()
          .withProcessors(new AutoAnnotationProcessor())
          .compile(TEST_ANNOTATION, testSource);
  assertThat(compilation)
      .hadErrorContaining(
          "method parameter 'other' must have the same name as a member of "
              + "com.example.TestAnnotation")
      .inFile(testSource)
      .onLineContaining("newTestAnnotation(int value, int other)");
}
 
Example #5
Source Project: picocli   Author: remkop   File: NativeImageConfigGeneratorProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testOptionDisableProxyVerbose() {
    NativeImageConfigGeneratorProcessor processor = new NativeImageConfigGeneratorProcessor();
    Compilation compilation =
            javac()
                    .withProcessors(processor)
                    .withOptions("-A" + ProxyConfigGen.OPTION_DISABLE, "-A" + AbstractGenerator.OPTION_VERBOSE) // no value
                    .compile(JavaFileObjects.forResource(
                            "picocli/examples/subcommands/ParentCommandDemo.java"));

    assertThat(compilation).succeeded();
    String[][] allParams = {
            { ReflectConfigGen.class.getSimpleName(),  "reflect-config.json",  "true" , "true" },
            { ResourceConfigGen.class.getSimpleName(), "resource-config.json", "true" , "true" },
            { ProxyConfigGen.class.getSimpleName(),    "proxy-config.json",    "false", "true" },
    };
    expectGeneratedWithNotes(compilation, allParams);
}
 
Example #6
Source Project: dart   Author: f2prateek   File: IntentBuilderGeneratorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void intentBuilderGenerator_should_fail_when_parentIsNotANavigationModel() {
  JavaFileObject source =
      JavaFileObjects.forSourceString(
          "test.navigation.TestNavigationModel",
          Joiner.on('\n')
              .join(
                  "package test.navigation;",
                  "import dart.BindExtra;",
                  "public class TestNavigationModel extends SuperClass {",
                  "    @BindExtra String extra;",
                  "}",
                  "class SuperClass {",
                  "}"));

  Compilation compilation = javac().withProcessors(hensonProcessor()).compile(source);
  assertThat(compilation)
      .hadErrorContaining(
          "DartModel test.navigation.TestNavigationModel parent does not have an IntentBuilder. Is test.navigation.SuperClass annotated with @DartModel or contains @BindExtra fields?");
}
 
Example #7
Source Project: nalu   Author: NaluKit   File: ControllerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void testControllerWithComposite01() {
  Compilation compilation = javac().withProcessors(new NaluProcessor())
                                   .compile(Arrays.asList(JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/ControllerWithComposite01.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/MockContext.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/MockShell.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/IComponent01.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/Component01.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/composite/CompositeController01.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/composite/ICompositeComponent01.java"),
                                                          JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/composite/CompositeComponent01.java")));
  CompilationSubject.assertThat(compilation)
                    .succeeded();
  CompilationSubject.assertThat(compilation)
                    .generatedSourceFile("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/ControllerWithComposite01CreatorImpl")
                    .hasSourceEquivalentTo(JavaFileObjects.forResource("com/github/nalukit/nalu/processor/common/ui/controllerWithComposite01/ControllerWithComposite01CreatorImpl.java"));
}
 
Example #8
Source Project: auto   Author: google   File: AutoAnnotationErrorsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDoesNotReturnAnnotation() {
  JavaFileObject testSource =
      JavaFileObjects.forSourceLines(
          "com.foo.Test",
          "package com.foo;",
          "",
          "import com.google.auto.value.AutoAnnotation;",
          "",
          "class Test {",
          "  @AutoAnnotation static String newString(int value) {",
          "    return new AutoAnnotation_Test_newString(value);",
          "  }",
          "}");
  Compilation compilation =
      javac()
          .withProcessors(new AutoAnnotationProcessor())
          .compile(TEST_ANNOTATION, testSource);
  assertThat(compilation)
      .hadErrorContaining("must be an annotation type, not java.lang.String")
      .inFile(testSource)
      .onLineContaining("static String newString(int value)");
}
 
Example #9
Source Project: firebase-android-sdk   Author: firebase   File: EncodableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void compile_withGenericClass_ShouldWarnAboutPotentialProblems() {
  Compilation result =
      javac()
          .withProcessors(new EncodableProcessor())
          .compile(
              JavaFileObjects.forSourceLines(
                  "GenericClass",
                  "import com.google.firebase.encoders.annotations.Encodable;",
                  "@Encodable public class GenericClass<T, U> {",
                  "public T getT() { return null; }",
                  "public U getU() { return null; }",
                  "}"));

  assertThat(result).hadWarningContaining("GenericClass<T,U> is a generic type");
  assertThat(result)
      .generatedSourceFile("AutoGenericClassEncoder")
      .hasSourceEquivalentTo(
          JavaFileObjects.forResource("ExpectedGenericsEncoderWithUnknownType.java"));
}
 
Example #10
Source Project: auto   Author: google   File: AutoValueCompilationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAbstractWithParams() {
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Baz",
          "package foo.bar;",
          "import com.google.auto.value.AutoValue;",
          "@AutoValue",
          "public abstract class Baz {",
          "  public abstract int foo(int bar);",
          "}");
  Compilation compilation =
      javac().withProcessors(new AutoValueProcessor()).compile(javaFileObject);
  assertThat(compilation).failed();
  assertThat(compilation)
      .hadWarningContaining(
          "Abstract method is neither a property getter nor a Builder converter")
      .inFile(javaFileObject)
      .onLineContaining("int foo(int bar)");
}
 
Example #11
Source Project: dataenum   Author: spotify   File: IntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCopyDocFromCaseSourceToJavadocCommentOnFactoryMethod() {
  Compilation compilation =
      javac()
          .withOptions("-implicit:class")
          .withProcessors(new DataEnumProcessor())
          .compile(JavaFileObjects.forResource("javadoc/Javadoc_dataenum.java"));

  assertThat(compilation).succeededWithoutWarnings();
  assertThat(compilation)
      .generatedSourceFile("javadoc.Javadoc")
      .contentsAsUtf8String()
      .contains(
          "/**\n"
              + "   * Some documentation about this case.\n"
              + "   *\n"
              + "   * @return a {@link Documented} (see {@link Javadoc_dataenum#Documented} for source)\n"
              + "   */\n");
}
 
Example #12
Source Project: auto   Author: google   File: AutoValueCompilationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void annotationOnEnum() {
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Baz",
          "package foo.bar;",
          "",
          "import com.google.auto.value.AutoValue;",
          "",
          "@AutoValue",
          "public enum Baz {}");
  Compilation compilation =
      javac().withProcessors(new AutoValueProcessor()).compile(javaFileObject);
  assertThat(compilation)
      .hadErrorContaining("AutoValue only applies to classes")
      .inFile(javaFileObject)
      .onLineContaining("enum Baz");
}
 
Example #13
Source Project: dart   Author: f2prateek   File: IntentBuilderGeneratorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void intentBuilderGenerator_should_fail_when_extraKeyIsInvalid() {
  JavaFileObject source =
      JavaFileObjects.forSourceString(
          "test.navigation.TestNavigationModel",
          Joiner.on('\n')
              .join(
                  "package test.navigation;",
                  "import dart.BindExtra;",
                  "public class TestNavigationModel {",
                  "    @BindExtra(\"my.key\") String extra;",
                  "}"));

  Compilation compilation = javac().withProcessors(hensonProcessor()).compile(source);
  assertThat(compilation)
      .hadErrorContaining(
          "@BindExtra key has to be a valid java variable identifier (test.navigation.TestNavigationModel#extra).");
}
 
Example #14
Source Project: auto   Author: google   File: AutoOneOfCompilationTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void noKindGetter() {
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Pet",
          "package foo.bar;",
          "",
          "import com.google.auto.value.AutoOneOf;",
          "",
          "@AutoOneOf(Pet.Kind.class)",
          "public abstract class Pet {",
          "  public enum Kind {DOG, CAT}",
          "  public abstract String dog();",
          "  public abstract String cat();",
          "}");
  Compilation compilation =
      javac().withProcessors(new AutoOneOfProcessor()).compile(javaFileObject);
  assertThat(compilation)
      .hadErrorContaining(
          "foo.bar.Pet must have a no-arg abstract method returning foo.bar.Pet.Kind")
      .inFile(javaFileObject)
      .onLineContaining("class Pet");
}
 
Example #15
Source Project: picocli   Author: remkop   File: NativeImageConfigGeneratorProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGenerateReflectConfigIssue850MissingMixin() {
    NativeImageConfigGeneratorProcessor processor = new NativeImageConfigGeneratorProcessor();
    Compilation compilation =
            javac()
                    .withProcessors(processor)
                    .withOptions("-A" + OPTION_PROJECT + "=issue850")
                    .compile(JavaFileObjects.forSourceLines(
                            "picocli.issue850missingmixin.App",
                            slurp("/picocli/issue850missingmixin/App.java")),
                            JavaFileObjects.forSourceLines(
                                    "picocli.issue850missingmixin.InitCommand",
                                    slurp("/picocli/issue850missingmixin/InitCommand.java")),
                            JavaFileObjects.forSourceLines(
                                    "picocli.issue850missingmixin.ProviderMixin",
                                    slurp("/picocli/issue850missingmixin/ProviderMixin.java"))
                            );
    assertThat(compilation).succeeded();
    assertThat(compilation)
            .generatedFile(StandardLocation.CLASS_OUTPUT, "META-INF/native-image/picocli-generated/issue850/reflect-config.json")
            .contentsAsUtf8String().isEqualTo(slurp("/picocli/issue850missingmixin/issue850-reflect-config.json"));
}
 
Example #16
Source Project: android-state   Author: evernote   File: TestProcessor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testTypeNotSupported() {
    JavaFileObject javaFileObject = JavaFileObjects.forSourceString(getName("TestTypeNotSupported"), ""
            + "package com.evernote.android.state.test;\n"
            + "\n"
            + "import com.evernote.android.state.State;\n"
            + "\n"
            + "public class TestTypeNotSupported {\n"
            + "    @State\n"
            + "    public Other test;\n"
            + "\n"
            + "    public static final class Other {}\n"
            + "}\n");

    Compilation compilation = Compiler.javac().withProcessors(new StateProcessor()).compile(javaFileObject);
    assertThat(compilation).failed();
    assertThat(compilation)
            .hadErrorContaining("Don't know how to put com.evernote.android.state.test.TestTypeNotSupported.Other into a bundle")
            .inFile(javaFileObject)
            .onLine(7)
            .atColumn(18);
}
 
Example #17
Source Project: tinkerpop   Author: apache   File: GremlinDslProcessorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCompileRemoteDslTraversal() {
    final Compilation compilation = javac()
            .withProcessors(new GremlinDslProcessor())
            .compile(JavaFileObjects.forResource(GremlinDsl.class.getResource("SocialTraversalDsl.java")),
                    JavaFileObjects.forResource(GremlinDsl.class.getResource("RemoteDslTraversal.java")));

    try {
        final ClassLoader cl = new JavaFileObjectClassLoader(compilation.generatedFiles());
        final Class cls = cl.loadClass("org.apache.tinkerpop.gremlin.process.traversal.dsl.RemoteDslTraversal");
        cls.getConstructor().newInstance();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #18
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAllowAccessToJavaLangAutomatically() {
    Compilation compilation = Compiler.javac()
            .withOptions(TestOptions.deptectiveOptions(Options.CONFIG_FILE, getConfigFileOption()))
            .compile(forTestClass(FooWithoutErrors.class));
    assertThat(compilation).succeeded();
}
 
Example #19
Source Project: auto   Author: google   File: AutoValueCompilationTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void autoValueBuilderWrongTypeGetter() {
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Baz",
          "package foo.bar;",
          "",
          "import com.google.auto.value.AutoValue;",
          "",
          "@AutoValue",
          "public abstract class Baz<T, U> {",
          "  abstract T blim();",
          "  abstract U blam();",
          "",
          "  @AutoValue.Builder",
          "  public interface Builder<T, U> {",
          "    Builder<T, U> blim(T x);",
          "    Builder<T, U> blam(U x);",
          "    T blim();",
          "    T blam();",
          "    Baz<T, U> build();",
          "  }",
          "}");
  Compilation compilation =
      javac()
          .withProcessors(new AutoValueProcessor(), new AutoValueBuilderProcessor())
          .compile(javaFileObject);
  assertThat(compilation)
      .hadErrorContaining(
          "Method matches a property of foo.bar.Baz but has return type T instead of U")
      .inFile(javaFileObject)
      .onLineContaining("T blam()");
}
 
Example #20
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidQualifiedClassReference() {
    Compilation compilation = compile();
    assertThat(compilation).failed();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barqualified")
    );
}
 
Example #21
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidStarImport() {
    Compilation compilation = compile();
    assertThat(compilation).failed();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.bardemand")
    );
}
 
Example #22
Source Project: andhow   Author: eeverman   File: PropertyRegistrarClassGeneratorTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Basic gross test that the generated source is compilable
 */
@Test
public void testGenerate_simple() throws Exception {
	
	PropertyRegistrarClassGenerator gen = new PropertyRegistrarClassGenerator(
			simpleCompileUnit(), AndHowCompileProcessor.class, runDate);
	String sourceStr = gen.generateSource();
	
	Compilation compilation
			= javac()
					.compile(JavaFileObjects.forSourceString(gen.buildGeneratedClassFullName(), sourceStr));
	
	assertThat(compilation).succeeded();

}
 
Example #23
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidFieldReferences() {
    Compilation compilation = compile();
    assertThat(compilation).failed();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barfield"));
}
 
Example #24
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidReferencesInGenericBounds() {
    Compilation compilation = compile();
    assertThat(compilation).failed();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.bargenericbound")
    );

}
 
Example #25
Source Project: Witch-Android   Author: sedstrom   File: WitchProcessorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void errorBindMethodWrongParameterCount() {
    Compilation compilation = compile("ErrorBindMethodWrongParameterCount.java");
    assertThat(compilation).hadErrorContaining("ErrorBindMethodWrongParameterCount");
    assertThat(compilation).hadErrorContaining("void text(android.view.View,java.lang.String,java.lang.String,java.lang.String) is not a valid bind method");
    assertThat(compilation).hadErrorContaining(String.format(readMore));
    assertValidBindMethodSignatures(compilation, "text");
    printErrors(compilation);
}
 
Example #26
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidSuperClass() {
    Compilation compilation = compile();
    assertThat(compilation).failed();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barsuper"));

    // inner class
    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barinnersuper"));
}
 
Example #27
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidImplementedInterface() {
    Compilation compilation = compile();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barinter"));

    // inner interface
    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barinnerinner"));
}
 
Example #28
Source Project: nalu   Author: NaluKit   File: TrackerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void testTrackerAnnotationWithoutExtendsIsApplication() {
  Compilation compilation = javac().withProcessors(new NaluProcessor())
                                   .compile(Collections.singletonList(JavaFileObjects.forResource("com/github/nalukit/nalu/processor/tracker/trackerAnnotationWithoutExtendsIsApplication/TrackerAnnotationWithoutExtendsIsApplication.java")));
  CompilationSubject.assertThat(compilation)
                    .failed();
  CompilationSubject.assertThat(compilation)
                    .hadErrorContaining("Nalu-Processor: @Tracker can only be used on interfaces that extends IsApplication");
}
 
Example #29
Source Project: auto   Author: google   File: AutoValueCompilationTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void autoValueBuilderNullableSetterForNonNullable() {
  JavaFileObject nullableFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Nullable",
          "package foo.bar;",
          "",
          "import java.lang.annotation.ElementType;",
          "import java.lang.annotation.Target;",
          "",
          "@Target(ElementType.TYPE_USE)",
          "public @interface Nullable {}");
  JavaFileObject javaFileObject =
      JavaFileObjects.forSourceLines(
          "foo.bar.Baz",
          "package foo.bar;",
          "",
          "import com.google.auto.value.AutoValue;",
          "",
          "@AutoValue",
          "public abstract class Baz {",
          "  abstract String notNull();",
          "",
          "  @AutoValue.Builder",
          "  public interface Builder {",
          "    Builder setNotNull(@Nullable String x);",
          "    Baz build();",
          "  }",
          "}");
  Compilation compilation =
      javac()
          .withProcessors(new AutoValueProcessor(), new AutoValueBuilderProcessor())
          .compile(javaFileObject, nullableFileObject);
  assertThat(compilation)
      .hadErrorContaining(
          "Parameter of setter method is @Nullable but property method"
              + " foo.bar.Baz.notNull() is not")
      .inFile(javaFileObject)
      .onLineContaining("setNotNull");
}
 
Example #30
Source Project: deptective   Author: moditect   File: BasicPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDetectInvalidLocalVariableReferences() {
    Compilation compilation = compile();
    assertThat(compilation).failed();

    assertThat(compilation).hadErrorContaining(
            packageFooMustNotAccess("org.moditect.deptective.plugintest.basic.barlocalvar"));
}