@Test
  public void testCopyingMethodAnnotationsToGeneratedFields() {
    JavaFileObject inputFile =
        new InputFileBuilder()
            .setImports(getImports(PropertyAnnotationsTest.class, Target.class, ElementType.class))
            .addAnnotations(
                "@AutoValue.CopyAnnotations(exclude={PropertyAnnotationsTest."
                    + "TestAnnotation.class})",
                "@Deprecated",
                "@PropertyAnnotationsTest.TestAnnotation",
                "@PropertyAnnotationsTest.InheritedAnnotation",
                "@MethodsOnly")
            .addInnerTypes("@Target(ElementType.METHOD) @interface MethodsOnly {}")
            .build();

    // Annotations are in lexicographical order of FQN:
    // @com.google.auto.value.processor.PropertyAnnotationsTest.InheritedAnnotation precedes
    // @foo.bar.Baz.MethodsOnly precedes
    // @java.lang.Deprecated
    JavaFileObject outputFile =
        new OutputFileBuilder()
            .setImports(getImports(PropertyAnnotationsTest.class))
            .addFieldAnnotations("@PropertyAnnotationsTest.InheritedAnnotation", "@Deprecated")
            .addMethodAnnotations(
                "@PropertyAnnotationsTest.InheritedAnnotation", "@Baz.MethodsOnly", "@Deprecated")
            .build();

    Compilation compilation =
        javac()
            .withOptions("-A" + Nullables.NULLABLE_OPTION + "=")
            .withProcessors(new AutoValueProcessor())
            .compile(inputFile);
    assertThat(compilation).succeeded();
    assertThat(compilation)
        .generatedSourceFile("foo.bar.AutoValue_Baz")
        .hasSourceEquivalentTo(outputFile);
  }
Tests that when CopyAnnotationsToGeneratedField is present on a method, all non-inherited
annotations (except those appearing in CopyAnnotationsToGeneratedField.exclude) are copied to
the method implementation in the generated class.
value/src/test/java/com/google/auto/value/processor/PropertyAnnotationsTest.java