diff --git a/annotationwrapper/api/pom.xml b/annotationwrapper/api/pom.xml index 46d540eb..72c71559 100644 --- a/annotationwrapper/api/pom.xml +++ b/annotationwrapper/api/pom.xml @@ -8,7 +8,7 @@ io.toolisticon.aptk aptk-annotationwrapper-parent - 0.22.11 + 0.23.0 aptk-annotationwrapper-api diff --git a/annotationwrapper/integrationtest/pom.xml b/annotationwrapper/integrationtest/pom.xml index ece7607e..4cb1fbba 100644 --- a/annotationwrapper/integrationtest/pom.xml +++ b/annotationwrapper/integrationtest/pom.xml @@ -9,7 +9,7 @@ io.toolisticon.aptk aptk-annotationwrapper-parent - 0.22.11 + 0.23.0 aptk-annotationwrapper-integrationTest @@ -112,6 +112,12 @@ cute + + io.toolisticon.cute + cute-legacy + + + diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/TestAnnotation.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/ExampleTestAnnotation.java similarity index 97% rename from annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/TestAnnotation.java rename to annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/ExampleTestAnnotation.java index beb871c8..a4107280 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/TestAnnotation.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/ExampleTestAnnotation.java @@ -9,7 +9,7 @@ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented -public @interface TestAnnotation { +public @interface ExampleTestAnnotation { // single value attributes diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/AutoDetectedCustomCodeClass.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/AutoDetectedCustomCodeClass.java index f2d6ff3f..5a437c55 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/AutoDetectedCustomCodeClass.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/AutoDetectedCustomCodeClass.java @@ -1,12 +1,12 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; public class AutoDetectedCustomCodeClass { - @CustomCodeMethod(TestAnnotation.class) - public static String autoDetectedMethod(TestAnnotationWrapper testAnnotationWrapper, String firstArg) { + @CustomCodeMethod(ExampleTestAnnotation.class) + public static String autoDetectedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { testAnnotationWrapper.enumAttribute(); return "it worked : " + firstArg; } diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/CustomCodeClass.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/CustomCodeClass.java index 9812b786..5cbea632 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/CustomCodeClass.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/CustomCodeClass.java @@ -1,18 +1,18 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; public class CustomCodeClass { - @CustomCodeMethod(TestAnnotation.class) - public static String forwardedMethod(TestAnnotationWrapper testAnnotationWrapper, String firstArg) { + @CustomCodeMethod(ExampleTestAnnotation.class) + public static String forwardedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { testAnnotationWrapper.enumAttribute(); return "it worked : " + firstArg; } - @CustomCodeMethod(TestAnnotation.class) - public static void forwardedMethodWithNoReturnValue(TestAnnotationWrapper testAnnotationWrapper, String firstArg) { + @CustomCodeMethod(ExampleTestAnnotation.class) + public static void forwardedMethodWithNoReturnValue(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { testAnnotationWrapper.enumAttribute(); } diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/package-info.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/package-info.java index cda324fa..f0887a0f 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/package-info.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/package-info.java @@ -1,11 +1,11 @@ @AnnotationWrapper( - value = {TestAnnotation.class, TestDefaultsAnnotation.class}, + value = {ExampleTestAnnotation.class, TestDefaultsAnnotation.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = true) package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; import io.toolisticon.aptk.annotationwrapper.test.TestDefaultsAnnotation; diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/AutoDetectedCustomCodeClass.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/AutoDetectedCustomCodeClass.java index 497c5a20..52557817 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/AutoDetectedCustomCodeClass.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/AutoDetectedCustomCodeClass.java @@ -1,12 +1,12 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationontype; import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; public class AutoDetectedCustomCodeClass { - @CustomCodeMethod(TestAnnotation.class) - public static String autoDetectedMethod(TestAnnotationWrapper testAnnotationWrapper, String firstArg) { + @CustomCodeMethod(ExampleTestAnnotation.class) + public static String autoDetectedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { testAnnotationWrapper.enumAttribute(); return "it worked : " + firstArg; } diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/CustomCodeClass.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/CustomCodeClass.java index c8a924a8..311a2f1b 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/CustomCodeClass.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/CustomCodeClass.java @@ -1,18 +1,18 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationontype; import io.toolisticon.aptk.annotationwrapper.api.CustomCodeMethod; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; public class CustomCodeClass { - @CustomCodeMethod(TestAnnotation.class) - public static String forwardedMethod(TestAnnotationWrapper testAnnotationWrapper, String firstArg) { + @CustomCodeMethod(ExampleTestAnnotation.class) + public static String forwardedMethod(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { testAnnotationWrapper.enumAttribute(); return "it worked : " + firstArg; } - @CustomCodeMethod(TestAnnotation.class) - public static void forwardedMethodWithNoReturnValue(TestAnnotationWrapper testAnnotationWrapper, String firstArg) { + @CustomCodeMethod(ExampleTestAnnotation.class) + public static void forwardedMethodWithNoReturnValue(ExampleTestAnnotationWrapper testAnnotationWrapper, String firstArg) { testAnnotationWrapper.enumAttribute(); } diff --git a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/PackagePlaceholder.java b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/PackagePlaceholder.java index f664d7ed..d54b6f36 100644 --- a/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/PackagePlaceholder.java +++ b/annotationwrapper/integrationtest/src/main/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/PackagePlaceholder.java @@ -1,12 +1,12 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationontype; import io.toolisticon.aptk.annotationwrapper.api.AnnotationWrapper; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; import io.toolisticon.aptk.annotationwrapper.test.TestDefaultsAnnotation; @AnnotationWrapper( - value = {TestAnnotation.class, TestDefaultsAnnotation.class}, + value = {ExampleTestAnnotation.class, TestDefaultsAnnotation.class}, bindCustomCode = {CustomCodeClass.class}, automaticallyWrapEmbeddedAnnotations = true) diff --git a/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/IntegrationTest.java b/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/IntegrationTest.java index 3c660612..42db0eb1 100644 --- a/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/IntegrationTest.java +++ b/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationonpackage/IntegrationTest.java @@ -1,7 +1,7 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationonpackage; import io.toolisticon.aptk.annotationwrapper.test.EmbeddedAnnotation; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; import io.toolisticon.aptk.annotationwrapper.test.TestDefaultsAnnotation; import io.toolisticon.aptk.annotationwrapper.test.TestEnum; import io.toolisticon.aptk.cute.APTKUnitTestProcessor; @@ -9,6 +9,7 @@ import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeMirrorWrapper; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.PassIn; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -26,7 +27,7 @@ */ public class IntegrationTest { - CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder.unitTest(); + CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder.unitTest(); @Before public void init() { @@ -34,17 +35,17 @@ public void init() { } @PassIn - @TestAnnotation( - stringAttribute = "WTF", - doubleAttribute = 1.0, - longAttribute = 1L, - enumAttribute = TestEnum.TWO, - typeAttribute = String.class, - annotationAttribute = @EmbeddedAnnotation(1), - stringArrayAttribute = {"1", "2", "3"}, - typeArrayAttribute = {Long.class, String.class}, - enumArrayAttribute = {TestEnum.TWO, TestEnum.THREE}, - annotationArrayAttribute = {@EmbeddedAnnotation(1), @EmbeddedAnnotation(2)} + @ExampleTestAnnotation( + stringAttribute = "WTF", + doubleAttribute = 1.0, + longAttribute = 1L, + enumAttribute = TestEnum.TWO, + typeAttribute = String.class, + annotationAttribute = @EmbeddedAnnotation(1), + stringArrayAttribute = {"1", "2", "3"}, + typeArrayAttribute = {Long.class, String.class}, + enumArrayAttribute = {TestEnum.TWO, TestEnum.THREE}, + annotationArrayAttribute = {@EmbeddedAnnotation(1), @EmbeddedAnnotation(2)} ) public static class TestUsage { @@ -53,63 +54,63 @@ public static class TestUsage { @Test public void testWrappedAccess() { unitTestBuilder.defineTestWithPassedInElement(TestUsage.class, new APTKUnitTestProcessor() { - @Override - public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - - TestAnnotationWrapper testAnnotationWrapper = TestAnnotationWrapper.wrap(typeElement); - - // check if element is returned correctly - MatcherAssert.assertThat(testAnnotationWrapper._annotatedElement(), Matchers.is((Element) typeElement)); - MatcherAssert.assertThat(testAnnotationWrapper.annotationAttribute()._annotatedElement(), Matchers.is((Element) typeElement)); - - - // single attribute values - - MatcherAssert.assertThat(testAnnotationWrapper.charAttribute(), Matchers.is('X')); - MatcherAssert.assertThat(testAnnotationWrapper.stringAttribute(), Matchers.is("WTF")); - MatcherAssert.assertThat(testAnnotationWrapper.floatAttribute(), Matchers.is(0.0f)); - MatcherAssert.assertThat(testAnnotationWrapper.doubleAttribute(), Matchers.is(1.0)); - MatcherAssert.assertThat(testAnnotationWrapper.shortAttribute(), Matchers.is((short) 0)); - MatcherAssert.assertThat(testAnnotationWrapper.byteAttribute(), Matchers.is((byte) 0)); - MatcherAssert.assertThat(testAnnotationWrapper.intAttribute(), Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.longAttribute(), Matchers.is(1L)); - MatcherAssert.assertThat(testAnnotationWrapper.enumAttribute(), Matchers.is(TestEnum.TWO)); - MatcherAssert.assertThat(testAnnotationWrapper.typeAttributeAsFqn(), Matchers.is(String.class.getCanonicalName())); - MatcherAssert.assertThat(testAnnotationWrapper.typeAttributeAsTypeMirror().toString(), Matchers.is(String.class.getCanonicalName())); - MatcherAssert.assertThat(testAnnotationWrapper.typeAttributeAsTypeMirrorWrapper().getQualifiedName(), Matchers.is(String.class.getCanonicalName())); - MatcherAssert.assertThat((Long) AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(testAnnotationWrapper.annotationAttributeAsAnnotationMirror()).getValue(), Matchers.is(1L)); - MatcherAssert.assertThat(testAnnotationWrapper.annotationAttribute().value(), Matchers.is(1L)); - - // array based attribute values - MatcherAssert.assertThat(testAnnotationWrapper.charArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.stringArrayAttribute(), Matchers.arrayContaining("1", "2", "3")); - - MatcherAssert.assertThat(testAnnotationWrapper.intArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.longArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.shortArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.byteArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.floatArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.doubleArrayAttribute().length, Matchers.is(0)); - MatcherAssert.assertThat(testAnnotationWrapper.booleanArrayAttribute().length, Matchers.is(0)); - - MatcherAssert.assertThat(testAnnotationWrapper.typeArrayAttributeAsFqn(), Matchers.arrayContaining(Long.class.getCanonicalName(), String.class.getCanonicalName())); - TypeMirror[] typeMirrorArray = testAnnotationWrapper.typeArrayAttributeAsTypeMirror(); - MatcherAssert.assertThat(typeMirrorArray[0].toString(), Matchers.is(Long.class.getCanonicalName())); - MatcherAssert.assertThat(typeMirrorArray[1].toString(), Matchers.is(String.class.getCanonicalName())); - TypeMirrorWrapper[] typeMirrorWrapperArray = testAnnotationWrapper.typeArrayAttributeAsTypeMirrorWrapper(); - MatcherAssert.assertThat(typeMirrorWrapperArray[0].getQualifiedName(), Matchers.is(Long.class.getCanonicalName())); - MatcherAssert.assertThat(typeMirrorWrapperArray[1].getQualifiedName(), Matchers.is(String.class.getCanonicalName())); - MatcherAssert.assertThat(testAnnotationWrapper.enumArrayAttribute(), Matchers.arrayContaining(TestEnum.TWO, TestEnum.THREE)); - AnnotationMirror[] annotationMirrors = testAnnotationWrapper.annotationArrayAttributeAsAnnotationMirrorArray(); - MatcherAssert.assertThat((Long) AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(annotationMirrors[0]).getValue(), Matchers.is(1L)); - MatcherAssert.assertThat((Long) AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(annotationMirrors[1]).getValue(), Matchers.is(2L)); - EmbeddedAnnotationWrapper[] embeddedAnnotationWrappers = testAnnotationWrapper.annotationArrayAttribute(); - MatcherAssert.assertThat(embeddedAnnotationWrappers[0].value(), Matchers.is(1L)); - MatcherAssert.assertThat(embeddedAnnotationWrappers[1].value(), Matchers.is(2L)); - } - }) - .compilationShouldSucceed() - .executeTest(); + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { + + ExampleTestAnnotationWrapper testAnnotationWrapper = ExampleTestAnnotationWrapper.wrap(typeElement); + + // check if element is returned correctly + MatcherAssert.assertThat(testAnnotationWrapper._annotatedElement(), Matchers.is((Element) typeElement)); + MatcherAssert.assertThat(testAnnotationWrapper.annotationAttribute()._annotatedElement(), Matchers.is((Element) typeElement)); + + + // single attribute values + + MatcherAssert.assertThat(testAnnotationWrapper.charAttribute(), Matchers.is('X')); + MatcherAssert.assertThat(testAnnotationWrapper.stringAttribute(), Matchers.is("WTF")); + MatcherAssert.assertThat(testAnnotationWrapper.floatAttribute(), Matchers.is(0.0f)); + MatcherAssert.assertThat(testAnnotationWrapper.doubleAttribute(), Matchers.is(1.0)); + MatcherAssert.assertThat(testAnnotationWrapper.shortAttribute(), Matchers.is((short) 0)); + MatcherAssert.assertThat(testAnnotationWrapper.byteAttribute(), Matchers.is((byte) 0)); + MatcherAssert.assertThat(testAnnotationWrapper.intAttribute(), Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.longAttribute(), Matchers.is(1L)); + MatcherAssert.assertThat(testAnnotationWrapper.enumAttribute(), Matchers.is(TestEnum.TWO)); + MatcherAssert.assertThat(testAnnotationWrapper.typeAttributeAsFqn(), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat(testAnnotationWrapper.typeAttributeAsTypeMirror().toString(), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat(testAnnotationWrapper.typeAttributeAsTypeMirrorWrapper().getQualifiedName(), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat((Long) AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(testAnnotationWrapper.annotationAttributeAsAnnotationMirror()).getValue(), Matchers.is(1L)); + MatcherAssert.assertThat(testAnnotationWrapper.annotationAttribute().value(), Matchers.is(1L)); + + // array based attribute values + MatcherAssert.assertThat(testAnnotationWrapper.charArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.stringArrayAttribute(), Matchers.arrayContaining("1", "2", "3")); + + MatcherAssert.assertThat(testAnnotationWrapper.intArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.longArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.shortArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.byteArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.floatArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.doubleArrayAttribute().length, Matchers.is(0)); + MatcherAssert.assertThat(testAnnotationWrapper.booleanArrayAttribute().length, Matchers.is(0)); + + MatcherAssert.assertThat(testAnnotationWrapper.typeArrayAttributeAsFqn(), Matchers.arrayContaining(Long.class.getCanonicalName(), String.class.getCanonicalName())); + TypeMirror[] typeMirrorArray = testAnnotationWrapper.typeArrayAttributeAsTypeMirror(); + MatcherAssert.assertThat(typeMirrorArray[0].toString(), Matchers.is(Long.class.getCanonicalName())); + MatcherAssert.assertThat(typeMirrorArray[1].toString(), Matchers.is(String.class.getCanonicalName())); + TypeMirrorWrapper[] typeMirrorWrapperArray = testAnnotationWrapper.typeArrayAttributeAsTypeMirrorWrapper(); + MatcherAssert.assertThat(typeMirrorWrapperArray[0].getQualifiedName(), Matchers.is(Long.class.getCanonicalName())); + MatcherAssert.assertThat(typeMirrorWrapperArray[1].getQualifiedName(), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat(testAnnotationWrapper.enumArrayAttribute(), Matchers.arrayContaining(TestEnum.TWO, TestEnum.THREE)); + AnnotationMirror[] annotationMirrors = testAnnotationWrapper.annotationArrayAttributeAsAnnotationMirrorArray(); + MatcherAssert.assertThat((Long) AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(annotationMirrors[0]).getValue(), Matchers.is(1L)); + MatcherAssert.assertThat((Long) AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(annotationMirrors[1]).getValue(), Matchers.is(2L)); + EmbeddedAnnotationWrapper[] embeddedAnnotationWrappers = testAnnotationWrapper.annotationArrayAttribute(); + MatcherAssert.assertThat(embeddedAnnotationWrappers[0].value(), Matchers.is(1L)); + MatcherAssert.assertThat(embeddedAnnotationWrappers[1].value(), Matchers.is(2L)); + } + }) + .compilationShouldSucceed() + .executeTest(); } @PassIn @@ -123,14 +124,14 @@ public void testDefaultValueDetection() { unitTestBuilder.defineTestWithPassedInElement(DefaultTestCase.class, new APTKUnitTestProcessor() { @Override public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - // single attribute values - TestDefaultsAnnotationWrapper wrappedAnnotation = TestDefaultsAnnotationWrapper.wrap(typeElement); - MatcherAssert.assertThat(wrappedAnnotation.withDefaultIsDefaultValue(), Matchers.is(true)); - MatcherAssert.assertThat(wrappedAnnotation.withoutDefaultIsDefaultValue(), Matchers.is(false)); - } - }) - .compilationShouldSucceed() - .executeTest(); + // single attribute values + TestDefaultsAnnotationWrapper wrappedAnnotation = TestDefaultsAnnotationWrapper.wrap(typeElement); + MatcherAssert.assertThat(wrappedAnnotation.withDefaultIsDefaultValue(), Matchers.is(true)); + MatcherAssert.assertThat(wrappedAnnotation.withoutDefaultIsDefaultValue(), Matchers.is(false)); + } + }) + .compilationShouldSucceed() + .executeTest(); } @Test @@ -139,63 +140,63 @@ public void testCustomCodeForwarding() { @Override public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - // single attribute values - TestAnnotationWrapper wrappedAnnotation = TestAnnotationWrapper.wrap(typeElement); - MatcherAssert.assertThat(wrappedAnnotation.forwardedMethod("yes"), Matchers.is("it worked : " + "yes")); - wrappedAnnotation.forwardedMethodWithNoReturnValue("yes"); - wrappedAnnotation.autoDetectedMethod("yes"); + // single attribute values + ExampleTestAnnotationWrapper wrappedAnnotation = ExampleTestAnnotationWrapper.wrap(typeElement); + MatcherAssert.assertThat(wrappedAnnotation.forwardedMethod("yes"), Matchers.is("it worked : " + "yes")); + wrappedAnnotation.forwardedMethodWithNoReturnValue("yes"); + wrappedAnnotation.autoDetectedMethod("yes"); - } - }) - .compilationShouldSucceed() - .executeTest(); + } + }) + .compilationShouldSucceed() + .executeTest(); } @Test public void testCompilerMessageTriggeredByAnnotationWrapper() { unitTestBuilder.defineTestWithPassedInElement(TestUsage.class, new APTKUnitTestProcessor() { - @Override - public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - - // single attribute values - TestAnnotationWrapper wrappedAnnotation = TestAnnotationWrapper.wrap(typeElement); - wrappedAnnotation.compilerMessage().asNote().write("NOTE"); - wrappedAnnotation.compilerMessage().asWarning().write("WARNING"); - wrappedAnnotation.compilerMessage().asMandatoryWarning().write("MWARNING"); - wrappedAnnotation.compilerMessage().asError().write("ERROR"); - - } - }) - .compilationShouldFail() - .expectNoteMessage().thatIsEqualTo("NOTE") - .expectWarningMessage().thatIsEqualTo("WARNING") - .expectMandatoryWarningMessage().thatIsEqualTo("MWARNING") - .expectErrorMessage().thatIsEqualTo("ERROR") - .executeTest(); + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { + + // single attribute values + ExampleTestAnnotationWrapper wrappedAnnotation = ExampleTestAnnotationWrapper.wrap(typeElement); + wrappedAnnotation.compilerMessage().asNote().write("NOTE"); + wrappedAnnotation.compilerMessage().asWarning().write("WARNING"); + wrappedAnnotation.compilerMessage().asMandatoryWarning().write("MWARNING"); + wrappedAnnotation.compilerMessage().asError().write("ERROR"); + + } + }) + .compilationShouldFail() + .expectNoteMessage().thatIsEqualTo("NOTE") + .expectWarningMessage().thatIsEqualTo("WARNING") + .expectMandatoryWarningMessage().thatIsEqualTo("MWARNING") + .expectErrorMessage().thatIsEqualTo("ERROR") + .executeTest(); } @Test public void testCompilerMessageTriggeredByAnnotationValueWrapper() { unitTestBuilder.defineTestWithPassedInElement(TestUsage.class, new APTKUnitTestProcessor() { - @Override - public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - - // single attribute values - TestAnnotationWrapper wrappedAnnotation = TestAnnotationWrapper.wrap(typeElement); - - wrappedAnnotation.annotationAttribute().compilerMessage().asNote().write("NOTE"); - wrappedAnnotation.annotationAttribute().compilerMessage().asWarning().write("WARNING"); - wrappedAnnotation.annotationAttribute().compilerMessage().asMandatoryWarning().write("MWARNING"); - wrappedAnnotation.annotationAttribute().compilerMessage().asError().write("ERROR"); - - } - }) - .compilationShouldFail() - .expectNoteMessage().thatIsEqualTo("NOTE") - .expectWarningMessage().thatIsEqualTo("WARNING") - .expectMandatoryWarningMessage().thatIsEqualTo("MWARNING") - .expectErrorMessage().thatIsEqualTo("ERROR") - .executeTest(); + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { + + // single attribute values + ExampleTestAnnotationWrapper wrappedAnnotation = ExampleTestAnnotationWrapper.wrap(typeElement); + + wrappedAnnotation.annotationAttribute().compilerMessage().asNote().write("NOTE"); + wrappedAnnotation.annotationAttribute().compilerMessage().asWarning().write("WARNING"); + wrappedAnnotation.annotationAttribute().compilerMessage().asMandatoryWarning().write("MWARNING"); + wrappedAnnotation.annotationAttribute().compilerMessage().asError().write("ERROR"); + + } + }) + .compilationShouldFail() + .expectNoteMessage().thatIsEqualTo("NOTE") + .expectWarningMessage().thatIsEqualTo("WARNING") + .expectMandatoryWarningMessage().thatIsEqualTo("MWARNING") + .expectErrorMessage().thatIsEqualTo("ERROR") + .executeTest(); } } diff --git a/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/IntegrationTest.java b/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/IntegrationTest.java index ec28bda0..162b6da9 100644 --- a/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/IntegrationTest.java +++ b/annotationwrapper/integrationtest/src/test/java/io/toolisticon/aptk/annotationwrapper/test/annotationontype/IntegrationTest.java @@ -1,15 +1,15 @@ package io.toolisticon.aptk.annotationwrapper.test.annotationontype; import io.toolisticon.aptk.annotationwrapper.test.EmbeddedAnnotation; -import io.toolisticon.aptk.annotationwrapper.test.TestAnnotation; +import io.toolisticon.aptk.annotationwrapper.test.ExampleTestAnnotation; import io.toolisticon.aptk.annotationwrapper.test.TestDefaultsAnnotation; import io.toolisticon.aptk.annotationwrapper.test.TestEnum; import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.AnnotationUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeMirrorWrapper; -import io.toolisticon.aptk.tools.wrapper.ElementWrapper; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.PassIn; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -27,7 +27,7 @@ */ public class IntegrationTest { - CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder.unitTest(); + CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder.unitTest(); @Before public void init() { @@ -36,7 +36,7 @@ public void init() { } @PassIn - @TestAnnotation( + @ExampleTestAnnotation( stringAttribute = "WTF", doubleAttribute = 1.0, longAttribute = 1L, @@ -58,7 +58,7 @@ public void testWrappedAccess() { @Override public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - TestAnnotationWrapper testAnnotationWrapper = TestAnnotationWrapper.wrap(typeElement); + ExampleTestAnnotationWrapper testAnnotationWrapper = ExampleTestAnnotationWrapper.wrap(typeElement); // check if element is returned correctly MatcherAssert.assertThat(testAnnotationWrapper._annotatedElement(), Matchers.is((Element) typeElement)); @@ -145,7 +145,7 @@ public void testCustomCodeForwarding() { public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { // single attribute values - TestAnnotationWrapper wrappedAnnotation = TestAnnotationWrapper.wrap(typeElement); + ExampleTestAnnotationWrapper wrappedAnnotation = ExampleTestAnnotationWrapper.wrap(typeElement); MatcherAssert.assertThat(wrappedAnnotation.forwardedMethod("yes"), Matchers.is("it worked : " + "yes")); wrappedAnnotation.forwardedMethodWithNoReturnValue("yes"); wrappedAnnotation.autoDetectedMethod("yes"); diff --git a/annotationwrapper/pom.xml b/annotationwrapper/pom.xml index 63ba01c6..fd0ef578 100644 --- a/annotationwrapper/pom.xml +++ b/annotationwrapper/pom.xml @@ -11,7 +11,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 diff --git a/annotationwrapper/processor/pom.xml b/annotationwrapper/processor/pom.xml index 089682a3..b1a6e084 100644 --- a/annotationwrapper/processor/pom.xml +++ b/annotationwrapper/processor/pom.xml @@ -9,7 +9,7 @@ io.toolisticon.aptk aptk-annotationwrapper-parent - 0.22.11 + 0.23.0 aptk-annotationwrapper-processor @@ -40,6 +40,11 @@ cute + + io.toolisticon.cute + cute-legacy + + io.toolisticon.aptk aptk-cute diff --git a/annotationwrapper/processor/src/test/java/io/toolisticon/aptk/annotationwrapper/processor/AnnotationWrapperProcessorTest.java b/annotationwrapper/processor/src/test/java/io/toolisticon/aptk/annotationwrapper/processor/AnnotationWrapperProcessorTest.java index dab6e071..a879db86 100644 --- a/annotationwrapper/processor/src/test/java/io/toolisticon/aptk/annotationwrapper/processor/AnnotationWrapperProcessorTest.java +++ b/annotationwrapper/processor/src/test/java/io/toolisticon/aptk/annotationwrapper/processor/AnnotationWrapperProcessorTest.java @@ -9,6 +9,7 @@ import io.toolisticon.aptk.tools.wrapper.ExecutableElementWrapper; import io.toolisticon.cute.CompileTestBuilder; import io.toolisticon.cute.PassIn; +import io.toolisticon.cute.UnitTest; import io.toolisticon.cute.matchers.CoreGeneratedFileObjectMatchers; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -450,7 +451,7 @@ private void test_AnnotationToWrap_getWrappedTypeMirror(TypeElement typeElement, @Test public void test_AnnotationToWrap_isAnnotationType() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(UnitTestAnnotation.class, new APTKUnitTestProcessor() { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(UnitTestAnnotation.class, new APTKUnitTestProcessor() { @Override public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { diff --git a/common/pom.xml b/common/pom.xml index 22a8aa49..5f4f16d5 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -7,7 +7,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 aptk-common diff --git a/compilermessages/api/pom.xml b/compilermessages/api/pom.xml index 28203f7a..027b96c3 100644 --- a/compilermessages/api/pom.xml +++ b/compilermessages/api/pom.xml @@ -8,7 +8,7 @@ io.toolisticon.aptk aptk-compilermessages-parent - 0.22.11 + 0.23.0 aptk-compilermessages-api diff --git a/compilermessages/integrationtest/pom.xml b/compilermessages/integrationtest/pom.xml index aa06ae8d..39e73b94 100644 --- a/compilermessages/integrationtest/pom.xml +++ b/compilermessages/integrationtest/pom.xml @@ -9,7 +9,7 @@ io.toolisticon.aptk aptk-compilermessages-parent - 0.22.11 + 0.23.0 aptk-compilermessages-integrationTest diff --git a/compilermessages/pom.xml b/compilermessages/pom.xml index 86ab9364..f752e722 100644 --- a/compilermessages/pom.xml +++ b/compilermessages/pom.xml @@ -11,7 +11,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 diff --git a/compilermessages/processor/pom.xml b/compilermessages/processor/pom.xml index 0f1b875f..81100cee 100644 --- a/compilermessages/processor/pom.xml +++ b/compilermessages/processor/pom.xml @@ -9,7 +9,7 @@ io.toolisticon.aptk aptk-compilermessages-parent - 0.22.11 + 0.23.0 aptk-compilermessages-processor diff --git a/cute/pom.xml b/cute/pom.xml index d49d53b6..45a30b87 100644 --- a/cute/pom.xml +++ b/cute/pom.xml @@ -8,7 +8,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 aptk-cute @@ -20,19 +20,13 @@ io.toolisticon.cute cute - provided - - - - io.toolisticon.aptk - aptk-tools + ${cute.version} provided io.toolisticon.aptk aptk-common - provided @@ -81,6 +75,7 @@ * + io.toolisticon.aptk:aptk-common:*:* *:*:*:*:test:* *:*:*:*:provided:* diff --git a/cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn.java b/cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn.java new file mode 100644 index 00000000..d6cdc4b1 --- /dev/null +++ b/cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn.java @@ -0,0 +1,48 @@ +package io.toolisticon.aptk.cute; + +import io.toolisticon.aptk.common.ToolingProvider; +import io.toolisticon.cute.UnitTestForTestingAnnotationProcessorsWithoutPassIn; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.Processor; +import javax.lang.model.element.Element; + +/** + * Convenient unit test processor for testing annotation processors build with the APTK with toolisticon's cute framework. + * + * @param The processor under test. init method will be called and {@link ToolingProvider} will be set. + */ +public abstract class APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn implements UnitTestForTestingAnnotationProcessorsWithoutPassIn { + + + /** + * The original unit test processor method. Contains logic to initialize the ToolingProvider. + * Will be called by cute framework. Propagates call to aptkUnitTest method after initializations. + * + * @param processor The processor under test + * @param processingEnvironment the processing environment + */ + @Override + public final void unitTest(PROCESSOR processor, ProcessingEnvironment processingEnvironment) { + + try { + // do initializations + ToolingProvider.setTooling(processingEnvironment); + + // propagate to unit test implementation + this.aptkUnitTest(processor, processingEnvironment); + + } finally { + ToolingProvider.clearTooling(); + } + + } + + /** + * The unit test method. + * + * @param unit the initialized processor under test + * @param processingEnvironment the processingEnvironment + */ + public abstract void aptkUnitTest(PROCESSOR unit, ProcessingEnvironment processingEnvironment); +} diff --git a/cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorWithoutPassIn.java b/cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorWithoutPassIn.java new file mode 100644 index 00000000..6fa7ba78 --- /dev/null +++ b/cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorWithoutPassIn.java @@ -0,0 +1,38 @@ +package io.toolisticon.aptk.cute; + +import io.toolisticon.aptk.common.ToolingProvider; +import io.toolisticon.cute.UnitTestWithoutPassIn; + +import javax.annotation.processing.ProcessingEnvironment; + +public abstract class APTKUnitTestProcessorWithoutPassIn implements UnitTestWithoutPassIn { + + /** + * The original unit test processor method. Contains logic to initialize the ToolingProvider. + * Will be called by cute framework. Propagates call to aptkUnitTest method after initializations. + * + * @param processingEnvironment the processing environment + */ + @Override + public final void unitTest(ProcessingEnvironment processingEnvironment) { + + try { + // do initializations + ToolingProvider.setTooling(processingEnvironment); + + // propagate to unit test implementation + this.aptkUnitTest(processingEnvironment); + + } finally { + ToolingProvider.clearTooling(); + } + + } + + /** + * The unit test method. + * + * @param processingEnvironment the processingEnvironment + */ + public abstract void aptkUnitTest(ProcessingEnvironment processingEnvironment); +} \ No newline at end of file diff --git a/cute/src/test/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsTest.java b/cute/src/test/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsTest.java deleted file mode 100644 index d068e66c..00000000 --- a/cute/src/test/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.toolisticon.aptk.cute; - -import io.toolisticon.aptk.tools.AbstractAnnotationProcessor; -import io.toolisticon.aptk.common.ToolingProvider; -import io.toolisticon.cute.CompileTestBuilder; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; - -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.element.TypeElement; -import java.util.Set; - -/** - * Unit test for {@link APTKUnitTestProcessorForTestingAnnotationProcessors}. - */ -public class APTKUnitTestProcessorForTestingAnnotationProcessorsTest { - - private static boolean unitTestMethodCalled = false; - - public static class TestProcessor extends AbstractAnnotationProcessor { - - private static boolean initCalled = false; - - - @Override - public synchronized void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - - initCalled = true; - } - - @Override - public boolean processAnnotations(Set annotations, RoundEnvironment roundEnv) { - return false; - } - - } - - @Before - public void init() { - TestProcessor.initCalled = false; - unitTestMethodCalled = false; - } - - @Test - public void testIfToolingIsSetCorrectly() { - - CompileTestBuilder.unitTest().defineTest(TestProcessor.class, new APTKUnitTestProcessorForTestingAnnotationProcessors() { - @Override - public void aptkUnitTest(TestProcessor processor, ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - - unitTestMethodCalled = true; - - MatcherAssert.assertThat(ToolingProvider.getTooling(), Matchers.notNullValue()); - - } - }) - .compilationShouldSucceed() - .executeTest(); - - - // check if init was called - MatcherAssert.assertThat("Init must have been called", TestProcessor.initCalled); - MatcherAssert.assertThat("aptkUnitTest method must have been called", unitTestMethodCalled); - - } - - -} diff --git a/cute/src/test/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorTest.java b/cute/src/test/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorTest.java deleted file mode 100644 index 52b243d2..00000000 --- a/cute/src/test/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.toolisticon.aptk.cute; - -import io.toolisticon.aptk.common.ToolingProvider; -import io.toolisticon.cute.CompileTestBuilder; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.junit.Test; - -import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.TypeElement; - -/** - * Unit test for {@link APTKUnitTestProcessor}. - */ -public class APTKUnitTestProcessorTest { - - private static boolean unitTestMethodCalled = false; - - - - @Test - public void testIfToolingIsSetCorrectly() { - - CompileTestBuilder.unitTest().defineTest( new APTKUnitTestProcessor() { - @Override - public void aptkUnitTest( ProcessingEnvironment processingEnvironment, TypeElement typeElement) { - - unitTestMethodCalled = true; - - MatcherAssert.assertThat(ToolingProvider.getTooling(), Matchers.notNullValue()); - - } - }) - .compilationShouldSucceed() - .executeTest(); - - - // check if init was called - MatcherAssert.assertThat("aptkUnitTest method must have been called", unitTestMethodCalled); - - } - - -} diff --git a/example/example-annotationprocessor/pom.xml b/example/example-annotationprocessor/pom.xml index dfc84407..9ffc4489 100644 --- a/example/example-annotationprocessor/pom.xml +++ b/example/example-annotationprocessor/pom.xml @@ -8,7 +8,7 @@ io.toolisticon.aptk aptk-example-parent - 0.22.11 + 0.23.0 aptk-example-annotationprocessor @@ -21,6 +21,8 @@ aptk-tools + + io.toolisticon.aptk aptk-example-annotations @@ -32,6 +34,21 @@ spiap-api + + + io.toolisticon.cute + cute + + + + io.toolisticon.cute + cute-legacy + + + + io.toolisticon.aptk + aptk-cute + diff --git a/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorTest.java b/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorTest.java index ac73819e..5550a351 100644 --- a/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorTest.java +++ b/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorTest.java @@ -3,6 +3,7 @@ import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.CoreMatcherValidationMessages; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import org.junit.Before; import org.junit.Test; @@ -13,7 +14,7 @@ public class ImplementsSpecificInterfaceCheckAnnotationProcessorTest { - private CompileTestBuilder.CompilationTestBuilder compilationTestBuilder = CompileTestBuilder.compilationTest() + private CompileTestBuilderApi.CompilationTestBuilder compilationTestBuilder = CompileTestBuilder.compilationTest() .addProcessors(ImplementsSpecificInterfaceCheckAnnotationProcessor.class); @Before diff --git a/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorUnitTest.java b/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorUnitTest.java index 11cd63b6..7ea24b3e 100644 --- a/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorUnitTest.java +++ b/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorUnitTest.java @@ -1,7 +1,7 @@ package io.toolisticon.aptk.example.annotationprocessor; -import io.toolisticon.aptk.common.ToolingProvider; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.cute.CompileTestBuilder; import io.toolisticon.cute.UnitTest; import org.hamcrest.MatcherAssert; @@ -17,13 +17,13 @@ public class ImplementsSpecificInterfaceCheckAnnotationProcessorUnitTest { public void testValidUsageWithAssignableParameters() { CompileTestBuilder.unitTest() - .defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { + .defineTest(new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { ImplementsSpecificInterfaceCheckAnnotationProcessor unit = new ImplementsSpecificInterfaceCheckAnnotationProcessor(); unit.init(processingEnvironment); - ToolingProvider.setTooling(processingEnvironment); + MatcherAssert.assertThat("Should be assignable to Object", unit.isAssignableTo(typeElement, Object.class.getCanonicalName())); @@ -38,13 +38,12 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement ty public void testValidUsageWithNonAssignableParameters() { CompileTestBuilder.unitTest() - .defineTest(new UnitTest() { + .defineTest(new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement typeElement) { ImplementsSpecificInterfaceCheckAnnotationProcessor unit = new ImplementsSpecificInterfaceCheckAnnotationProcessor(); unit.init(processingEnvironment); - ToolingProvider.setTooling(processingEnvironment); MatcherAssert.assertThat("Should not be assignable to String", !unit.isAssignableTo(typeElement, String.class.getCanonicalName())); diff --git a/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeProcessorTest.java b/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeProcessorTest.java index 81a8208f..5fbfdb6e 100644 --- a/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeProcessorTest.java +++ b/example/example-annotationprocessor/src/test/java/io/toolisticon/aptk/example/annotationprocessor/MethodWithOneStringParameterAndVoidReturnTypeProcessorTest.java @@ -3,6 +3,7 @@ import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.CoreMatcherValidationMessages; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import org.junit.Before; import org.junit.Test; @@ -15,7 +16,7 @@ public void init() { } - private CompileTestBuilder.CompilationTestBuilder compilationTestBuilder = CompileTestBuilder.compilationTest() + private CompileTestBuilderApi.CompilationTestBuilder compilationTestBuilder = CompileTestBuilder.compilationTest() .addProcessors(MethodHasStringParameterAndVoidReturnTypeCheckAnnotationProcessor.class); @Test diff --git a/example/example-annotations/pom.xml b/example/example-annotations/pom.xml index 12f12ee4..dd72e543 100644 --- a/example/example-annotations/pom.xml +++ b/example/example-annotations/pom.xml @@ -7,7 +7,7 @@ io.toolisticon.aptk aptk-example-parent - 0.22.11 + 0.23.0 aptk-example-annotations diff --git a/example/example-usecase/pom.xml b/example/example-usecase/pom.xml index 98b65c66..65a6d396 100644 --- a/example/example-usecase/pom.xml +++ b/example/example-usecase/pom.xml @@ -7,7 +7,7 @@ io.toolisticon.aptk aptk-example-parent - 0.22.11 + 0.23.0 aptk-example-usecase diff --git a/example/pom.xml b/example/pom.xml index 8ac73f7d..b7a1f020 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -7,7 +7,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 aptk-example-parent diff --git a/extensions/java9/pom.xml b/extensions/java9/pom.xml index f14c686b..24ca55ba 100644 --- a/extensions/java9/pom.xml +++ b/extensions/java9/pom.xml @@ -8,7 +8,7 @@ io.toolisticon.aptk extension-parent - 0.22.11 + 0.23.0 aptk-tools-java9 diff --git a/extensions/pom.xml b/extensions/pom.xml index 8b60529e..3219dd6c 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -7,7 +7,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 extension-parent diff --git a/pom.xml b/pom.xml index 1743c7ef..721c6896 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 pom aptk-parent @@ -87,7 +87,7 @@ 0.11.0 - 0.12.1 + 1.0.0_RC1 4.13.2 @@ -718,6 +718,11 @@ cute + + io.toolisticon.cute + cute-legacy + + @@ -742,6 +747,13 @@ ${project.version} + + io.toolisticon.aptk + aptk-cute + ${project.version} + test + + io.toolisticon.aptk aptk-annotationwrapper-api @@ -769,6 +781,13 @@ test + + io.toolisticon.cute + cute-legacy + ${cute.version} + test + + diff --git a/templating/pom.xml b/templating/pom.xml index fbe14fca..76a480ac 100644 --- a/templating/pom.xml +++ b/templating/pom.xml @@ -7,7 +7,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 aptk-templating diff --git a/tools/pom.xml b/tools/pom.xml index 2b5896aa..c028b0ba 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -8,7 +8,7 @@ io.toolisticon.aptk aptk-parent - 0.22.11 + 0.23.0 aptk-tools @@ -32,6 +32,18 @@ test + + io.toolisticon.aptk + aptk-cute + ${project.version} + + + + io.toolisticon.cute + cute-legacy + test + + diff --git a/tools/src/main/java/io/toolisticon/aptk/tools/TypeMirrorWrapper.java b/tools/src/main/java/io/toolisticon/aptk/tools/TypeMirrorWrapper.java index 76b4899e..89e93f88 100644 --- a/tools/src/main/java/io/toolisticon/aptk/tools/TypeMirrorWrapper.java +++ b/tools/src/main/java/io/toolisticon/aptk/tools/TypeMirrorWrapper.java @@ -241,6 +241,27 @@ public static boolean isCollection(TypeMirror typeMirror) { } + /** + * Checks if wrapped TypeMirror represents an Iterable. + * + * @return true if wrapped TypeMirror represents an Iterable, otherwise false + */ + public boolean isIterable() { + return isIterable(typeMirror); + } + + /** + * Checks if passed TypeMirror represents an Iterable. + * + * @param typeMirror the TypeMirror to check + * @return true if passed TypeMirror represents an Iterable, otherwise false + */ + public static boolean isIterable(TypeMirror typeMirror) { + + return isDeclared(typeMirror) && TypeUtils.TypeComparison.isAssignableTo(TypeUtils.getTypes().erasure(typeMirror), TypeUtils.TypeRetrieval.getTypeMirror(Iterable.class)); + + } + /** * Checks if wrapped TypeMirror is an array. @@ -415,8 +436,8 @@ public static boolean hasComponentType(TypeMirror typeMirror) { } /** - * Gets the ComponentType of TypeMirror representing an array or collection. - * Will return TypeMirror of Object if collections component type isn't explicitly set. + * Gets the ComponentType of TypeMirror representing an array, a Collection or an Iterable. + * Will return TypeMirror of Object if Collections/Iterables component type isn't explicitly set. * * @return The component TypeMirror when passed typeMirror represents an array or collection, otherwise null. */ @@ -425,11 +446,11 @@ public TypeMirror getComponentType() { } /** - * Gets the ComponentType of TypeMirror representing an array or collection. - * Will return TypeMirror of Object if collections component type isn't explicitly set. + * Gets the ComponentType of TypeMirror representing an array, a Collection or an Iterable. + * Will return TypeMirror of Object if Collections/Iterablea component type isn't explicitly set. * * @param typeMirror the TypeMirror to check - * @return The component TypeMirror when passed typeMirror represents an array a collection, otherwise null. + * @return The component TypeMirror when passed typeMirror represents an array, a Collection or Iterable, otherwise null. */ public static TypeMirror getComponentType(TypeMirror typeMirror) { @@ -437,7 +458,7 @@ public static TypeMirror getComponentType(TypeMirror typeMirror) { return ((ArrayType) typeMirror).getComponentType(); } - if (isCollection(typeMirror)) { + if (isCollection(typeMirror) || isIterable(typeMirror)) { if (hasTypeArguments(typeMirror)) { List typeArgumentTypeMirrors = getTypeArguments(typeMirror); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/AbstractUnitTestAnnotationProcessorClass.java b/tools/src/test/java/io/toolisticon/aptk/tools/AbstractUnitTestAnnotationProcessorClass.java index 5f6729cb..b28136b9 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/AbstractUnitTestAnnotationProcessorClass.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/AbstractUnitTestAnnotationProcessorClass.java @@ -1,7 +1,7 @@ package io.toolisticon.aptk.tools; import io.toolisticon.aptk.common.ToolingProvider; - +import io.toolisticon.cute.TestAnnotation; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationUtilsTest.java index 16862f29..2b033ec4 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationUtilsTest.java @@ -1,5 +1,6 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.annotationutilstestclasses.ClassArrayAttributeAnnotation; import io.toolisticon.aptk.tools.annotationutilstestclasses.ClassAttributeAnnotation; import io.toolisticon.aptk.tools.annotationutilstestclasses.DefaultValueAnnotation; @@ -8,19 +9,20 @@ import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.wrapper.AnnotationMirrorWrapper; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; -import java.lang.annotation.Repeatable; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -33,7 +35,7 @@ */ public class AnnotationUtilsTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -50,26 +52,27 @@ public void init() { @Test public void annotationUtilsTest_classAttribute_emptyValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classAttribute_empty") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classAttribute_empty") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(AnnotationUtils.getClassAttributeFromAnnotationAsFqn(testElement, ClassAttributeAnnotation.class), Matchers.nullValue()); + // shouldn't find nonexisting + MatcherAssert.assertThat(AnnotationUtils.getClassAttributeFromAnnotationAsFqn(testElement, ClassAttributeAnnotation.class), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -78,26 +81,27 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_classAttribute_StringClassValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classAttribute_atDefaultValue") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classAttribute_atDefaultValue") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(AnnotationUtils.getClassAttributeFromAnnotationAsFqn(testElement, ClassAttributeAnnotation.class), Matchers.equalTo(String.class.getCanonicalName())); + // shouldn't find nonexisting + MatcherAssert.assertThat(AnnotationUtils.getClassAttributeFromAnnotationAsFqn(testElement, ClassAttributeAnnotation.class), Matchers.equalTo(String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -106,26 +110,27 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_classAttributeWithExplicitAttributeName_LongClassValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classAttribute_atNamedAttribute") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classAttribute_atNamedAttribute") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(AnnotationUtils.getClassAttributeFromAnnotationAsFqn(testElement, ClassAttributeAnnotation.class, "classAttribute"), Matchers.equalTo(Long.class.getCanonicalName())); + // shouldn't find nonexisting + MatcherAssert.assertThat(AnnotationUtils.getClassAttributeFromAnnotationAsFqn(testElement, ClassAttributeAnnotation.class, "classAttribute"), Matchers.equalTo(Long.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -138,26 +143,27 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_arrayClassAttribute_emptyValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_empty") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_empty") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class), Matchers.arrayWithSize(0)); + // shouldn't find nonexisting + MatcherAssert.assertThat(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class), Matchers.arrayWithSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -165,26 +171,27 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_arrayClassAttribute_StringDoubleFloatValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_atDefaultValue") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_atDefaultValue") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(Arrays.asList(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class)), Matchers.contains(String.class.getCanonicalName(), Double.class.getCanonicalName(), Float.class.getCanonicalName())); + // shouldn't find nonexisting + MatcherAssert.assertThat(Arrays.asList(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class)), Matchers.contains(String.class.getCanonicalName(), Double.class.getCanonicalName(), Float.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -193,26 +200,27 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_arrayClassAttributeWithExplicitAttributeName_LongIntegerValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_atNamedAttribute") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_atNamedAttribute") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(Arrays.asList(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class, "classArrayAttribute")), Matchers.contains(Long.class.getCanonicalName(), Integer.class.getCanonicalName())); + // shouldn't find nonexisting + MatcherAssert.assertThat(Arrays.asList(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class, "classArrayAttribute")), Matchers.contains(Long.class.getCanonicalName(), Integer.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -220,26 +228,27 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_arrayClassAttributeWithExplicitAttributeName_LongIntegerAnnotationClassAttributeTestClassValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(ClassArrayAttributeAnnotation.class) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); - Element testElement = FluentElementFilter.createFluentElementFilter(result) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_atNamedAttribute_withUncompiledClass") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter(result) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("test_classArrayAttribute_atNamedAttribute_withUncompiledClass") + .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat(Arrays.asList(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class, "classArrayAttribute")), Matchers.contains(Long.class.getCanonicalName(), Integer.class.getCanonicalName(), "io.toolisticon.annotationprocessor.AnnotationClassAttributeTestClass")); + // shouldn't find nonexisting + MatcherAssert.assertThat(Arrays.asList(AnnotationUtils.getClassArrayAttributeFromAnnotationAsFqn(testElement, ClassArrayAttributeAnnotation.class, "classArrayAttribute")), Matchers.contains(Long.class.getCanonicalName(), Integer.class.getCanonicalName(), "io.toolisticon.annotationprocessor.AnnotationClassAttributeTestClass")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -253,22 +262,23 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_getAnnotationValueOfAttribute_getImplicitlySetAnnotationValueMustReturnNull() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); - MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); + // precondition + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); + MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); - // test - AnnotationValue value = AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror); + // test + AnnotationValue value = AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror); - // shouldn't find nonexisting - MatcherAssert.assertThat(value, Matchers.nullValue()); + // shouldn't find nonexisting + MatcherAssert.assertThat(value, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -281,22 +291,23 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_getAnnotationValueOfAttributeWithDefaults_getImplicitlySetAnnotationValue_defaultValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); - MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); + // precondition + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); + MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); - // test - AnnotationValue value = AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(annotationMirror); + // test + AnnotationValue value = AnnotationUtils.getAnnotationValueOfAttributeWithDefaults(annotationMirror); - // shouldn't find nonexisting - MatcherAssert.assertThat((Long) value.getValue(), Matchers.is(5L)); + // shouldn't find nonexisting + MatcherAssert.assertThat((Long) value.getValue(), Matchers.is(5L)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -308,21 +319,22 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_getMandatoryAttributeValueNames_getMandatoryAttributeValueNames() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); - MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); + // precondition + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); + MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); - String[] names = AnnotationUtils.getMandatoryAttributeValueNames(annotationMirror); + String[] names = AnnotationUtils.getMandatoryAttributeValueNames(annotationMirror); - // shouldn't find nonexisting - MatcherAssert.assertThat(Arrays.asList(names), Matchers.contains("mandatoryValue")); + // shouldn't find nonexisting + MatcherAssert.assertThat(Arrays.asList(names), Matchers.contains("mandatoryValue")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -335,22 +347,23 @@ protected void testCase(TypeElement element) { @Test public void annotationUtilsTest_getOptionalAttributeValueNames_getOptionalAttributeValueNames() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); - MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); + // precondition + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); + MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); - // test - String[] names = AnnotationUtils.getOptionalAttributeValueNames(annotationMirror); + // test + String[] names = AnnotationUtils.getOptionalAttributeValueNames(annotationMirror); - // shouldn't find nonexisting - MatcherAssert.assertThat(Arrays.asList(names), Matchers.contains("value")); + // shouldn't find nonexisting + MatcherAssert.assertThat(Arrays.asList(names), Matchers.contains("value")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -362,22 +375,23 @@ protected void testCase(TypeElement element) { @Test public void getElementForAnnotationMirror_getElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); - MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); + // precondition + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, DefaultValueAnnotation.class); + MatcherAssert.assertThat(annotationMirror, Matchers.notNullValue()); - // test - TypeElement result = (TypeElement) AnnotationUtils.getElementForAnnotationMirror(annotationMirror); + // test + TypeElement result = (TypeElement) AnnotationUtils.getElementForAnnotationMirror(annotationMirror); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat(result.toString(), Matchers.is(DefaultValueAnnotation.class.getCanonicalName())); + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat(result.toString(), Matchers.is(DefaultValueAnnotation.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -402,28 +416,29 @@ static class ClassAttributeTestcase_NonClassAttribute { @Test public void getClassAttributeFromAnnotationAsTypeMirror_shouldGetClassAttributeSuccefully() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); - MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); + // precondition + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); + MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); - // test - for value - TypeMirror result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, ClassAttributeAnnotation.class); + // test - for value + TypeMirror result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, ClassAttributeAnnotation.class); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat("Type must match String : ", TypeUtils.TypeComparison.isTypeEqual(result, String.class)); + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat("Type must match String : ", TypeUtils.TypeComparison.isTypeEqual(result, String.class)); - // test - for value - result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, ClassAttributeAnnotation.class, "classAttribute"); + // test - for value + result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, ClassAttributeAnnotation.class, "classAttribute"); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat("Type must match Long : ", TypeUtils.TypeComparison.isTypeEqual(result, Long.class)); + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat("Type must match Long : ", TypeUtils.TypeComparison.isTypeEqual(result, Long.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -431,33 +446,34 @@ protected void testCase(TypeElement element) { @Test public void getClassAttributeFromAnnotationAsTypeMirror_shouldReturnNullForNonMatchingClassAttributes() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); - MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); + // precondition + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); + MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); - // test - no class based attribute - TypeMirror result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, DefaultValueAnnotation.class); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - no class based attribute + TypeMirror result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, DefaultValueAnnotation.class); + MatcherAssert.assertThat(result, Matchers.nullValue()); - // test - no class based attribute - result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, DefaultValueAnnotation.class, "mandatoryValue"); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - no class based attribute + result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, DefaultValueAnnotation.class, "mandatoryValue"); + MatcherAssert.assertThat(result, Matchers.nullValue()); - // test - annotation not found - result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, ClassArrayAttributeAnnotation.class); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - annotation not found + result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, ClassArrayAttributeAnnotation.class); + MatcherAssert.assertThat(result, Matchers.nullValue()); - // test - annotation doesn't take attributes - result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, NoAttributeAnnotation.class); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - annotation doesn't take attributes + result = AnnotationUtils.getClassAttributeFromAnnotationAsTypeMirror(typeElement, NoAttributeAnnotation.class); + MatcherAssert.assertThat(result, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -466,39 +482,40 @@ protected void testCase(TypeElement element) { @Test public void getClassAttributeFromAnnotationAsFqn_shouldGetClassAttributeSuccefully() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); - MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); + // precondition + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); + MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); - // test - for value - String result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, ClassAttributeAnnotation.class); + // test - for value + String result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, ClassAttributeAnnotation.class); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat("Type must match String : ", String.class.getCanonicalName().equals(result)); + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat("Type must match String : ", String.class.getCanonicalName().equals(result)); - // test - for value - result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, ClassAttributeAnnotation.class, "classAttribute"); + // test - for value + result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, ClassAttributeAnnotation.class, "classAttribute"); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat("Type must match Long : ", Long.class.getCanonicalName().equals(result)); + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat("Type must match Long : ", Long.class.getCanonicalName().equals(result)); - // test - for value - result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(AnnotationUtils.getAnnotationMirror(typeElement, ClassAttributeAnnotation.class)); + // test - for value + result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(AnnotationUtils.getAnnotationMirror(typeElement, ClassAttributeAnnotation.class)); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat("Type must match String : ", String.class.getCanonicalName().equals(result)); + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat("Type must match String : ", String.class.getCanonicalName().equals(result)); - // test - for value - result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(AnnotationUtils.getAnnotationMirror(typeElement, ClassAttributeAnnotation.class), "classAttribute"); + // test - for value + result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(AnnotationUtils.getAnnotationMirror(typeElement, ClassAttributeAnnotation.class), "classAttribute"); - MatcherAssert.assertThat(result, Matchers.notNullValue()); - MatcherAssert.assertThat("Type must match Long : ", Long.class.getCanonicalName().equals(result)); - } - }) + MatcherAssert.assertThat(result, Matchers.notNullValue()); + MatcherAssert.assertThat("Type must match Long : ", Long.class.getCanonicalName().equals(result)); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -506,33 +523,34 @@ protected void testCase(TypeElement element) { @Test public void getClassAttributeFromAnnotationAsFqn_shouldReturnNullForNonMatchingClassAttributes() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // precondition - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); - MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); + // precondition + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ClassAttributeTestcase_WithCorrectClassAttribute.class); + MatcherAssert.assertThat("PRECONDITION : TypeElement must exist", typeElement, Matchers.notNullValue()); - // test - no class based attribute - String result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, DefaultValueAnnotation.class); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - no class based attribute + String result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, DefaultValueAnnotation.class); + MatcherAssert.assertThat(result, Matchers.nullValue()); - // test - no class based attribute - result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, DefaultValueAnnotation.class, "mandatoryValue"); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - no class based attribute + result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, DefaultValueAnnotation.class, "mandatoryValue"); + MatcherAssert.assertThat(result, Matchers.nullValue()); - // test - annotation not found - result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, ClassArrayAttributeAnnotation.class); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - annotation not found + result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, ClassArrayAttributeAnnotation.class); + MatcherAssert.assertThat(result, Matchers.nullValue()); - // test - annotation doesn't take attributes - result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, NoAttributeAnnotation.class); - MatcherAssert.assertThat(result, Matchers.nullValue()); + // test - annotation doesn't take attributes + result = AnnotationUtils.getClassAttributeFromAnnotationAsFqn(typeElement, NoAttributeAnnotation.class); + MatcherAssert.assertThat(result, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -541,23 +559,24 @@ protected void testCase(TypeElement element) { // -- isRepeatableAnnotation // -------------------------------------------- - public @interface NotRepeatable{ + public @interface NotRepeatable { } @Test public void isRepeatableAnnotation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for Repeatable annotation", AnnotationUtils.isRepeatableAnnotation(IsRepeatable.class)); - MatcherAssert.assertThat("Should return false for non Repeatable annotation", !AnnotationUtils.isRepeatableAnnotation(NotRepeatable.class)); - MatcherAssert.assertThat("Should return false for null value", !AnnotationUtils.isRepeatableAnnotation(null)); + MatcherAssert.assertThat("Should return true for Repeatable annotation", AnnotationUtils.isRepeatableAnnotation(IsRepeatable.class)); + MatcherAssert.assertThat("Should return false for non Repeatable annotation", !AnnotationUtils.isRepeatableAnnotation(NotRepeatable.class)); + MatcherAssert.assertThat("Should return false for null value", !AnnotationUtils.isRepeatableAnnotation(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -570,16 +589,17 @@ protected void testCase(TypeElement element) { @Test public void getRepeatableAnnotationWrapperClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(AnnotationUtils.getRepeatableAnnotationWrapperClass(IsRepeatable.class).get(), Matchers.is(IsRepeatableWrapper.class)); - MatcherAssert.assertThat("Should return empty Optional for non Repeatable annotation", !AnnotationUtils.getRepeatableAnnotationWrapperClass(NotRepeatable.class).isPresent()); - MatcherAssert.assertThat("Should return empty Optional for null value", !AnnotationUtils.getRepeatableAnnotationWrapperClass(null).isPresent()); + MatcherAssert.assertThat(AnnotationUtils.getRepeatableAnnotationWrapperClass(IsRepeatable.class).get(), Matchers.is(IsRepeatableWrapper.class)); + MatcherAssert.assertThat("Should return empty Optional for non Repeatable annotation", !AnnotationUtils.getRepeatableAnnotationWrapperClass(NotRepeatable.class).isPresent()); + MatcherAssert.assertThat("Should return empty Optional for null value", !AnnotationUtils.getRepeatableAnnotationWrapperClass(null).isPresent()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -589,26 +609,27 @@ protected void testCase(TypeElement element) { // -------------------------------------------- - @IsRepeatable("A") @IsRepeatable("B") - static class CompilerMessageAnchor{ + static class CompilerMessageAnchor { } @Test public void getRepeatableAnnotation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(CompilerMessageAnchor.class); - MatcherAssert.assertThat(AnnotationUtils.getRepeatableAnnotation(typeElement,IsRepeatable.class).get().stream().map(e -> AnnotationMirrorWrapper.wrap(e).getAttributeWithDefault().getStringValue()).collect(Collectors.toList()), Matchers.containsInAnyOrder("A", "B")); - //MatcherAssert.assertThat("Should return empty Optional for non Repeatable annotation", !AnnotationUtils.getRepeatableAnnotationWrapperClass(NotRepeatable.class).isPresent()); - //MatcherAssert.assertThat("Should return empty Optional for null value", !AnnotationUtils.getRepeatableAnnotationWrapperClass(null).isPresent()); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(CompilerMessageAnchor.class); + MatcherAssert.assertThat(AnnotationUtils.getRepeatableAnnotation(typeElement, IsRepeatable.class).get().stream().map(e -> AnnotationMirrorWrapper.wrap(e).getAttributeWithDefault().getStringValue()).collect(Collectors.toList()), Matchers.containsInAnyOrder("A", "B")); + //MatcherAssert.assertThat("Should return empty Optional for non Repeatable annotation", !AnnotationUtils.getRepeatableAnnotationWrapperClass(NotRepeatable.class).isPresent()); + //MatcherAssert.assertThat("Should return empty Optional for null value", !AnnotationUtils.getRepeatableAnnotationWrapperClass(null).isPresent()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationValueUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationValueUtilsTest.java index a25079ad..03dccf0b 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationValueUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/AnnotationValueUtilsTest.java @@ -1,13 +1,16 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.annotationvalueutilstestclasses.AnnotationValueTestAnnotation; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.TypeElement; @@ -25,7 +28,7 @@ */ public class AnnotationValueUtilsTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationValueUtilsTestClass.java")); @@ -42,36 +45,37 @@ public void init() { @Test public void annotationValueUtils_test_isLong() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isLong(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -79,36 +83,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isInteger() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isInteger(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -116,36 +122,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isFloat() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloat(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -153,36 +161,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isDouble() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDouble(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -190,36 +200,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isBoolean() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBoolean(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -227,36 +239,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isString() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isString(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -264,36 +278,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isChar() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isChar(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -301,35 +317,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isEnum() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnum(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -337,35 +355,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClass(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -373,35 +393,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isAnnotation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotation(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -409,36 +431,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isArray() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); - - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(true)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.is(false)); + + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(true)); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -451,36 +475,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getLongValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(1L)); - - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.is(1L)); + + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getLongValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -489,36 +515,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getIntegerValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(1)); - - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.is(1)); + + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -526,35 +554,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getFloatValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(1.0f)); - - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.is(1.0f)); + + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -562,35 +592,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getDoubleValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(1.0)); - - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.is(1.0)); + + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -598,35 +630,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getBooleanValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -634,36 +668,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getStringValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is("stringValue")); - - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.is("stringValue")); + + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -671,35 +707,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getCharValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is('C')); - - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.is('C')); + + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -707,36 +745,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getEnumValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")).getSimpleName().toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); - - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")).getSimpleName().toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); + + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -744,36 +784,38 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getClassValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")).getSimpleName().toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); - - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")).getSimpleName().toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); + + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -781,35 +823,37 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getAnnotationValueOfAttribute() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")).toString(), Matchers.is("@" + Deprecated.class.getCanonicalName())); - - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")).toString(), Matchers.is("@" + Deprecated.class.getCanonicalName())); + + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.nullValue()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -818,51 +862,53 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getArrayValue_and_convertAndCastAttributeValueListToArray() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - // via convertAndCastAttributeValueListToArray - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Long.class)), Matchers.contains(1L, 2L, 3L)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Integer.class)), Matchers.contains(1, 2, 3)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Boolean.class)), Matchers.contains(true, false)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Float.class)), Matchers.contains(1.0f, 2.0f, 3.0f)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Double.class)), Matchers.contains(1.0, 2.0, 3.0)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), String.class)), Matchers.contains("1", "2")); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Character.class)), Matchers.contains('1', '2')); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classValue")), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationValue")), Matchers.nullValue()); + // via convertAndCastAttributeValueListToArray + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Long.class)), Matchers.contains(1L, 2L, 3L)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Integer.class)), Matchers.contains(1, 2, 3)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Boolean.class)), Matchers.contains(true, false)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Float.class)), Matchers.contains(1.0f, 2.0f, 3.0f)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Double.class)), Matchers.contains(1.0, 2.0, 3.0)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), String.class)), Matchers.contains("1", "2")); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Character.class)), Matchers.contains('1', '2')); - TypeMirror[] typeMirrors = AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), TypeMirror.class); - MatcherAssert.assertThat(typeMirrors.length, Matchers.is(2)); - MatcherAssert.assertThat(typeMirrors[0].toString(), Matchers.is(Long.class.getCanonicalName())); - MatcherAssert.assertThat(typeMirrors[1].toString(), Matchers.is(Integer.class.getCanonicalName())); + TypeMirror[] typeMirrors = AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), TypeMirror.class); + MatcherAssert.assertThat(typeMirrors.length, Matchers.is(2)); + MatcherAssert.assertThat(typeMirrors[0].toString(), Matchers.is(Long.class.getCanonicalName())); + MatcherAssert.assertThat(typeMirrors[1].toString(), Matchers.is(Integer.class.getCanonicalName())); - VariableElement[] enums = AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), VariableElement.class); - MatcherAssert.assertThat(enums.length, Matchers.is(2)); - MatcherAssert.assertThat(enums[0].toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); - MatcherAssert.assertThat(enums[1].toString(), Matchers.is(StandardLocation.CLASS_OUTPUT.name())); + VariableElement[] enums = AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), VariableElement.class); + MatcherAssert.assertThat(enums.length, Matchers.is(2)); + MatcherAssert.assertThat(enums[0].toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); + MatcherAssert.assertThat(enums[1].toString(), Matchers.is(StandardLocation.CLASS_OUTPUT.name())); - AnnotationMirror[] annotationMirrors = AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), AnnotationMirror.class); - MatcherAssert.assertThat(annotationMirrors.length, Matchers.is(1)); - MatcherAssert.assertThat(annotationMirrors[0].toString(), Matchers.is("@" + Deprecated.class.getCanonicalName())); + AnnotationMirror[] annotationMirrors = AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), AnnotationMirror.class); + MatcherAssert.assertThat(annotationMirrors.length, Matchers.is(1)); + MatcherAssert.assertThat(annotationMirrors[0].toString(), Matchers.is("@" + Deprecated.class.getCanonicalName())); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -870,24 +916,26 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_convertAndCastAttributeValueListToArray_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - MatcherAssert.assertThat(AnnotationValueUtils.convertAndCastAttributeValueListToArray(null, String.class), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.convertAndCastAttributeValueListToArray(null, String.class), Matchers.nullValue()); - boolean exceptionThrown = false; - try { - MatcherAssert.assertThat(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), null), Matchers.nullValue()); - } catch (IllegalArgumentException e) { - exceptionThrown = true; - } - MatcherAssert.assertThat("Expected that IllegalArgumentException is thrown if passed type is null", exceptionThrown); + boolean exceptionThrown = false; + try { + MatcherAssert.assertThat(AnnotationValueUtils.convertAndCastAttributeValueListToArray(AnnotationValueUtils.getArrayValue(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), null), Matchers.nullValue()); + } catch (IllegalArgumentException e) { + exceptionThrown = true; + } + MatcherAssert.assertThat("Expected that IllegalArgumentException is thrown if passed type is null", exceptionThrown); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -895,39 +943,40 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getArrayValue_viaConvenienceMode() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - // via convenience methods - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getLongValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue"))), Matchers.contains(1L, 2L, 3L)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getIntegerValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue"))), Matchers.contains(1, 2, 3)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getBooleanValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue"))), Matchers.contains(true, false)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getFloatValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue"))), Matchers.contains(1.0f, 2.0f, 3.0f)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getDoubleValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue"))), Matchers.contains(1.0, 2.0, 3.0)); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getStringValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue"))), Matchers.contains("1", "2")); - MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getCharValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue"))), Matchers.contains('1', '2')); + // via convenience methods + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getLongValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue"))), Matchers.contains(1L, 2L, 3L)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getIntegerValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue"))), Matchers.contains(1, 2, 3)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getBooleanValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue"))), Matchers.contains(true, false)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getFloatValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue"))), Matchers.contains(1.0f, 2.0f, 3.0f)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getDoubleValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue"))), Matchers.contains(1.0, 2.0, 3.0)); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getStringValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue"))), Matchers.contains("1", "2")); + MatcherAssert.assertThat(Arrays.asList(AnnotationValueUtils.getCharValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue"))), Matchers.contains('1', '2')); - TypeMirror[] typeMirrors = AnnotationValueUtils.getTypeAttributeValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")); - MatcherAssert.assertThat(typeMirrors.length, Matchers.is(2)); - MatcherAssert.assertThat(typeMirrors[0].toString(), Matchers.is(Long.class.getCanonicalName())); - MatcherAssert.assertThat(typeMirrors[1].toString(), Matchers.is(Integer.class.getCanonicalName())); + TypeMirror[] typeMirrors = AnnotationValueUtils.getTypeAttributeValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")); + MatcherAssert.assertThat(typeMirrors.length, Matchers.is(2)); + MatcherAssert.assertThat(typeMirrors[0].toString(), Matchers.is(Long.class.getCanonicalName())); + MatcherAssert.assertThat(typeMirrors[1].toString(), Matchers.is(Integer.class.getCanonicalName())); - VariableElement[] enums = AnnotationValueUtils.getEnumValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")); - MatcherAssert.assertThat(enums.length, Matchers.is(2)); - MatcherAssert.assertThat(enums[0].toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); - MatcherAssert.assertThat(enums[1].toString(), Matchers.is(StandardLocation.CLASS_OUTPUT.name())); + VariableElement[] enums = AnnotationValueUtils.getEnumValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")); + MatcherAssert.assertThat(enums.length, Matchers.is(2)); + MatcherAssert.assertThat(enums[0].toString(), Matchers.is(StandardLocation.SOURCE_OUTPUT.name())); + MatcherAssert.assertThat(enums[1].toString(), Matchers.is(StandardLocation.CLASS_OUTPUT.name())); - AnnotationMirror[] annotationMirrors = AnnotationValueUtils.getAnnotationValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")); - MatcherAssert.assertThat(annotationMirrors.length, Matchers.is(1)); - MatcherAssert.assertThat(annotationMirrors[0].toString(), Matchers.is("@" + Deprecated.class.getCanonicalName())); + AnnotationMirror[] annotationMirrors = AnnotationValueUtils.getAnnotationValueArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")); + MatcherAssert.assertThat(annotationMirrors.length, Matchers.is(1)); + MatcherAssert.assertThat(annotationMirrors[0].toString(), Matchers.is("@" + Deprecated.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -935,34 +984,36 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_getArrayValue_viaConvenienceMode_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // test null safety - MatcherAssert.assertThat(AnnotationValueUtils.getLongValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValueArray((List) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValueArray((List) null), Matchers.nullValue()); - - - MatcherAssert.assertThat(AnnotationValueUtils.getLongValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getFloatValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getStringValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getCharValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getEnumValueArray((AnnotationValue) null), Matchers.nullValue()); - MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue((AnnotationValue) null), Matchers.nullValue()); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + // test null safety + MatcherAssert.assertThat(AnnotationValueUtils.getLongValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValueArray((List) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValueArray((List) null), Matchers.nullValue()); + + + MatcherAssert.assertThat(AnnotationValueUtils.getLongValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getIntegerValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getBooleanValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getFloatValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getDoubleValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getStringValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getCharValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getEnumValueArray((AnnotationValue) null), Matchers.nullValue()); + MatcherAssert.assertThat(AnnotationValueUtils.getAnnotationValue((AnnotationValue) null), Matchers.nullValue()); + + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -970,48 +1021,50 @@ protected void testCase(TypeElement element) { @Test public void annotationValueUtils_test_isXXXAray() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); - - MatcherAssert.assertThat(AnnotationValueUtils.isLongArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isIntegerArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isBooleanArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloatArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isDoubleArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isStringArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isCharArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnumArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isClassArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(true)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(true)); - - MatcherAssert.assertThat(AnnotationValueUtils.isLongArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isIntegerArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBooleanArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloatArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDoubleArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isStringArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isCharArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnumArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClassArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); - - - MatcherAssert.assertThat(AnnotationValueUtils.isLongArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isIntegerArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isBooleanArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isFloatArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isDoubleArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isStringArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isCharArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isEnumArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isClassArray(null), Matchers.is(false)); - MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(null), Matchers.is(false)); - - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(element, AnnotationValueTestAnnotation.class); + + MatcherAssert.assertThat(AnnotationValueUtils.isLongArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "longArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isIntegerArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isBooleanArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloatArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isDoubleArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isStringArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isCharArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnumArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isClassArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(true)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(true)); + + MatcherAssert.assertThat(AnnotationValueUtils.isLongArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "intArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isIntegerArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "booleanArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBooleanArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloatArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "doubleArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDoubleArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "stringArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isStringArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "charArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isCharArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "enumArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnumArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "classArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClassArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "annotationArrayValue")), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(AnnotationUtils.getAnnotationValueOfAttribute(annotationMirror, "floatArrayValue")), Matchers.is(false)); + + + MatcherAssert.assertThat(AnnotationValueUtils.isLongArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isIntegerArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isBooleanArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isFloatArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isDoubleArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isStringArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isCharArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isEnumArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isClassArray(null), Matchers.is(false)); + MatcherAssert.assertThat(AnnotationValueUtils.isAnnotationArray(null), Matchers.is(false)); + + + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/BeanUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/BeanUtilsTest.java index 1e2b98b1..e5300485 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/BeanUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/BeanUtilsTest.java @@ -1,15 +1,18 @@ package io.toolisticon.aptk.tools; import com.sun.source.tree.StatementTree; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -23,7 +26,7 @@ */ public class BeanUtilsTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationValueUtilsTestClass.java")); @@ -36,13 +39,15 @@ public void init() { @Test public void getPossibleGetterOrSetterNames_getter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - MatcherAssert.assertThat(Arrays.asList(BeanUtils.getPrefixedName("get", "testField")), Matchers.contains("getTestField")); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - } - }) + MatcherAssert.assertThat(Arrays.asList(BeanUtils.getPrefixedName("get", "testField")), Matchers.contains("getTestField")); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -56,19 +61,21 @@ protected void testCase(TypeElement element) { public void fieldWithImplementedGetterAndSetters_checkHasGetter() { unitTestBuilder.useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithImplementedGetterAndSetters") - .getResult().get(0); - - - // shouldn't find nonexisting - MatcherAssert.assertThat("Should detect getter ", BeanUtils.checkHasGetter(field)); - } - }) + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithImplementedGetterAndSetters") + .getResult().get(0); + + + // shouldn't find nonexisting + MatcherAssert.assertThat("Should detect getter ", BeanUtils.checkHasGetter(field)); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -78,44 +85,45 @@ protected void testCase(TypeElement element) { public void fieldWithImplementedGetterAndSetters_checkHasSetter() { unitTestBuilder.useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithImplementedGetterAndSetters") - .getResult().get(0); - - - // shouldn't find nonexisting - MatcherAssert.assertThat("Should detect setter ", BeanUtils.checkHasSetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithImplementedGetterAndSetters") + .getResult().get(0); + // shouldn't find nonexisting + MatcherAssert.assertThat("Should detect setter ", BeanUtils.checkHasSetter(field)); + } + }) + .compilationShouldSucceed() + .executeTest(); + } @Test public void fieldWithoutGetter_checkHasGetter() { unitTestBuilder.useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutGetter") - .getResult().get(0); - - - // shouldn't find nonexisting - MatcherAssert.assertThat("Should not detect getter ", !BeanUtils.checkHasGetter(field)); - } - }) + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutGetter") + .getResult().get(0); + + + // shouldn't find nonexisting + MatcherAssert.assertThat("Should not detect getter ", !BeanUtils.checkHasGetter(field)); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -124,24 +132,23 @@ protected void testCase(TypeElement element) { public void fieldWithoutSetter_checkHasSetter() { unitTestBuilder.useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutSetter") - .getResult().get(0); - - - MatcherAssert.assertThat("Should not detect setter ", !BeanUtils.checkHasSetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutSetter") + .getResult().get(0); + MatcherAssert.assertThat("Should not detect setter ", !BeanUtils.checkHasSetter(field)); + } + }) + .compilationShouldSucceed() + .executeTest(); + } // ----------------------- @@ -153,18 +160,20 @@ public void isAttribute_fieldWithBothGetterAndSetter() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithImplementedGetterAndSetters") - .getResult().get(0); - - - MatcherAssert.assertThat("Must return true for field with getter and setter", BeanUtils.isAttribute(field)); - } - }) + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithImplementedGetterAndSetters") + .getResult().get(0); + + + MatcherAssert.assertThat("Must return true for field with getter and setter", BeanUtils.isAttribute(field)); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -174,18 +183,20 @@ public void isAttribute_fieldWithoutSetter() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutGetter") - .getResult().get(0); - - - MatcherAssert.assertThat("Must return true for field without setter", !BeanUtils.isAttribute(field)); - } - }) + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutGetter") + .getResult().get(0); + + + MatcherAssert.assertThat("Must return true for field without setter", !BeanUtils.isAttribute(field)); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -195,18 +206,20 @@ public void isAttribute_fieldWithoutGetter() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/FieldLevelTestcases.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutSetter") - .getResult().get(0); - - - MatcherAssert.assertThat("Must return true for field without getter", !BeanUtils.isAttribute(field)); - } - }) + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + VariableElement field = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("fieldWithoutSetter") + .getResult().get(0); + + + MatcherAssert.assertThat("Must return true for field without getter", !BeanUtils.isAttribute(field)); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -221,26 +234,28 @@ public void getAttributes_withTypeHierarchy1() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/TypeHierarchyTestClass.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CLASS) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*InheritingType") - .getResult().get(0); + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CLASS) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*InheritingType") + .getResult().get(0); - BeanUtils.AttributeResult[] results = BeanUtils.getAttributes(typeElement); + BeanUtils.AttributeResult[] results = BeanUtils.getAttributes(typeElement); - Set attributeNames = new HashSet(); + Set attributeNames = new HashSet(); - for (BeanUtils.AttributeResult result : results) { - attributeNames.add(result.getFieldName()); - } + for (BeanUtils.AttributeResult result : results) { + attributeNames.add(result.getFieldName()); + } - MatcherAssert.assertThat(attributeNames, Matchers.contains("booleanField", "stringField")); - } - }) + MatcherAssert.assertThat(attributeNames, Matchers.contains("booleanField", "stringField")); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -250,27 +265,29 @@ public void getAttributes_withTypeHierarchy2() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/TypeHierarchyTestClass.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CLASS) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*InheritingType") - .getResult().get(0); + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CLASS) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*InheritingType") + .getResult().get(0); - BeanUtils.AttributeResult[] results = BeanUtils.getAttributesWithInheritance(typeElement); - Set attributeNames = new HashSet(); + BeanUtils.AttributeResult[] results = BeanUtils.getAttributesWithInheritance(typeElement); - for (BeanUtils.AttributeResult result : results) { - attributeNames.add(result.getFieldName()); - } + Set attributeNames = new HashSet(); - MatcherAssert.assertThat(attributeNames, Matchers.containsInAnyOrder("booleanField", "stringField", "superBooleanField", "superStringField")); + for (BeanUtils.AttributeResult result : results) { + attributeNames.add(result.getFieldName()); + } - } - }) + MatcherAssert.assertThat(attributeNames, Matchers.containsInAnyOrder("booleanField", "stringField", "superBooleanField", "superStringField")); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -285,19 +302,21 @@ public void isDefaultNoargConstructor_defaultNoargConstructor() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/DefaultNoargConstructorTest.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - ExecutableElement constructor = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CONSTRUCTOR) - .getResult().get(0); + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + ExecutableElement constructor = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CONSTRUCTOR) + .getResult().get(0); - MatcherAssert.assertThat("Should return true for default constructor", BeanUtils.isDefaultNoargConstructor(constructor)); - MatcherAssert.assertThat("Should return true for default constructor", BeanUtils.hasDefaultNoargsConstructor(element)); + MatcherAssert.assertThat("Should return true for default constructor", BeanUtils.isDefaultNoargConstructor(constructor)); + MatcherAssert.assertThat("Should return true for default constructor", BeanUtils.hasDefaultNoargsConstructor(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -307,19 +326,21 @@ public void isDefaultNoargConstructor_explicitNoargConstructor() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/ExplicitNoargConstructorTest.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - ExecutableElement constructor = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CONSTRUCTOR) - .getResult().get(0); + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + ExecutableElement constructor = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CONSTRUCTOR) + .getResult().get(0); - MatcherAssert.assertThat("Should return false for explicit constructor", !BeanUtils.isDefaultNoargConstructor(constructor)); - MatcherAssert.assertThat("Should return false for explicit constructor", !BeanUtils.hasDefaultNoargsConstructor(element)); - } - }) + MatcherAssert.assertThat("Should return false for explicit constructor", !BeanUtils.isDefaultNoargConstructor(constructor)); + MatcherAssert.assertThat("Should return false for explicit constructor", !BeanUtils.hasDefaultNoargsConstructor(element)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -329,21 +350,23 @@ public void isDefaultNoargConstructor_explicitNoargConstructor2() { unitTestBuilder .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/ExplicitNoargConstructorTest2.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - ExecutableElement constructor = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CONSTRUCTOR) - .getResult().get(0); + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + ExecutableElement constructor = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CONSTRUCTOR) + .getResult().get(0); - List statements = ProcessingEnvironmentUtils.getTrees().getTree(constructor).getBody().getStatements(); + List statements = ProcessingEnvironmentUtils.getTrees().getTree(constructor).getBody().getStatements(); - MatcherAssert.assertThat("Should return true for explicit constructor that looks like default constructor", BeanUtils.isDefaultNoargConstructor(constructor)); - MatcherAssert.assertThat("Should return true for explicit constructor that looks like default constructor", BeanUtils.hasDefaultNoargsConstructor(element)); + MatcherAssert.assertThat("Should return true for explicit constructor that looks like default constructor", BeanUtils.isDefaultNoargConstructor(constructor)); + MatcherAssert.assertThat("Should return true for explicit constructor that looks like default constructor", BeanUtils.hasDefaultNoargsConstructor(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtilsTest.java index 2029ed2c..8a0723b1 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtilsTest.java @@ -1,13 +1,16 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -23,7 +26,7 @@ */ public class ElementUtilsTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -36,23 +39,24 @@ public void init() { @Test public void getEnclosedElementsByName() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "privateField"); - MatcherAssert.assertThat(result, Matchers.hasSize(1)); - MatcherAssert.assertThat(result.get(0).getKind(), Matchers.is(ElementKind.FIELD)); - MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("privateField")); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "privateField"); + MatcherAssert.assertThat(result, Matchers.hasSize(1)); + MatcherAssert.assertThat(result.get(0).getKind(), Matchers.is(ElementKind.FIELD)); + MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("privateField")); - // shouldn't find nonexisting - result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "XXXXXXXX"); - MatcherAssert.assertThat(result, Matchers.empty()); + // shouldn't find nonexisting + result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "XXXXXXXX"); + MatcherAssert.assertThat(result, Matchers.empty()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -61,23 +65,24 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedElementsByNameRegex() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List results = ElementUtils.AccessEnclosedElements.getEnclosedElementsByNameRegex(element, ".*ublic.*"); - MatcherAssert.assertThat(results, Matchers.hasSize(4)); - for (Element result : results) { - MatcherAssert.assertThat(result.getKind(), Matchers.is(ElementKind.FIELD)); - MatcherAssert.assertThat(result.getSimpleName().toString(), Matchers.startsWith("public")); - } + List results = ElementUtils.AccessEnclosedElements.getEnclosedElementsByNameRegex(element, ".*ublic.*"); + MatcherAssert.assertThat(results, Matchers.hasSize(4)); + for (Element result : results) { + MatcherAssert.assertThat(result.getKind(), Matchers.is(ElementKind.FIELD)); + MatcherAssert.assertThat(result.getSimpleName().toString(), Matchers.startsWith("public")); + } - // shouldn't find nonexisting - results = ElementUtils.AccessEnclosedElements.getEnclosedElementsByNameRegex(element, "XXXXXXXX"); - MatcherAssert.assertThat(results, Matchers.empty()); + // shouldn't find nonexisting + results = ElementUtils.AccessEnclosedElements.getEnclosedElementsByNameRegex(element, "XXXXXXXX"); + MatcherAssert.assertThat(results, Matchers.empty()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -85,16 +90,17 @@ protected void testCase(TypeElement element) { @Test public void hasModifiers() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should have public modifier", AptkCoreMatchers.BY_MODIFIER.getValidator().hasAllOf(element, Modifier.PUBLIC)); - MatcherAssert.assertThat("Class should not have abstract modifier", !AptkCoreMatchers.BY_MODIFIER.getValidator().hasAllOf(element, Modifier.PUBLIC, Modifier.ABSTRACT)); + MatcherAssert.assertThat("Class should have public modifier", AptkCoreMatchers.BY_MODIFIER.getValidator().hasAllOf(element, Modifier.PUBLIC)); + MatcherAssert.assertThat("Class should not have abstract modifier", !AptkCoreMatchers.BY_MODIFIER.getValidator().hasAllOf(element, Modifier.PUBLIC, Modifier.ABSTRACT)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -102,19 +108,20 @@ protected void testCase(TypeElement element) { @Test public void hasPublicModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have public modifier", ElementUtils.CheckModifierOfElement.hasPublicModifier(element)); + MatcherAssert.assertThat("Class should be detected to have public modifier", ElementUtils.CheckModifierOfElement.hasPublicModifier(element)); - MatcherAssert.assertThat("Class should not be detected to have public modifier", !ElementUtils.CheckModifierOfElement.hasPublicModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have public modifier", !ElementUtils.CheckModifierOfElement.hasPublicModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have public modifier", !ElementUtils.CheckModifierOfElement.hasPublicModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have public modifier", !ElementUtils.CheckModifierOfElement.hasPublicModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -122,19 +129,20 @@ protected void testCase(TypeElement element) { @Test public void hasProtectedModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have protected modifier", ElementUtils.CheckModifierOfElement.hasProtectedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "protectedField").get(0))); + MatcherAssert.assertThat("Class should be detected to have protected modifier", ElementUtils.CheckModifierOfElement.hasProtectedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "protectedField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have protected modifier", !ElementUtils.CheckModifierOfElement.hasProtectedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have protected modifier", !ElementUtils.CheckModifierOfElement.hasProtectedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have protected modifier", !ElementUtils.CheckModifierOfElement.hasProtectedModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have protected modifier", !ElementUtils.CheckModifierOfElement.hasProtectedModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -142,19 +150,20 @@ protected void testCase(TypeElement element) { @Test public void hasPrivateModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have private modifier", ElementUtils.CheckModifierOfElement.hasPrivateModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should be detected to have private modifier", ElementUtils.CheckModifierOfElement.hasPrivateModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have private modifier", !ElementUtils.CheckModifierOfElement.hasPrivateModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "protectedField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have private modifier", !ElementUtils.CheckModifierOfElement.hasPrivateModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "protectedField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have private modifier", !ElementUtils.CheckModifierOfElement.hasPrivateModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have private modifier", !ElementUtils.CheckModifierOfElement.hasPrivateModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -162,22 +171,23 @@ protected void testCase(TypeElement element) { @Test public void hasAbstractModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Element abstractType = AptkCoreMatchers.BY_MODIFIER.getFilter().filterByAllOf(AptkCoreMatchers.BY_ELEMENT_KIND.getFilter().filterByOneOf(element.getEnclosedElements(), ElementKind.CLASS), Modifier.ABSTRACT).get(0); + Element abstractType = AptkCoreMatchers.BY_MODIFIER.getFilter().filterByAllOf(AptkCoreMatchers.BY_ELEMENT_KIND.getFilter().filterByOneOf(element.getEnclosedElements(), ElementKind.CLASS), Modifier.ABSTRACT).get(0); - MatcherAssert.assertThat("Class should be detected to have abstract modifier", ElementUtils.CheckModifierOfElement.hasAbstractModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(abstractType.getEnclosedElements(), "abstractMethod").get(0))) - ; + MatcherAssert.assertThat("Class should be detected to have abstract modifier", ElementUtils.CheckModifierOfElement.hasAbstractModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(abstractType.getEnclosedElements(), "abstractMethod").get(0))) + ; - MatcherAssert.assertThat("Class should not be detected to have abstract modifier", !ElementUtils.CheckModifierOfElement.hasAbstractModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have abstract modifier", !ElementUtils.CheckModifierOfElement.hasAbstractModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have abstract modifier", !ElementUtils.CheckModifierOfElement.hasAbstractModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have abstract modifier", !ElementUtils.CheckModifierOfElement.hasAbstractModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -185,19 +195,20 @@ protected void testCase(TypeElement element) { @Test public void hasStaticModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have static modifier", ElementUtils.CheckModifierOfElement.hasStaticModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "publicStaticField").get(0))); + MatcherAssert.assertThat("Class should be detected to have static modifier", ElementUtils.CheckModifierOfElement.hasStaticModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "publicStaticField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have static modifier", !ElementUtils.CheckModifierOfElement.hasStaticModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have static modifier", !ElementUtils.CheckModifierOfElement.hasStaticModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have static modifier", !ElementUtils.CheckModifierOfElement.hasStaticModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have static modifier", !ElementUtils.CheckModifierOfElement.hasStaticModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -205,19 +216,20 @@ protected void testCase(TypeElement element) { @Test public void hasFinalModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have final modifier", ElementUtils.CheckModifierOfElement.hasFinalModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "publicFinalField").get(0))); + MatcherAssert.assertThat("Class should be detected to have final modifier", ElementUtils.CheckModifierOfElement.hasFinalModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "publicFinalField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have final modifier", !ElementUtils.CheckModifierOfElement.hasFinalModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have final modifier", !ElementUtils.CheckModifierOfElement.hasFinalModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have final modifier", !ElementUtils.CheckModifierOfElement.hasFinalModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have final modifier", !ElementUtils.CheckModifierOfElement.hasFinalModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -225,19 +237,20 @@ protected void testCase(TypeElement element) { @Test public void hasTransientModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have transient modifier", ElementUtils.CheckModifierOfElement.hasTransientModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "publicTransientField").get(0))); + MatcherAssert.assertThat("Class should be detected to have transient modifier", ElementUtils.CheckModifierOfElement.hasTransientModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "publicTransientField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have transient modifier", !ElementUtils.CheckModifierOfElement.hasTransientModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have transient modifier", !ElementUtils.CheckModifierOfElement.hasTransientModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have transient modifier", !ElementUtils.CheckModifierOfElement.hasTransientModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have transient modifier", !ElementUtils.CheckModifierOfElement.hasTransientModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -245,19 +258,20 @@ protected void testCase(TypeElement element) { @Test public void hasSynchronizedModifier() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Class should be detected to have synchronized modifier", ElementUtils.CheckModifierOfElement.hasSynchronizedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "synchronizedMethod").get(0))); + MatcherAssert.assertThat("Class should be detected to have synchronized modifier", ElementUtils.CheckModifierOfElement.hasSynchronizedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "synchronizedMethod").get(0))); - MatcherAssert.assertThat("Class should not be detected to have synchronized modifier", !ElementUtils.CheckModifierOfElement.hasSynchronizedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); + MatcherAssert.assertThat("Class should not be detected to have synchronized modifier", !ElementUtils.CheckModifierOfElement.hasSynchronizedModifier(AptkCoreMatchers.BY_NAME.getFilter().filterByOneOf(element.getEnclosedElements(), "privateField").get(0))); - MatcherAssert.assertThat("Class should not be detected to have synchronized modifier", !ElementUtils.CheckModifierOfElement.hasSynchronizedModifier(null)); + MatcherAssert.assertThat("Class should not be detected to have synchronized modifier", !ElementUtils.CheckModifierOfElement.hasSynchronizedModifier(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -265,21 +279,22 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedFields() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List fields = ElementUtils.AccessEnclosedElements.getEnclosedFields(element); + List fields = ElementUtils.AccessEnclosedElements.getEnclosedFields(element); - MatcherAssert.assertThat(fields, Matchers.notNullValue()); - MatcherAssert.assertThat(fields, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(fields, Matchers.notNullValue()); + MatcherAssert.assertThat(fields, Matchers.not(Matchers.empty())); - for (VariableElement field : fields) { - MatcherAssert.assertThat(field.getKind(), Matchers.is(ElementKind.FIELD)); - } + for (VariableElement field : fields) { + MatcherAssert.assertThat(field.getKind(), Matchers.is(ElementKind.FIELD)); + } - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -287,20 +302,21 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedMethods() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List methods = ElementUtils.AccessEnclosedElements.getEnclosedMethods(element); + List methods = ElementUtils.AccessEnclosedElements.getEnclosedMethods(element); - MatcherAssert.assertThat(methods, Matchers.notNullValue()); - MatcherAssert.assertThat(methods, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(methods, Matchers.notNullValue()); + MatcherAssert.assertThat(methods, Matchers.not(Matchers.empty())); - for (ExecutableElement method : methods) { - MatcherAssert.assertThat(method.getKind(), Matchers.is(ElementKind.METHOD)); - } - } - }) + for (ExecutableElement method : methods) { + MatcherAssert.assertThat(method.getKind(), Matchers.is(ElementKind.METHOD)); + } + } + }) .compilationShouldSucceed() .executeTest(); } @@ -308,20 +324,21 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedConstructors() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List constructors = ElementUtils.AccessEnclosedElements.getEnclosedConstructors(element); + List constructors = ElementUtils.AccessEnclosedElements.getEnclosedConstructors(element); - MatcherAssert.assertThat(constructors, Matchers.notNullValue()); - MatcherAssert.assertThat(constructors, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(constructors, Matchers.notNullValue()); + MatcherAssert.assertThat(constructors, Matchers.not(Matchers.empty())); - for (ExecutableElement constructor : constructors) { - MatcherAssert.assertThat(constructor.getKind(), Matchers.is(ElementKind.CONSTRUCTOR)); - } - } - }) + for (ExecutableElement constructor : constructors) { + MatcherAssert.assertThat(constructor.getKind(), Matchers.is(ElementKind.CONSTRUCTOR)); + } + } + }) .compilationShouldSucceed() .executeTest(); } @@ -329,21 +346,22 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedTypes() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List types = ElementUtils.AccessEnclosedElements.getEnclosedTypes(element); + List types = ElementUtils.AccessEnclosedElements.getEnclosedTypes(element); - MatcherAssert.assertThat(types, Matchers.notNullValue()); - MatcherAssert.assertThat(types, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(types, Matchers.notNullValue()); + MatcherAssert.assertThat(types, Matchers.not(Matchers.empty())); - for (TypeElement type : types) { - MatcherAssert.assertThat(type.getKind(), Matchers.is(ElementKind.CLASS)); - } + for (TypeElement type : types) { + MatcherAssert.assertThat(type.getKind(), Matchers.is(ElementKind.CLASS)); + } - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -351,21 +369,22 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedElementsWithAllAnnotationsOf() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, FilterTestAnnotation1.class); + List elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, FilterTestAnnotation1.class); - MatcherAssert.assertThat(elements, Matchers.notNullValue()); - MatcherAssert.assertThat(elements, Matchers.not(Matchers.empty())); + MatcherAssert.assertThat(elements, Matchers.notNullValue()); + MatcherAssert.assertThat(elements, Matchers.not(Matchers.empty())); - for (Element element1 : elements) { - MatcherAssert.assertThat(element1.getAnnotation(FilterTestAnnotation1.class), Matchers.notNullValue()); - } + for (Element element1 : elements) { + MatcherAssert.assertThat(element1.getAnnotation(FilterTestAnnotation1.class), Matchers.notNullValue()); + } - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -373,25 +392,26 @@ protected void testCase(TypeElement element) { @Test public void getEnclosedElementsWithAllAnnotationsOf_withNullValuedElementOrAnnotation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(null, FilterTestAnnotation1.class); + List elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(null, FilterTestAnnotation1.class); - MatcherAssert.assertThat(elements, Matchers.empty()); + MatcherAssert.assertThat(elements, Matchers.empty()); - elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, null); + elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, null); - MatcherAssert.assertThat(elements, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(elements, Matchers.hasSize(element.getEnclosedElements().size())); - elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element); + elements = (List) ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element); - MatcherAssert.assertThat(elements, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(elements, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtils_AccessTypeHierarchyTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtils_AccessTypeHierarchyTest.java index 3ce76ced..d11a9485 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtils_AccessTypeHierarchyTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/ElementUtils_AccessTypeHierarchyTest.java @@ -1,12 +1,15 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import java.util.Arrays; @@ -34,7 +37,7 @@ public static class TestType extends InbetweenType { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationValueUtilsTestClass.java")); @@ -47,21 +50,22 @@ public void init() { @Test public void getDirectSuperTypeElements() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // find field - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + // find field + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); + TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); - MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElements(typeElement)), Matchers.contains( - inBetweenTypeElement)); + MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElements(typeElement)), Matchers.contains( + inBetweenTypeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -70,29 +74,30 @@ protected void testCase(TypeElement element) { @Test public void getSuperTypeElements() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // find field - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + // find field + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); - TypeElement topMostTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TopMostType.class); - TypeElement objectTypeElement = TypeUtils.TypeRetrieval.getTypeElement(Object.class); - TypeElement testInterfaceTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); + TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); + TypeElement topMostTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TopMostType.class); + TypeElement objectTypeElement = TypeUtils.TypeRetrieval.getTypeElement(Object.class); + TypeElement testInterfaceTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); - MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElements(typeElement)), Matchers.contains( - inBetweenTypeElement, - topMostTypeElement, - objectTypeElement, - testInterfaceTypeElement)); + MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElements(typeElement)), Matchers.contains( + inBetweenTypeElement, + topMostTypeElement, + objectTypeElement, + testInterfaceTypeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -100,31 +105,32 @@ protected void testCase(TypeElement element) { @Test public void getDirectSuperTypeElementsOfKindType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // Test 1 : has super type - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + // Test 1 : has super type + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); + TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); - MatcherAssert.assertThat(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementOfKindType(typeElement), Matchers.equalTo( - inBetweenTypeElement - )); + MatcherAssert.assertThat(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementOfKindType(typeElement), Matchers.equalTo( + inBetweenTypeElement + )); - // Test 2 : has no super type - typeElement = TypeUtils.TypeRetrieval.getTypeElement(Object.class); + // Test 2 : has no super type + typeElement = TypeUtils.TypeRetrieval.getTypeElement(Object.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - MatcherAssert.assertThat(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementOfKindType(typeElement), Matchers.nullValue()); + MatcherAssert.assertThat(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementOfKindType(typeElement), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -132,29 +138,30 @@ protected void testCase(TypeElement element) { @Test public void getDirectSuperTypeElementsOfKindInterface() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // Test 1: has no interface - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + // Test 1: has no interface + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementsOfKindInterface(typeElement)), Matchers.empty()); + MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementsOfKindInterface(typeElement)), Matchers.empty()); - // Test 2: has interface - typeElement = TypeUtils.TypeRetrieval.getTypeElement(TopMostType.class); + // Test 2: has interface + typeElement = TypeUtils.TypeRetrieval.getTypeElement(TopMostType.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - TypeElement testInterfaceTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); + TypeElement testInterfaceTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); - MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementsOfKindInterface(typeElement)), Matchers.contains(testInterfaceTypeElement)); + MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getDirectSuperTypeElementsOfKindInterface(typeElement)), Matchers.contains(testInterfaceTypeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -162,28 +169,30 @@ protected void testCase(TypeElement element) { @Test public void getSuperTypeElementsOfKindType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // find field - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + // find field + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); - TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); - TypeElement topMostTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TopMostType.class); - TypeElement objectTypeElement = TypeUtils.TypeRetrieval.getTypeElement(Object.class); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + TypeElement inBetweenTypeElement = TypeUtils.TypeRetrieval.getTypeElement(InbetweenType.class); + TypeElement topMostTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TopMostType.class); + TypeElement objectTypeElement = TypeUtils.TypeRetrieval.getTypeElement(Object.class); - MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElementsOfKindType(typeElement)), Matchers.contains( - inBetweenTypeElement, - topMostTypeElement, - objectTypeElement - )); + MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElementsOfKindType(typeElement)), Matchers.contains( + inBetweenTypeElement, + topMostTypeElement, + objectTypeElement + )); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -191,23 +200,24 @@ protected void testCase(TypeElement element) { @Test public void getSuperTypeElementsOfKindInterface() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - // find field - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + // find field + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestType.class); - MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); + MatcherAssert.assertThat("PRECONDITION : typelement must not be null", typeElement != null); - TypeElement testInterfaceTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); + TypeElement testInterfaceTypeElement = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); - MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElementsOfKindInterface(typeElement)), Matchers.contains( - testInterfaceTypeElement - )); + MatcherAssert.assertThat(Arrays.asList(ElementUtils.AccessTypeHierarchy.getSuperTypeElementsOfKindInterface(typeElement)), Matchers.contains( + testInterfaceTypeElement + )); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/FilerUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/FilerUtilsTest.java index 4ffdc48c..3d4831ff 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/FilerUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/FilerUtilsTest.java @@ -2,6 +2,7 @@ import io.toolisticon.aptk.tools.generators.FileObjectUtilsTestAnnotationProcessor; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.junit.Before; import org.junit.Test; @@ -16,16 +17,16 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder - .unitTest() - .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); + private CompileTestBuilderApi.CompilationTestBuilder compilationTestBuilder = CompileTestBuilder + .compilationTest() + .addSources(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @Test public void testValidUsage() { - unitTestBuilder.useProcessor(new FileObjectUtilsTestAnnotationProcessor()) - .useSource(JavaFileObjectUtils.readFromResource("/testcases/generators/FilerUtilsTestClass.java")) + compilationTestBuilder.addProcessors(FileObjectUtilsTestAnnotationProcessor.class) + .addSources(JavaFileObjectUtils.readFromResource("/testcases/generators/FilerUtilsTestClass.java")) .compilationShouldSucceed() .expectThatFileObjectExists(StandardLocation.CLASS_OUTPUT, "", "testOutput.txt", JavaFileObjectUtils.readFromResource("/testcases/generators/expectedResult.txt")) .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/FluentElementFilterTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/FluentElementFilterTest.java index 563aeb99..dc0dec5c 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/FluentElementFilterTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/FluentElementFilterTest.java @@ -1,14 +1,18 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; +import io.toolisticon.cute.TestAnnotation; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; @@ -23,7 +27,7 @@ public class FluentElementFilterTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -36,22 +40,24 @@ public void init() { @Test public void filterByKinds() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .getResult(); - MatcherAssert.assertThat(results, Matchers.hasSize(8)); + List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .getResult(); - for (Element resultElement : results) { - MatcherAssert.assertThat(resultElement.getKind(), Matchers.is(ElementKind.FIELD)); - } + MatcherAssert.assertThat(results, Matchers.hasSize(8)); - } - }) + for (Element resultElement : results) { + MatcherAssert.assertThat(resultElement.getKind(), Matchers.is(ElementKind.FIELD)); + } + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -60,21 +66,23 @@ protected void testCase(TypeElement element) { @Test public void filterByKinds_and_filterByModifiers() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .applyFilter(AptkCoreMatchers.BY_MODIFIER).filterByAllOf(Modifier.PUBLIC, Modifier.STATIC) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .applyFilter(AptkCoreMatchers.BY_MODIFIER).filterByAllOf(Modifier.PUBLIC, Modifier.STATIC) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(1)); - MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("publicStaticField")); + MatcherAssert.assertThat(result, Matchers.hasSize(1)); + MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("publicStaticField")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -82,19 +90,21 @@ protected void testCase(TypeElement element) { @Test public void filterByKinds_nullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List results = FluentElementFilter.createFluentElementFilter((List) null) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .getResult(); - MatcherAssert.assertThat(results, Matchers.hasSize(0)); + List results = FluentElementFilter.createFluentElementFilter((List) null) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .getResult(); + MatcherAssert.assertThat(results, Matchers.hasSize(0)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -102,18 +112,20 @@ protected void testCase(TypeElement element) { @Test public void filterByKinds_nullValuedFilterArgument_shouldReturnUnfilteredListElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(null) - .getResult(); + List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(null) + .getResult(); - MatcherAssert.assertThat(results, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(results, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -121,19 +133,21 @@ protected void testCase(TypeElement element) { @Test public void filterByKinds_shouldReturnUnfilteredListForNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf() - .getResult(); - MatcherAssert.assertThat(results, Matchers.hasSize(element.getEnclosedElements().size())); + List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf() + .getResult(); + MatcherAssert.assertThat(results, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -143,23 +157,25 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByKinds_returnListForMatchingFilterArguments() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .getResult(); + List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .getResult(); - MatcherAssert.assertThat(results, Matchers.hasSize(element.getEnclosedElements().size() - 8)); + MatcherAssert.assertThat(results, Matchers.hasSize(element.getEnclosedElements().size() - 8)); - for (Element resultElement : results) { - MatcherAssert.assertThat(resultElement.getKind(), Matchers.not(ElementKind.FIELD)); - } + for (Element resultElement : results) { + MatcherAssert.assertThat(resultElement.getKind(), Matchers.not(ElementKind.FIELD)); + } - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -167,19 +183,21 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByKinds_nullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List results = FluentElementFilter.createFluentElementFilter((List) null) - .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .getResult(); + List results = FluentElementFilter.createFluentElementFilter((List) null) + .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .getResult(); - MatcherAssert.assertThat(results, Matchers.hasSize(0)); + MatcherAssert.assertThat(results, Matchers.hasSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -188,19 +206,21 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByKinds_shouldReturnEmptyListForInvertedFilteringWithNullValuedFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(null) - .getResult(); - MatcherAssert.assertThat(results, Matchers.empty()); + List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(null) + .getResult(); + MatcherAssert.assertThat(results, Matchers.empty()); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -208,18 +228,20 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByKinds_shouldReturnEmptyListForNonInvertedFNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf() - .getResult(); + List results = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf() + .getResult(); - MatcherAssert.assertThat(results, Matchers.empty()); + MatcherAssert.assertThat(results, Matchers.empty()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -227,21 +249,23 @@ protected void testCase(TypeElement element) { @Test public void filterByNames_shouldReturnListForOneMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // one search attribute - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField") - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(1)); - MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("publicStaticField")); + // one search attribute + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField") + .getResult(); + MatcherAssert.assertThat(result, Matchers.hasSize(1)); + MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("publicStaticField")); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -250,21 +274,23 @@ protected void testCase(TypeElement element) { @Test public void filterByNames_shouldReturnListForTwoMatchingFilterArguments() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // two search attributes - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField", "synchronizedMethod") - .getResult(); + // two search attributes + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField", "synchronizedMethod") + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(2)); - MatcherAssert.assertThat(convertToList(result.get(0).getSimpleName().toString(), result.get(1).getSimpleName().toString()), Matchers.containsInAnyOrder("publicStaticField", "synchronizedMethod")); + MatcherAssert.assertThat(result, Matchers.hasSize(2)); + MatcherAssert.assertThat(convertToList(result.get(0).getSimpleName().toString(), result.get(1).getSimpleName().toString()), Matchers.containsInAnyOrder("publicStaticField", "synchronizedMethod")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -272,19 +298,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNames_shouldReturnEmptyListForNonMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // returns empty result - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("XXX") - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + // returns empty result + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("XXX") + .getResult(); - } - }) + MatcherAssert.assertThat(result, Matchers.hasSize(0)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -292,19 +320,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNames_shouldReturnUnfilteredListForNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // handle no passed filter args correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf() - .getResult(); + // handle no passed filter args correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf() + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -312,19 +342,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNames_shouldReturnUnfilteredListForNullValuedFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) - .getResult(); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -332,20 +364,22 @@ protected void testCase(TypeElement element) { @Test public void filterByNames_shouldReturnEmptyListForNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // null valued element list - List result = - FluentElementFilter.createFluentElementFilter((List) null) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + // null valued element list + List result = + FluentElementFilter.createFluentElementFilter((List) null) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) + .getResult(); - } - }) + MatcherAssert.assertThat(result, Matchers.hasSize(0)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -356,24 +390,26 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByNames_shouldReturnListForOneMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // one search attribute - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField") - .getResult(); + // one search attribute + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField") + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 1)); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 1)); - for (Element resultElement : result) { - MatcherAssert.assertThat(resultElement.getSimpleName().toString(), Matchers.not("publicStaticField")); - } + for (Element resultElement : result) { + MatcherAssert.assertThat(resultElement.getSimpleName().toString(), Matchers.not("publicStaticField")); + } - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -381,23 +417,25 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByNames_shouldReturnListForTwoMatchingFilterArguments() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // two search attributes - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField", "synchronizedMethod") - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 2)); - for (Element resultElement : result) { - MatcherAssert.assertThat("Must nor be publicStaticField or synchronizedMethod", !resultElement.getSimpleName().equals("publicStaticField") && !resultElement.getSimpleName().equals("synchronizedMethod")); - } + // two search attributes + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("publicStaticField", "synchronizedMethod") + .getResult(); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 2)); + for (Element resultElement : result) { + MatcherAssert.assertThat("Must nor be publicStaticField or synchronizedMethod", !resultElement.getSimpleName().equals("publicStaticField") && !resultElement.getSimpleName().equals("synchronizedMethod")); + } - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -405,20 +443,22 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByNames_shouldReturnEmptyListForNonMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // returns empty result - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("XXX") - .getResult(); + // returns empty result + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("XXX") + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -426,20 +466,21 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByNames_shouldReturnEmptyListForNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // handle no passed filter args correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf() - .getResult(); + // handle no passed filter args correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf() + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + MatcherAssert.assertThat(result, Matchers.hasSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -447,20 +488,22 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByNames_shouldReturnEmptyListForInvertedFilteringWithNullValuedFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) - .getResult(); - MatcherAssert.assertThat(result, Matchers.empty()); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) + .getResult(); + MatcherAssert.assertThat(result, Matchers.empty()); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -468,21 +511,23 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByNames_shouldReturnEmptyListForNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // null valued element list - List result = - FluentElementFilter.createFluentElementFilter((List) null) - .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) - .getResult(); + // null valued element list + List result = + FluentElementFilter.createFluentElementFilter((List) null) + .applyInvertedFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(null) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + MatcherAssert.assertThat(result, Matchers.hasSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -490,21 +535,23 @@ protected void testCase(TypeElement element) { @Test public void filterByNameWithRegularExpressions_shouldReturnNonEmptyListForOneMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // one search attribute - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf("publicSt.*Field") - .getResult(); + // one search attribute + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf("publicSt.*Field") + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(1)); - MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("publicStaticField")); + MatcherAssert.assertThat(result, Matchers.hasSize(1)); + MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("publicStaticField")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -513,21 +560,23 @@ protected void testCase(TypeElement element) { @Test public void filterByNameWithRegularExpressions_shouldReturnListForTwoMatchingFilterArguments() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // two search attributes - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf("publicSt.*Field", "synchr.*Method") - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(2)); - MatcherAssert.assertThat(convertToList(result.get(0).getSimpleName().toString(), result.get(1).getSimpleName().toString()), Matchers.containsInAnyOrder("publicStaticField", "synchronizedMethod")); + // two search attributes + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf("publicSt.*Field", "synchr.*Method") + .getResult(); + MatcherAssert.assertThat(result, Matchers.hasSize(2)); + MatcherAssert.assertThat(convertToList(result.get(0).getSimpleName().toString(), result.get(1).getSimpleName().toString()), Matchers.containsInAnyOrder("publicStaticField", "synchronizedMethod")); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -535,19 +584,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNameWithRegularExpressions_shouldReturnEmptyListForNonMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // returns empty result - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf("XXX") - .getResult(); + // returns empty result + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf("XXX") + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + MatcherAssert.assertThat(result, Matchers.hasSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -555,19 +606,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNameWithRegularExpressions_shouldReturnUnfilteredListForNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // handle no passed filter args correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf() - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + // handle no passed filter args correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf() + .getResult(); - } - }) + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -575,19 +628,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNameWithRegularExpressions_shouldReturnUnfilteredListForNullValuedFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(null) - .getResult(); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(null) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -595,19 +650,21 @@ protected void testCase(TypeElement element) { @Test public void filterByNameWithRegularExpressions_shouldReturnEmptyListForNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter((List) null) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(null) - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter((List) null) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(null) + .getResult(); - } - }) + MatcherAssert.assertThat(result, Matchers.hasSize(0)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -615,20 +672,22 @@ protected void testCase(TypeElement element) { @Test public void filterByAnnotation_shouldReturnEmptyListForOneMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(1)); - MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("synchronizedMethod")); + MatcherAssert.assertThat(result, Matchers.hasSize(1)); + MatcherAssert.assertThat(result.get(0).getSimpleName().toString(), Matchers.is("synchronizedMethod")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -637,21 +696,23 @@ protected void testCase(TypeElement element) { @Test public void filterByAnnotation_shouldReturnListForTwoMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // two search attributes - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, FilterTestAnnotation2.class) - .getResult(); + // two search attributes + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, FilterTestAnnotation2.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(1)); - MatcherAssert.assertThat(convertToList(result.get(0).getSimpleName().toString()), Matchers.containsInAnyOrder("synchronizedMethod")); + MatcherAssert.assertThat(result, Matchers.hasSize(1)); + MatcherAssert.assertThat(convertToList(result.get(0).getSimpleName().toString()), Matchers.containsInAnyOrder("synchronizedMethod")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -659,19 +720,21 @@ protected void testCase(TypeElement element) { @Test public void filterByAnnotation_shouldReturnEmptyListForNonMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // returns empty result - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(TestAnnotation.class) - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + // returns empty result + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(TestAnnotation.class) + .getResult(); - } - }) + MatcherAssert.assertThat(result, Matchers.hasSize(0)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -679,19 +742,21 @@ protected void testCase(TypeElement element) { @Test public void filterByAnnotation_shouldReturnEmptyListForNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // handle no passed filter args correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf() - .getResult(); + // handle no passed filter args correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf() + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -699,19 +764,21 @@ protected void testCase(TypeElement element) { @Test public void filterByAnnotation_shouldReturnUnfilteredListForNullValuedFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(null) - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(null) + .getResult(); - } - }) + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -719,19 +786,21 @@ protected void testCase(TypeElement element) { @Test public void filterByAnnotation_shouldReturnEmptyListForNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter((List) null) - .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) - .getResult(); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter((List) null) + .applyFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + MatcherAssert.assertThat(result, Matchers.hasSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -743,23 +812,25 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByAnnotation_shouldReturnListForOneMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // one search attribute - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) - .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 1)); + // one search attribute + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) + .getResult(); - for (Element resultElement : result) { - MatcherAssert.assertThat(resultElement.getSimpleName().toString(), Matchers.not("synchronizedMethod")); - } + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 1)); - } - }) + for (Element resultElement : result) { + MatcherAssert.assertThat(resultElement.getSimpleName().toString(), Matchers.not("synchronizedMethod")); + } + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -767,23 +838,25 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByAnnotation_shouldReturnListForTwoMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // two search attributes - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, FilterTestAnnotation2.class) - .getResult(); + // two search attributes + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, FilterTestAnnotation2.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 1)); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size() - 1)); - for (Element resultElement : result) { - MatcherAssert.assertThat(resultElement.getSimpleName().toString(), Matchers.not("synchronizedMethod")); - } + for (Element resultElement : result) { + MatcherAssert.assertThat(resultElement.getSimpleName().toString(), Matchers.not("synchronizedMethod")); + } - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -791,19 +864,21 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByAnnotation_shouldReturnUnfilteredListForNonMatchingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // returns empty result - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, TestAnnotation.class) - .getResult(); + // returns empty result + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, TestAnnotation.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -811,19 +886,20 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByAnnotation_shouldReturnEmptyListForNonExistingFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // returns empty result - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, TestAnnotation.class) - .getResult(); + // returns empty result + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByAllOf(FilterTestAnnotation1.class, TestAnnotation.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); + MatcherAssert.assertThat(result, Matchers.hasSize(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -832,20 +908,22 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByAnnotation_shouldReturnEmptyListForInvertedFilteringWithNullValuedFilterArgument() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(null) - .getResult(); - MatcherAssert.assertThat(result, Matchers.empty()); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(null) + .getResult(); + MatcherAssert.assertThat(result, Matchers.empty()); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -853,20 +931,22 @@ protected void testCase(TypeElement element) { @Test public void inverseFilterByAnnotation_shouldReturnEmptyListForNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // handle nulls correctly - List result = FluentElementFilter.createFluentElementFilter((List) null) - .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) - .getResult(); + // handle nulls correctly + List result = FluentElementFilter.createFluentElementFilter((List) null) + .applyInvertedFilter(AptkCoreMatchers.BY_ANNOTATION).filterByOneOf(FilterTestAnnotation1.class) + .getResult(); - MatcherAssert.assertThat(result, Matchers.hasSize(0)); + MatcherAssert.assertThat(result, Matchers.hasSize(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -874,16 +954,18 @@ protected void testCase(TypeElement element) { @Test public void isEmpty_succeedingValidationWithEmptyElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).isEmpty(), Matchers.is(true)); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).isEmpty(), Matchers.is(true)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -891,16 +973,18 @@ protected void testCase(TypeElement element) { @Test public void isEmpty_failingValidationWithNonEmptyElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects non empty result correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).isEmpty(), Matchers.is(false)); + // detects non empty result correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).isEmpty(), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -908,16 +992,18 @@ protected void testCase(TypeElement element) { @Test public void isEmpty_succeedingValidationWithNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects non empty result correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).isEmpty(), Matchers.is(true)); + // detects non empty result correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).isEmpty(), Matchers.is(true)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -925,16 +1011,18 @@ protected void testCase(TypeElement element) { @Test public void hasSingleElement_failingValidationWithEmptyElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).hasSingleElement(), Matchers.is(false)); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).hasSingleElement(), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -942,16 +1030,18 @@ protected void testCase(TypeElement element) { @Test public void hasSingleElement_succeedingValidationWithElementListWithSizeOne() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects single result elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(convertToList(element)).hasSingleElement(), Matchers.is(true)); + // detects single result elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(convertToList(element)).hasSingleElement(), Matchers.is(true)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -959,16 +1049,18 @@ protected void testCase(TypeElement element) { @Test public void hasSingleElement_failingValidationWithElementListWithSizeBiggerOne() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects multiple elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasSingleElement(), Matchers.is(false)); + // detects multiple elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasSingleElement(), Matchers.is(false)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -976,16 +1068,18 @@ protected void testCase(TypeElement element) { @Test public void hasSingleElement_failingValidationWithNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects multiple elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).hasSingleElement(), Matchers.is(false)); + // detects multiple elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).hasSingleElement(), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -993,16 +1087,18 @@ protected void testCase(TypeElement element) { @Test public void hasMultipleElement_succeedingValidationWithMultipleElements() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects multiple elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasMultipleElements(), Matchers.is(true)); + // detects multiple elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasMultipleElements(), Matchers.is(true)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1010,16 +1106,18 @@ protected void testCase(TypeElement element) { @Test public void hasMultipleElement_succeedingValidationWithEmptyList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).hasMultipleElements(), Matchers.is(false)); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).hasMultipleElements(), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1027,16 +1125,18 @@ protected void testCase(TypeElement element) { @Test public void hasMultipleElement_failingValidationWithListOfSizeOne() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects single result elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(convertToList(element)).hasMultipleElements(), Matchers.is(false)); + // detects single result elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(convertToList(element)).hasMultipleElements(), Matchers.is(false)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1044,16 +1144,18 @@ protected void testCase(TypeElement element) { @Test public void hasMultipleElement_failingValidationWithNullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects single result elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).hasMultipleElements(), Matchers.is(false)); + // detects single result elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).hasMultipleElements(), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1061,15 +1163,17 @@ protected void testCase(TypeElement element) { @Test public void hasSize_succeedingValidationWithEmptyElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).hasSize(0), Matchers.is(true)); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(new ArrayList()).hasSize(0), Matchers.is(true)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1077,15 +1181,17 @@ protected void testCase(TypeElement element) { @Test public void hasSize_succeedingValidationWithElementListOfSizeOne() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects single result elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(convertToList(element)).hasSize(1), Matchers.is(true)); - } - }) + // detects single result elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(convertToList(element)).hasSize(1), Matchers.is(true)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1093,15 +1199,17 @@ protected void testCase(TypeElement element) { @Test public void hasSize_succeedingValidationWithElementListOfSizeBiggerThanOne() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects multiple elements correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasSize(element.getEnclosedElements().size()), Matchers.is(true)); + // detects multiple elements correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasSize(element.getEnclosedElements().size()), Matchers.is(true)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1109,15 +1217,17 @@ protected void testCase(TypeElement element) { @Test public void hasSize_succeedingValidationWithNullValued() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects null valued element list correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).hasSize(3), Matchers.is(false)); + // detects null valued element list correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).hasSize(3), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1125,16 +1235,18 @@ protected void testCase(TypeElement element) { @Test public void hasSize_failingValidation1() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasSize(0), Matchers.is(false)); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).hasSize(0), Matchers.is(false)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1142,16 +1254,18 @@ protected void testCase(TypeElement element) { @Test public void geResultSize_nullValuedElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).getResultSize(), Matchers.is(0)); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter((List) null).getResultSize(), Matchers.is(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1160,16 +1274,18 @@ protected void testCase(TypeElement element) { @Test public void geResultSize_emptyElementList() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // detects empty results correctly - MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).getResultSize(), Matchers.is(element.getEnclosedElements().size())); + // detects empty results correctly + MatcherAssert.assertThat(FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()).getResultSize(), Matchers.is(element.getEnclosedElements().size())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/InterfaceUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/InterfaceUtilsTest.java index a70e50cf..42f5ccb0 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/InterfaceUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/InterfaceUtilsTest.java @@ -1,9 +1,11 @@ package io.toolisticon.aptk.tools; import io.toolisticon.aptk.common.ToolingProvider; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.wrapper.ExecutableElementWrapper; import io.toolisticon.aptk.tools.wrapper.TypeElementWrapper; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.PassIn; import io.toolisticon.cute.UnitTest; import org.hamcrest.MatcherAssert; @@ -11,7 +13,6 @@ import org.junit.Test; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import java.io.IOException; @@ -72,9 +73,10 @@ static class TypeVarReplacement { @Test public void getStringRepresentationWithReplaceTypeVars() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeVarReplacement.class, new UnitTest() { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeVarReplacement.class, new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + ToolingProvider.setTooling(processingEnvironment); try { @@ -108,9 +110,10 @@ static class TypeVarMappingTest { @Test public void mapTypeVars_withPassedInTypes() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeVarMappingTest.class, new UnitTest() { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeVarMappingTest.class, new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + ToolingProvider.setTooling(processingEnvironment); try { @@ -133,9 +136,10 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement el @Test public void mapTypeVars_withoutPassedInTypes() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeVarMappingTest.class, new UnitTest() { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeVarMappingTest.class, new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + ToolingProvider.setTooling(processingEnvironment); try { @@ -188,28 +192,22 @@ interface MethodsToImplement_Top { @Test public void getMethodsToImplement() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(MethodsToImplement_Base.class, new UnitTest() { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(MethodsToImplement_Base.class, new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - - ToolingProvider.setTooling(processingEnvironment); - try { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Set methods = InterfaceUtils.getMethodsToImplement(TypeElementWrapper.wrap(element)); - MatcherAssert.assertThat(methods.stream().map(e -> e.getMethodSignature()).collect(Collectors.toList()), Matchers.containsInAnyOrder( - "T groundLevel(F baseParam)", - "String midLevel(Integer midParam)", - "String topLevel(String topParam)", - "void withGenerics(List genParam)", - "> void withMethodTypeVar(K param)", - "String withMethodTypeVar() throws IOException", - "void doubledMethod(String parameter)")); + Set methods = InterfaceUtils.getMethodsToImplement(TypeElementWrapper.wrap(element)); + MatcherAssert.assertThat(methods.stream().map(e -> e.getMethodSignature()).collect(Collectors.toList()), Matchers.containsInAnyOrder( + "T groundLevel(F baseParam)", + "String midLevel(Integer midParam)", + "String topLevel(String topParam)", + "void withGenerics(List genParam)", + "> void withMethodTypeVar(K param)", + "String withMethodTypeVar() throws IOException", + "void doubledMethod(String parameter)")); - } finally { - ToolingProvider.clearTooling(); - } } }) @@ -244,7 +242,7 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement el } - CompileTestBuilder.UnitTestBuilder unitTestBuilder; + CompileTestBuilderApi.UnitTestBuilder unitTestBuilder; public interface FluentApiConverter { @@ -267,7 +265,7 @@ public String toString() { } } - public abstract static class SuperClass implements FluentApiConverter { + public abstract static class SuperClass implements FluentApiConverter { } @@ -292,46 +290,31 @@ public TargetType convert(String o) { @Test public void test_getResolvedTypeArgumentOfSuperTypeOrInterface_with_superclass() { - CompileTestBuilder.unitTest().defineTest(new UnitTest() { + CompileTestBuilder.unitTest().defineTest(new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - try { - ToolingProvider.setTooling(processingEnvironment); - - List typeParameters = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.getByClass(MyConverter.class).get(), TypeMirrorWrapper.wrap(FluentApiConverter.class)); - MatcherAssert.assertThat(typeParameters.stream().map(e -> e.getSimpleName()).collect(Collectors.toList()), Matchers.contains(String.class.getSimpleName().toString(), TargetType.class.getSimpleName().toString())); + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - typeParameters = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.getByClass(MyConverter.class).get(), TypeMirrorWrapper.wrap(SuperClass.class)); - MatcherAssert.assertThat(typeParameters.stream().map(e -> e.getSimpleName()).collect(Collectors.toList()), Matchers.contains(String.class.getSimpleName().toString(), TargetType.class.getSimpleName().toString())); + List typeParameters = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.getByClass(MyConverter.class).get(), TypeMirrorWrapper.wrap(FluentApiConverter.class)); + MatcherAssert.assertThat(typeParameters.stream().map(e -> e.getSimpleName()).collect(Collectors.toList()), Matchers.contains(String.class.getSimpleName().toString(), TargetType.class.getSimpleName().toString())); - } finally { - ToolingProvider.clearTooling(); - } - + typeParameters = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.getByClass(MyConverter.class).get(), TypeMirrorWrapper.wrap(SuperClass.class)); + MatcherAssert.assertThat(typeParameters.stream().map(e -> e.getSimpleName()).collect(Collectors.toList()), Matchers.contains(String.class.getSimpleName().toString(), TargetType.class.getSimpleName().toString())); } }).executeTest(); } - @Test public void test_getResolvedTypeArgumentOfSuperTypeOrInterface_without_superclass() { - CompileTestBuilder.unitTest().defineTest(new UnitTest() { + CompileTestBuilder.unitTest().defineTest(new APTKUnitTestProcessor() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - try { - ToolingProvider.setTooling(processingEnvironment); - - List typeParameters = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.getByClass(My2ndConverter.class).get(), TypeMirrorWrapper.wrap(FluentApiConverter.class)); - - MatcherAssert.assertThat(typeParameters.stream().map(e -> e.getSimpleName()).collect(Collectors.toList()), Matchers.contains(String.class.getSimpleName().toString(), TargetType.class.getSimpleName().toString())); + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - } finally { - ToolingProvider.clearTooling(); - } + List typeParameters = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.getByClass(My2ndConverter.class).get(), TypeMirrorWrapper.wrap(FluentApiConverter.class)); + MatcherAssert.assertThat(typeParameters.stream().map(e -> e.getSimpleName()).collect(Collectors.toList()), Matchers.contains(String.class.getSimpleName().toString(), TargetType.class.getSimpleName().toString())); } }).executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/TestAnnotation.java b/tools/src/test/java/io/toolisticon/aptk/tools/TestAnnotation.java deleted file mode 100644 index ae1cb219..00000000 --- a/tools/src/test/java/io/toolisticon/aptk/tools/TestAnnotation.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.toolisticon.aptk.tools; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(value = ElementType.TYPE) -public @interface TestAnnotation { -} diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/TypeMirrorWrapperTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/TypeMirrorWrapperTest.java index ed0c0dc2..ef638350 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/TypeMirrorWrapperTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/TypeMirrorWrapperTest.java @@ -4,7 +4,6 @@ import io.toolisticon.cute.CompileTestBuilder; import io.toolisticon.cute.PassIn; import io.toolisticon.cute.UnitTest; -import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; import org.mockito.Mockito; @@ -24,6 +23,10 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Consumer; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; /** * Unit test for {@link TypeMirrorWrapper}. @@ -56,13 +59,13 @@ public void test_nullValuedWrapper_class() { @Test public void test_wrap() { - CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { + CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { ToolingProvider.setTooling(processingEnvironment); try { - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(TypeMirrorWrapperTest.class).getQualifiedName(), Matchers.is(TypeMirrorWrapperTest.class.getCanonicalName())); - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(TypeMirrorWrapperTest.class.getCanonicalName()).getQualifiedName(), Matchers.is(TypeMirrorWrapperTest.class.getCanonicalName())); + assertThat(TypeMirrorWrapper.wrap(TypeMirrorWrapperTest.class).getQualifiedName(), is(TypeMirrorWrapperTest.class.getCanonicalName())); + assertThat(TypeMirrorWrapper.wrap(TypeMirrorWrapperTest.class.getCanonicalName()).getQualifiedName(), is(TypeMirrorWrapperTest.class.getCanonicalName())); } finally { @@ -75,26 +78,26 @@ public void test_wrap() { @Test public void test_isVoid() { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.VOID)).isVoidType()); - MatcherAssert.assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isVoidType()); - MatcherAssert.assertThat("Expected false for null", !TypeMirrorWrapper.isVoidType(mockTypeCheck(null))); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.VOID)).isVoidType()); + assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isVoidType()); + assertThat("Expected false for null", !TypeMirrorWrapper.isVoidType(mockTypeCheck(null))); } @Test public void test_isWildcardType() { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).isWildcardType()); - MatcherAssert.assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isWildcardType()); - MatcherAssert.assertThat("Expected false for null", !TypeMirrorWrapper.isWildcardType(mockTypeCheck(null))); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).isWildcardType()); + assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isWildcardType()); + assertThat("Expected false for null", !TypeMirrorWrapper.isWildcardType(mockTypeCheck(null))); } @Test public void test_getWildcardType() { // Expect cast instance of TypeMirror TypeMirror typeMirror = mockTypeCheck(WildcardType.class, TypeKind.WILDCARD); - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(typeMirror).getWildcardType(), Matchers.is(typeMirror)); + assertThat(TypeMirrorWrapper.wrap(typeMirror).getWildcardType(), is(typeMirror)); // expect null for non matching type kind - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).getWildcardType(), Matchers.nullValue()); + assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).getWildcardType(), Matchers.nullValue()); } @@ -104,7 +107,7 @@ public static class ClassType { } - public static enum EnumType { + public enum EnumType { } @@ -115,97 +118,85 @@ public interface InterfaceType { @Test public void test_isClassType() { - CompileTestBuilder.unitTest().defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { + CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { - ToolingProvider.setTooling(processingEnvironment); + ToolingProvider.setTooling(processingEnvironment); - MatcherAssert.assertThat("must return true for Class", TypeMirrorWrapper.wrap(ClassType.class).isClass()); - MatcherAssert.assertThat("must return false for Enum", !TypeMirrorWrapper.wrap(EnumType.class).isClass()); - MatcherAssert.assertThat("must return false for Interface", !TypeMirrorWrapper.wrap(InterfaceType.class).isClass()); - MatcherAssert.assertThat("must return false for annotation", !TypeMirrorWrapper.wrap(Target.class).isClass()); + assertThat("must return true for Class", TypeMirrorWrapper.wrap(ClassType.class).isClass()); + assertThat("must return false for Enum", !TypeMirrorWrapper.wrap(EnumType.class).isClass()); + assertThat("must return false for Interface", !TypeMirrorWrapper.wrap(InterfaceType.class).isClass()); + assertThat("must return false for annotation", !TypeMirrorWrapper.wrap(Target.class).isClass()); - } }).executeTest(); } @Test public void test_isEnumType() { - CompileTestBuilder.unitTest().defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { + CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { - ToolingProvider.setTooling(processingEnvironment); + ToolingProvider.setTooling(processingEnvironment); - MatcherAssert.assertThat("must return false for Class", !TypeMirrorWrapper.wrap(ClassType.class).isEnum()); - MatcherAssert.assertThat("must return true for Enum", TypeMirrorWrapper.wrap(EnumType.class).isEnum()); - MatcherAssert.assertThat("must return false for Interface", !TypeMirrorWrapper.wrap(InterfaceType.class).isEnum()); - MatcherAssert.assertThat("must return false for annotation", !TypeMirrorWrapper.wrap(Target.class).isEnum()); + assertThat("must return false for Class", !TypeMirrorWrapper.wrap(ClassType.class).isEnum()); + assertThat("must return true for Enum", TypeMirrorWrapper.wrap(EnumType.class).isEnum()); + assertThat("must return false for Interface", !TypeMirrorWrapper.wrap(InterfaceType.class).isEnum()); + assertThat("must return false for annotation", !TypeMirrorWrapper.wrap(Target.class).isEnum()); - } }).executeTest(); } @Test public void test_isInterfaceType() { - CompileTestBuilder.unitTest().defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { + CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { - ToolingProvider.setTooling(processingEnvironment); + ToolingProvider.setTooling(processingEnvironment); - MatcherAssert.assertThat("must return false for Class", !TypeMirrorWrapper.wrap(ClassType.class).isInterface()); - MatcherAssert.assertThat("must return false for Enum", !TypeMirrorWrapper.wrap(EnumType.class).isInterface()); - MatcherAssert.assertThat("must return true for Interface", TypeMirrorWrapper.wrap(InterfaceType.class).isInterface()); - MatcherAssert.assertThat("must return false for annotation", !TypeMirrorWrapper.wrap(Target.class).isInterface()); + assertThat("must return false for Class", !TypeMirrorWrapper.wrap(ClassType.class).isInterface()); + assertThat("must return false for Enum", !TypeMirrorWrapper.wrap(EnumType.class).isInterface()); + assertThat("must return true for Interface", TypeMirrorWrapper.wrap(InterfaceType.class).isInterface()); + assertThat("must return false for annotation", !TypeMirrorWrapper.wrap(Target.class).isInterface()); - } }).executeTest(); } @Test public void test_isAnnotationType() { - CompileTestBuilder.unitTest().defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { + CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { - ToolingProvider.setTooling(processingEnvironment); + ToolingProvider.setTooling(processingEnvironment); - MatcherAssert.assertThat("must return false for Class", !TypeMirrorWrapper.wrap(ClassType.class).isAnnotation()); - MatcherAssert.assertThat("must return false for Enum", !TypeMirrorWrapper.wrap(EnumType.class).isAnnotation()); - MatcherAssert.assertThat("must return false for Interface", !TypeMirrorWrapper.wrap(InterfaceType.class).isAnnotation()); - MatcherAssert.assertThat("must return true for annotation", TypeMirrorWrapper.wrap(Target.class).isAnnotation()); + assertThat("must return false for Class", !TypeMirrorWrapper.wrap(ClassType.class).isAnnotation()); + assertThat("must return false for Enum", !TypeMirrorWrapper.wrap(EnumType.class).isAnnotation()); + assertThat("must return false for Interface", !TypeMirrorWrapper.wrap(InterfaceType.class).isAnnotation()); + assertThat("must return true for annotation", TypeMirrorWrapper.wrap(Target.class).isAnnotation()); - } }).executeTest(); } @Test public void test_isErrorType() { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.ERROR)).isErrorType()); - MatcherAssert.assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isErrorType()); - MatcherAssert.assertThat("Expected false for null", !TypeMirrorWrapper.isErrorType(mockTypeCheck(null))); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.ERROR)).isErrorType()); + assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isErrorType()); + assertThat("Expected false for null", !TypeMirrorWrapper.isErrorType(mockTypeCheck(null))); } @Test public void test_isDeclaredType() { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isDeclared()); - MatcherAssert.assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.ARRAY)).isDeclared()); - MatcherAssert.assertThat("Expected false for null", !TypeMirrorWrapper.isDeclared(null)); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isDeclared()); + assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.ARRAY)).isDeclared()); + assertThat("Expected false for null", !TypeMirrorWrapper.isDeclared(null)); } @Test public void test_getDeclaredType() { // Expect cast instance of TypeMirror TypeMirror typeMirror = mockTypeCheck(DeclaredType.class, TypeKind.DECLARED); - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(typeMirror).getDeclaredType(), Matchers.is(typeMirror)); + assertThat(TypeMirrorWrapper.wrap(typeMirror).getDeclaredType(), is(typeMirror)); // expect null for non matching type kind - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).getDeclaredType(), Matchers.nullValue()); + assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).getDeclaredType(), Matchers.nullValue()); } @@ -229,157 +220,163 @@ public static class CollectionCheck_NoCollection { Map noCollectionField; } - @Test - public void test_isCollection_List() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_List.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + public static class IterableCheck_Iterable { + @PassIn + Iterable iterableField; + } - ToolingProvider.setTooling(processingEnvironment); - try { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(element.asType()).isCollection()); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + public static class IterableCheck_IterableWithoutComponentType { + @PassIn + Iterable collectionField; + } + + public static class IterableCheck_NonIterable { + @PassIn + Map nonIterableField; + } + + private void executeTest(Class clazz, Consumer test){ + CompileTestBuilder.unitTest().defineTestWithPassedInElement(clazz, + (processingEnvironment, element) -> { + ToolingProvider.setTooling(processingEnvironment); + try { + test.accept(element); + } finally { + ToolingProvider.clearTooling(); + } + }).executeTest(); } @Test - public void test_isCollection_Set() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_Set.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + public void test_isIterable_Iterable() + { + executeTest(IterableCheck_Iterable.class,(element) -> + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(element.asType()).isIterable()) + ); + } + @Test + public void test_isCollection_List() + { + executeTest(CollectionCheck_List.class, (element) -> + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(element.asType()).isCollection()) + ); + } - ToolingProvider.setTooling(processingEnvironment); - try { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(element.asType()).isCollection()); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + @Test + public void test_isCollection_Set() + { + executeTest(CollectionCheck_Set.class, (element) -> + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(element.asType()).isCollection()) + ); } @Test - public void test_isCollection_noCollection() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_NoCollection.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + public void test_isCollection_noCollection() + { + executeTest(CollectionCheck_NoCollection.class, (element) -> + assertThat("Expected false for no collection type", !TypeMirrorWrapper.wrap(element.asType()).isCollection()) + ); + } - ToolingProvider.setTooling(processingEnvironment); - try { - MatcherAssert.assertThat("Expected false for no collection type", !TypeMirrorWrapper.wrap(element.asType()).isCollection()); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + @Test + public void test_isIterable_nonIterable() + { + executeTest(IterableCheck_NonIterable.class, (element) -> + assertThat("Expected false for non iterable type", !TypeMirrorWrapper.wrap(element.asType()).isIterable()) + ); } @Test public void test_getComponentType_forList() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_Set.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { - - ToolingProvider.setTooling(processingEnvironment); - try { + executeTest(CollectionCheck_Set.class, (element) -> { TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); - MatcherAssert.assertThat("Should be true", typeMirrorWrapper.hasComponentType()); - MatcherAssert.assertThat(typeMirrorWrapper.getComponentType().toString(), Matchers.is(String.class.getCanonicalName())); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + assertThat("Should be true", typeMirrorWrapper.hasComponentType()); + assertThat(typeMirrorWrapper.getComponentType().toString(), is(String.class.getCanonicalName())); + }); } @Test - public void test_getComponentType_forListWithoutComponentType() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_ListWithoutComponentType.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { - - ToolingProvider.setTooling(processingEnvironment); - try { - TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); - MatcherAssert.assertThat("Should be true", typeMirrorWrapper.hasComponentType()); - MatcherAssert.assertThat(typeMirrorWrapper.getWrappedComponentType().getQualifiedName(), Matchers.is(Object.class.getCanonicalName())); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + public void test_getComponentType_forIterable() { + executeTest(IterableCheck_Iterable.class, (element) -> { + TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); + assertThat("Should be true", typeMirrorWrapper.hasComponentType()); + assertThat(typeMirrorWrapper.getComponentType().toString(), is(String.class.getCanonicalName())); + }); } @Test - public void test_getComponentType_forSet() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_Set.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + public void test_getComponentType_forListWithoutComponentType() + { + executeTest(CollectionCheck_ListWithoutComponentType.class, (element) -> { + TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); + assertThat("Should be true", typeMirrorWrapper.hasComponentType()); + assertThat(typeMirrorWrapper.getWrappedComponentType().getQualifiedName(), + is(Object.class.getCanonicalName())); + }); + } - ToolingProvider.setTooling(processingEnvironment); - try { - TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); - MatcherAssert.assertThat("Should be true", typeMirrorWrapper.hasComponentType()); - MatcherAssert.assertThat(typeMirrorWrapper.getComponentType().toString(), Matchers.is(String.class.getCanonicalName())); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + @Test + public void test_getComponentType_forIterableWithoutComponentType() + { + executeTest(IterableCheck_IterableWithoutComponentType.class, (element) -> { + TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); + assertThat("Should be true", typeMirrorWrapper.hasComponentType()); + assertThat(typeMirrorWrapper.getWrappedComponentType().getQualifiedName(), + is(Object.class.getCanonicalName())); + }); } @Test - public void test_getComponentType_nonCollection() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(CollectionCheck_NoCollection.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + public void test_getComponentType_forSet() + { + executeTest(CollectionCheck_Set.class, (element) -> { + TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); + assertThat("Should be true", typeMirrorWrapper.hasComponentType()); + assertThat(typeMirrorWrapper.getComponentType().toString(), is(String.class.getCanonicalName())); + }); + } - ToolingProvider.setTooling(processingEnvironment); - try { - TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); - MatcherAssert.assertThat("Should be false", !typeMirrorWrapper.hasComponentType()); - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getComponentType(), Matchers.nullValue()); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + @Test + public void test_getComponentType_nonCollection() + { + executeTest(CollectionCheck_NoCollection.class, (element) -> { + TypeMirrorWrapper typeMirrorWrapper = TypeMirrorWrapper.wrap(element.asType()); + assertThat("Should be false", !typeMirrorWrapper.hasComponentType()); + assertThat(TypeMirrorWrapper.wrap(element.asType()).getComponentType(), Matchers.nullValue()); + }); } @Test public void test_isArrayType() { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.ARRAY)).isArray()); - MatcherAssert.assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isArray()); - MatcherAssert.assertThat("Expected false for null", !TypeMirrorWrapper.isArray(null)); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.ARRAY)).isArray()); + assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isArray()); + assertThat("Expected false for null", !TypeMirrorWrapper.isArray(null)); } @Test public void test_getArrayType() { // Expect cast instance of TypeMirror TypeMirror typeMirror = mockTypeCheck(ArrayType.class, TypeKind.ARRAY); - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(typeMirror).getArrayType(), Matchers.is(typeMirror)); + assertThat(TypeMirrorWrapper.wrap(typeMirror).getArrayType(), is(typeMirror)); // expect null for non matching type kind - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).getArrayType(), Matchers.nullValue()); + assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).getArrayType(), Matchers.nullValue()); } @Test public void test_isPrimitiveType() { - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.LONG)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.SHORT)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DOUBLE)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.FLOAT)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.BYTE)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.BOOLEAN)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.INT)).isPrimitive()); - MatcherAssert.assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.CHAR)).isPrimitive()); - MatcherAssert.assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isPrimitive()); - MatcherAssert.assertThat("Expected false for null", !TypeMirrorWrapper.isPrimitive(null)); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.LONG)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.SHORT)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DOUBLE)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.FLOAT)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.BYTE)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.BOOLEAN)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.INT)).isPrimitive()); + assertThat("Expected true for matching kind", TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.CHAR)).isPrimitive()); + assertThat("Expected false for non matching kind", !TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.DECLARED)).isPrimitive()); + assertThat("Expected false for null", !TypeMirrorWrapper.isPrimitive(null)); } @Test @@ -395,14 +392,14 @@ public void test_getPrimitiveType() { testGetPrimitiveType(TypeKind.CHAR); // expect null for non matching type kind - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).getPrimitiveType(), Matchers.nullValue()); + assertThat(TypeMirrorWrapper.wrap(mockTypeCheck(TypeKind.WILDCARD)).getPrimitiveType(), Matchers.nullValue()); } private void testGetPrimitiveType(TypeKind typeKind) { // Expect cast instance of TypeMirror TypeMirror typeMirror = mockTypeCheck(PrimitiveType.class, typeKind); - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(typeMirror).getPrimitiveType(), Matchers.is(typeMirror)); + assertThat(TypeMirrorWrapper.wrap(typeMirror).getPrimitiveType(), is(typeMirror)); } private TypeMirror mockTypeCheck(Class type, TypeKind typeKind) { @@ -442,16 +439,14 @@ public static class ImportTest_Primitive { @Test public void test_getImports() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest.class, + (UnitTest) (processingEnvironment, element) -> { - Set imports = TypeMirrorWrapper.wrap(element.asType()).getImports(); + Set imports = TypeMirrorWrapper.wrap(element.asType()).getImports(); - MatcherAssert.assertThat(imports, Matchers.containsInAnyOrder(List.class.getCanonicalName(), Map.class.getCanonicalName(), Serializable.class.getCanonicalName())); + assertThat(imports, Matchers.containsInAnyOrder(List.class.getCanonicalName(), Map.class.getCanonicalName(), Serializable.class.getCanonicalName())); - } - }).executeTest(); + }).executeTest(); } // --------------------------------------------------------------- @@ -460,44 +455,38 @@ public void unitTest(ProcessingEnvironment processingEnvironment, VariableElemen @Test public void test_getTypeDeclaration_withTypeParameters() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest.class, + (UnitTest) (processingEnvironment, element) -> { - String typeDeclaration = TypeMirrorWrapper.wrap(element.asType()).getTypeDeclaration(); + String typeDeclaration = TypeMirrorWrapper.wrap(element.asType()).getTypeDeclaration(); - MatcherAssert.assertThat(typeDeclaration, Matchers.is("Map[]>")); + assertThat(typeDeclaration, is("Map[]>")); - } - }).executeTest(); + }).executeTest(); } @Test public void test_getTypeDeclaration_withoutTypeParameters() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest_NonGeneric.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest_NonGeneric.class, + (UnitTest) (processingEnvironment, element) -> { - String typeDeclaration = TypeMirrorWrapper.wrap(element.asType()).getTypeDeclaration(); + String typeDeclaration = TypeMirrorWrapper.wrap(element.asType()).getTypeDeclaration(); - MatcherAssert.assertThat(typeDeclaration, Matchers.is("String")); + assertThat(typeDeclaration, is("String")); - } - }).executeTest(); + }).executeTest(); } @Test public void test_getTypeDeclaration_withPrimitive() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest_Primitive.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(ImportTest_Primitive.class, + (UnitTest) (processingEnvironment, element) -> { - String typeDeclaration = TypeMirrorWrapper.wrap(element.asType()).getTypeDeclaration(); + String typeDeclaration = TypeMirrorWrapper.wrap(element.asType()).getTypeDeclaration(); - MatcherAssert.assertThat(typeDeclaration, Matchers.is("long")); + assertThat(typeDeclaration, is("long")); - } - }).executeTest(); + }).executeTest(); } // --------------------------------------------------------------- @@ -511,18 +500,16 @@ public static class TypeArgumentsTest { @Test public void test_hasTypeArguments() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeArgumentsTest.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeArgumentsTest.class, + (UnitTest) (processingEnvironment, element) -> { - // with type arguments - MatcherAssert.assertThat("expect true for Map", TypeMirrorWrapper.wrap(element.asType()).hasTypeArguments()); + // with type arguments + assertThat("expect true for Map", TypeMirrorWrapper.wrap(element.asType()).hasTypeArguments()); - // No Type arguments - MatcherAssert.assertThat("expect false for String", !TypeMirrorWrapper.wrap(processingEnvironment.getElementUtils().getTypeElement(String.class.getCanonicalName()).asType()).hasTypeArguments()); + // No Type arguments + assertThat("expect false for String", !TypeMirrorWrapper.wrap(processingEnvironment.getElementUtils().getTypeElement(String.class.getCanonicalName()).asType()).hasTypeArguments()); - } - }).executeTest(); + }).executeTest(); } // --------------------------------------------------------------- @@ -531,26 +518,24 @@ public void unitTest(ProcessingEnvironment processingEnvironment, VariableElemen @Test public void test_getTypeArguments() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeArgumentsTest.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeArgumentsTest.class, + (UnitTest) (processingEnvironment, element) -> { - try { - ToolingProvider.setTooling(processingEnvironment); + try { + ToolingProvider.setTooling(processingEnvironment); - List typeArgumentTypeMirrors = TypeMirrorWrapper.wrap(element.asType()).getTypeArguments(); - MatcherAssert.assertThat(typeArgumentTypeMirrors, Matchers.hasSize(2)); - MatcherAssert.assertThat(TypeUtils.TypeConversion.convertToFqn(typeArgumentTypeMirrors.get(0)), Matchers.is(String.class.getCanonicalName())); - MatcherAssert.assertThat(TypeUtils.TypeConversion.convertToFqn(typeArgumentTypeMirrors.get(1)), Matchers.is(Long.class.getCanonicalName())); + List typeArgumentTypeMirrors = TypeMirrorWrapper.wrap(element.asType()).getTypeArguments(); + assertThat(typeArgumentTypeMirrors, Matchers.hasSize(2)); + assertThat(TypeUtils.TypeConversion.convertToFqn(typeArgumentTypeMirrors.get(0)), is(String.class.getCanonicalName())); + assertThat(TypeUtils.TypeConversion.convertToFqn(typeArgumentTypeMirrors.get(1)), is(Long.class.getCanonicalName())); - // check for non typeArgument class - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.getEnclosingElement().asType()).getTypeArguments(), Matchers.nullValue()); + // check for non typeArgument class + assertThat(TypeMirrorWrapper.wrap(element.getEnclosingElement().asType()).getTypeArguments(), Matchers.nullValue()); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + } finally { + ToolingProvider.clearTooling(); + } + }).executeTest(); } // --------------------------------------------------------------- @@ -559,26 +544,24 @@ public void unitTest(ProcessingEnvironment processingEnvironment, VariableElemen @Test public void test_getWrappedTypeArguments() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeArgumentsTest.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { + CompileTestBuilder.unitTest().defineTestWithPassedInElement(TypeArgumentsTest.class, + (UnitTest) (processingEnvironment, element) -> { - try { - ToolingProvider.setTooling(processingEnvironment); + try { + ToolingProvider.setTooling(processingEnvironment); - List typeArgumentTypeMirrorWrappers = TypeMirrorWrapper.wrap(element.asType()).getWrappedTypeArguments(); - MatcherAssert.assertThat(typeArgumentTypeMirrorWrappers, Matchers.hasSize(2)); - MatcherAssert.assertThat(typeArgumentTypeMirrorWrappers.get(0).getQualifiedName(), Matchers.is(String.class.getCanonicalName())); - MatcherAssert.assertThat(typeArgumentTypeMirrorWrappers.get(1).getQualifiedName(), Matchers.is(Long.class.getCanonicalName())); + List typeArgumentTypeMirrorWrappers = TypeMirrorWrapper.wrap(element.asType()).getWrappedTypeArguments(); + assertThat(typeArgumentTypeMirrorWrappers, Matchers.hasSize(2)); + assertThat(typeArgumentTypeMirrorWrappers.get(0).getQualifiedName(), is(String.class.getCanonicalName())); + assertThat(typeArgumentTypeMirrorWrappers.get(1).getQualifiedName(), is(Long.class.getCanonicalName())); - // check for non typeArgument class - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.getEnclosingElement().asType()).getWrappedTypeArguments(), Matchers.nullValue()); + // check for non typeArgument class + assertThat(TypeMirrorWrapper.wrap(element.getEnclosingElement().asType()).getWrappedTypeArguments(), Matchers.nullValue()); - } finally { - ToolingProvider.clearTooling(); - } - } - }).executeTest(); + } finally { + ToolingProvider.clearTooling(); + } + }).executeTest(); } // --------------------------------------------------------------- @@ -592,14 +575,8 @@ public static class PackageTest { @Test public void test_getPackage() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(PackageTest.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getPackage(), Matchers.is(PackageTest.class.getPackage().getName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(PackageTest.class, + (UnitTest) (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getPackage(), is(PackageTest.class.getPackage().getName()))).executeTest(); } @@ -611,14 +588,8 @@ public static class PackageTestOfArray { @Test public void test_getPackageOfArray() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(PackageTestOfArray.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getPackage(), Matchers.is(PackageTest.class.getPackage().getName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(PackageTestOfArray.class, + (UnitTest) (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getPackage(), is(PackageTest.class.getPackage().getName()))).executeTest(); } public static class PackageTestOfPrimitive { @@ -629,14 +600,8 @@ public static class PackageTestOfPrimitive { @Test public void test_getPackageOfPrimitiveArray() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(PackageTestOfPrimitive.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getPackage(), Matchers.nullValue()); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(PackageTestOfPrimitive.class, + (UnitTest) (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getPackage(), Matchers.nullValue())).executeTest(); } // --------------------------------------------------------------- @@ -651,14 +616,8 @@ public static class GetTypeElement { @Test public void test_getTypeElement() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetTypeElement.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getTypeElement().get().getQualifiedName().toString(), Matchers.is(GetTypeElement.class.getCanonicalName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetTypeElement.class, + (UnitTest) (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getTypeElement().get().getQualifiedName().toString(), is(GetTypeElement.class.getCanonicalName()))).executeTest(); } @@ -669,14 +628,8 @@ public static class GetTypeElement_ofPrimitive { @Test public void test_getTypeElement_ofPrimitive() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetTypeElement_ofPrimitive.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, VariableElement element) { - - MatcherAssert.assertThat("Must return empty optional", !TypeMirrorWrapper.wrap(element.asType()).getTypeElement().isPresent()); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetTypeElement_ofPrimitive.class, + (UnitTest) (processingEnvironment, element) -> assertThat("Must return empty optional", !TypeMirrorWrapper.wrap(element.asType()).getTypeElement().isPresent())).executeTest(); } // --------------------------------------------------------------- @@ -699,38 +652,20 @@ public static class GetName_ofArray { @Test public void test_getSimpleName() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getSimpleName(), Matchers.is(GetName.class.getSimpleName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName.class, + (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getSimpleName(), is(GetName.class.getSimpleName()))).executeTest(); } @Test public void test_getSimpleName_ofPrimitive() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofPrimitive.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getSimpleName(), Matchers.is("long")); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofPrimitive.class, + (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getSimpleName(), is("long"))).executeTest(); } @Test public void test_getSimpleName_ofArray() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofArray.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getSimpleName(), Matchers.is(GetName.class.getSimpleName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofArray.class, + (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getSimpleName(), is(GetName.class.getSimpleName()))).executeTest(); } // --------------------------------------------------------------- @@ -739,38 +674,20 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen @Test public void test_getQualifiedName() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getQualifiedName(), Matchers.is(GetName.class.getCanonicalName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName.class, + (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getQualifiedName(), is(GetName.class.getCanonicalName()))).executeTest(); } @Test public void test_getQualifiedName_ofPrimitive() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofPrimitive.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getQualifiedName(), Matchers.is("long")); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofPrimitive.class, + (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getQualifiedName(), is("long"))).executeTest(); } @Test public void test_getQualifiedName_ofArray() { - CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofArray.class, new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - - MatcherAssert.assertThat(TypeMirrorWrapper.wrap(element.asType()).getQualifiedName(), Matchers.is(GetName.class.getCanonicalName())); - - } - }).executeTest(); + CompileTestBuilder.unitTest().defineTestWithPassedInElement(GetName_ofArray.class, + (processingEnvironment, element) -> assertThat(TypeMirrorWrapper.wrap(element.asType()).getQualifiedName(), is(GetName.class.getCanonicalName()))).executeTest(); } // --------------------------------------------------------------- @@ -791,7 +708,7 @@ static class MyChildClass extends MySuperClass { @Test public void test_assignability() { - CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { + CompileTestBuilder.unitTest().defineTest((processingEnvironment, element) -> { try { ToolingProvider.setTooling(processingEnvironment); @@ -801,28 +718,28 @@ public void test_assignability() { TypeMirrorWrapper nonMatching = TypeMirrorWrapper.wrap(String.class); // Check interface - MatcherAssert.assertThat("Should be assignable", myInterface.isAssignableFrom(superClass)); - MatcherAssert.assertThat("Should be assignable", myInterface.isAssignableFrom(childClass)); - MatcherAssert.assertThat("Shouldn't be assignable", !myInterface.isAssignableFrom(nonMatching)); - MatcherAssert.assertThat("Should be assignable", !myInterface.isAssignableTo(superClass)); - MatcherAssert.assertThat("Should be assignable", !myInterface.isAssignableTo(childClass)); - MatcherAssert.assertThat("Shouldn't be assignable", !myInterface.isAssignableTo(nonMatching)); + assertThat("Should be assignable", myInterface.isAssignableFrom(superClass)); + assertThat("Should be assignable", myInterface.isAssignableFrom(childClass)); + assertThat("Shouldn't be assignable", !myInterface.isAssignableFrom(nonMatching)); + assertThat("Should be assignable", !myInterface.isAssignableTo(superClass)); + assertThat("Should be assignable", !myInterface.isAssignableTo(childClass)); + assertThat("Shouldn't be assignable", !myInterface.isAssignableTo(nonMatching)); // Check superclass - MatcherAssert.assertThat("Should be assignable", superClass.isAssignableFrom(childClass)); - MatcherAssert.assertThat("Shouldn't be assignable", !superClass.isAssignableFrom(myInterface)); - MatcherAssert.assertThat("Shouldn't be assignable", !superClass.isAssignableFrom(nonMatching)); - MatcherAssert.assertThat("Should be assignable", superClass.isAssignableTo(myInterface)); - MatcherAssert.assertThat("Shoulddn't be assignable", !superClass.isAssignableTo(childClass)); - MatcherAssert.assertThat("Shouldn't be assignable", !superClass.isAssignableTo(nonMatching)); + assertThat("Should be assignable", superClass.isAssignableFrom(childClass)); + assertThat("Shouldn't be assignable", !superClass.isAssignableFrom(myInterface)); + assertThat("Shouldn't be assignable", !superClass.isAssignableFrom(nonMatching)); + assertThat("Should be assignable", superClass.isAssignableTo(myInterface)); + assertThat("Shouldn't be assignable", !superClass.isAssignableTo(childClass)); + assertThat("Shouldn't be assignable", !superClass.isAssignableTo(nonMatching)); // Check childclass - MatcherAssert.assertThat("Shoulddn't be assignable", !childClass.isAssignableFrom(superClass)); - MatcherAssert.assertThat("Shouldn't be assignable", !childClass.isAssignableFrom(myInterface)); - MatcherAssert.assertThat("Shouldn't be assignable", !childClass.isAssignableFrom(nonMatching)); - MatcherAssert.assertThat("Should be assignable", childClass.isAssignableTo(myInterface)); - MatcherAssert.assertThat("Should be assignable", childClass.isAssignableTo(superClass)); - MatcherAssert.assertThat("Shouldn't be assignable", !childClass.isAssignableTo(nonMatching)); + assertThat("Shouldn't be assignable", !childClass.isAssignableFrom(superClass)); + assertThat("Shouldn't be assignable", !childClass.isAssignableFrom(myInterface)); + assertThat("Shouldn't be assignable", !childClass.isAssignableFrom(nonMatching)); + assertThat("Should be assignable", childClass.isAssignableTo(myInterface)); + assertThat("Should be assignable", childClass.isAssignableTo(superClass)); + assertThat("Shouldn't be assignable", !childClass.isAssignableTo(nonMatching)); } finally { ToolingProvider.clearTooling(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtilsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtilsTest.java index ddc92f1d..141e0aff 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtilsTest.java @@ -1,15 +1,19 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; +import io.toolisticon.cute.UnitTest; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -29,7 +33,7 @@ public class TypeUtilsTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -41,18 +45,22 @@ public void init() { @Test public void typeUtils_typeRetrieval_getTypeElement_GetTypeElementForClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - MatcherAssert.assertThat(typeElement, Matchers.notNullValue()); - MatcherAssert.assertThat(typeElement.getSimpleName().toString(), Matchers.is(AbstractUnitTestAnnotationProcessorClass.class.getSimpleName())); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - } - }) + MatcherAssert.assertThat(typeElement, Matchers.notNullValue()); + MatcherAssert.assertThat(typeElement.getSimpleName().toString(), Matchers.is(AbstractUnitTestAnnotationProcessorClass.class.getSimpleName())); + + + } + } + ) .compilationShouldSucceed() .executeTest(); } @@ -60,17 +68,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_GetTypeElementForArrayClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(String[].class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(String[].class); - MatcherAssert.assertThat("An array TypeMirror can't be converted into a TypeElement so result has to be null", typeElement, Matchers.nullValue()); + MatcherAssert.assertThat("An array TypeMirror can't be converted into a TypeElement so result has to be null", typeElement, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -78,17 +87,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_GetTypeElementForTypeMirror() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(element.asType()); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(element.asType()); - MatcherAssert.assertThat(typeElement, Matchers.notNullValue()); - MatcherAssert.assertThat(typeElement.getSimpleName().toString(), Matchers.is("AnnotationProcessorTestClass")); + MatcherAssert.assertThat(typeElement, Matchers.notNullValue()); + MatcherAssert.assertThat(typeElement.getSimpleName().toString(), Matchers.is("AnnotationProcessorTestClass")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -96,15 +106,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_GetTypeElementForNullValuedTypeMirror() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement((TypeMirror) null); - MatcherAssert.assertThat(typeElement, Matchers.nullValue()); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement((TypeMirror) null); + MatcherAssert.assertThat(typeElement, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -112,15 +123,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_GetTypeElementForPrimitiveTypeClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(int.class); - MatcherAssert.assertThat("A primitive TypeMirror can't be converted into a TypeElement so result has to be null", typeElement, Matchers.nullValue()); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(int.class); + MatcherAssert.assertThat("A primitive TypeMirror can't be converted into a TypeElement so result has to be null", typeElement, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -128,17 +140,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_GetTypeMirrorForClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(AbstractUnitTestAnnotationProcessorClass.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(AbstractUnitTestAnnotationProcessorClass.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.DECLARED)); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.DECLARED)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -146,19 +159,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_GetTypeMirrorForArrayClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); - MatcherAssert.assertThat(((ArrayType) typeMirror).getComponentType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + MatcherAssert.assertThat(((ArrayType) typeMirror).getComponentType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -166,16 +180,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror((Class) null); - MatcherAssert.assertThat("Should return null for null valued input parameter", typeMirror, Matchers.nullValue()); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror((Class) null); + MatcherAssert.assertThat("Should return null for null valued input parameter", typeMirror, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -183,18 +198,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_getTypeMirrorForPrimitive() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(int.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(int.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.INT)); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.INT)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -202,18 +218,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForInt() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // int - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(int.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.INT)); + // int + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(int.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.INT)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -221,18 +238,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForLong() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // long - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(long.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.LONG)); + // long + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(long.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.LONG)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -240,18 +258,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForShort() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // short - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(short.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.SHORT)); + // short + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(short.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.SHORT)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -259,18 +278,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForBoolean() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // boolean - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(boolean.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.BOOLEAN)); + // boolean + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(boolean.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.BOOLEAN)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -278,18 +298,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForByte() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // byte - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(byte.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.BYTE)); + // byte + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(byte.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.BYTE)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -297,18 +318,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForFloat() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // float - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(float.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.FLOAT)); + // float + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(float.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.FLOAT)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -316,18 +338,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForDouble() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // double - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(double.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.DOUBLE)); + // double + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(double.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.DOUBLE)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -336,18 +359,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForChar() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // char - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(char.class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.CHAR)); + // char + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(char.class); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.CHAR)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -355,17 +379,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForNullValue_shouldReturnNull() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // null value - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(null); - MatcherAssert.assertThat(typeMirror, Matchers.nullValue()); + // null value + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(null); + MatcherAssert.assertThat(typeMirror, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -373,17 +398,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getPrimitiveTypeMirror_getTypeMirrorForNonPrimitiveType_shouldReturnNull() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // non primitive type value - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(String.class); - MatcherAssert.assertThat(typeMirror, Matchers.nullValue()); + // non primitive type value + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getPrimitiveTypeMirror(String.class); + MatcherAssert.assertThat(typeMirror, Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -391,19 +417,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_getTypeMirrorOfArray() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); - MatcherAssert.assertThat(((ArrayType) typeMirror).getComponentType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat(typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat(typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + MatcherAssert.assertThat(((ArrayType) typeMirror).getComponentType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -411,14 +438,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypes_getEncapsulatedTypesInstance() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.getTypes(), Matchers.notNullValue()); + MatcherAssert.assertThat(TypeUtils.getTypes(), Matchers.notNullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -426,14 +454,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_testToGetElementByClassName() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement("io.toolisticon.annotationprocessor.AnnotationProcessorTestClass"), Matchers.is(element)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement("io.toolisticon.annotationprocessor.AnnotationProcessorTestClass"), Matchers.is(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -441,14 +470,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_testBehaviorWithNonExistingClassNameParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement("io.toolisticon.annotationprocessor.AnnotationProcessorTestClassXXXX"), Matchers.nullValue()); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement("io.toolisticon.annotationprocessor.AnnotationProcessorTestClassXXXX"), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -456,14 +486,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_testBehaviorWithNullValuedClassNameParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement((String) null), - Matchers.nullValue()); - } - }) + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement((String) null), + Matchers.nullValue()); + } + }) .compilationShouldSucceed() .executeTest(); } @@ -471,22 +502,23 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_testToGetTypeMirrorByClassName() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("io.toolisticon.annotationprocessor.AnnotationProcessorTestClass"), Matchers.is(element.asType())); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("int").getKind(), Matchers.is(TypeKind.INT)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("long").getKind(), Matchers.is(TypeKind.LONG)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("short").getKind(), Matchers.is(TypeKind.SHORT)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("float").getKind(), Matchers.is(TypeKind.FLOAT)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("double").getKind(), Matchers.is(TypeKind.DOUBLE)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("byte").getKind(), Matchers.is(TypeKind.BYTE)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("boolean").getKind(), Matchers.is(TypeKind.BOOLEAN)); - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("char").getKind(), Matchers.is(TypeKind.CHAR)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("io.toolisticon.annotationprocessor.AnnotationProcessorTestClass"), Matchers.is(element.asType())); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("int").getKind(), Matchers.is(TypeKind.INT)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("long").getKind(), Matchers.is(TypeKind.LONG)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("short").getKind(), Matchers.is(TypeKind.SHORT)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("float").getKind(), Matchers.is(TypeKind.FLOAT)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("double").getKind(), Matchers.is(TypeKind.DOUBLE)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("byte").getKind(), Matchers.is(TypeKind.BYTE)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("boolean").getKind(), Matchers.is(TypeKind.BOOLEAN)); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("char").getKind(), Matchers.is(TypeKind.CHAR)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -494,14 +526,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_testBehaviorWithNonExistingClassNameParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("io.toolisticon.annotationprocessor.AnnotationProcessorTestClassXXXX"), Matchers.nullValue()); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror("io.toolisticon.annotationprocessor.AnnotationProcessorTestClassXXXX"), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -510,14 +543,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeMirror_testBehaviorWithNullValuedClassNameParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror((String) null), Matchers.nullValue()); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeMirror((String) null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -525,22 +559,23 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_typeRetrieval_getTypeElement_testBehaviorWithAnonymousClassTypeMirror_shouldReturnNullBecauseNoTypeElementExists() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Comparable anonymousComparable = new Comparable() { - @Override - public int compareTo(Long o) { - return 0; - } - }; + Comparable anonymousComparable = new Comparable() { + @Override + public int compareTo(Long o) { + return 0; + } + }; - MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement(anonymousComparable.getClass()), Matchers.nullValue()); + MatcherAssert.assertThat(TypeUtils.TypeRetrieval.getTypeElement(anonymousComparable.getClass()), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -548,20 +583,21 @@ public int compareTo(Long o) { @Test public void typeUtils_Arrays_getArraysComponentType_getComponentTypeOfTypeMirrorString() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); - MatcherAssert.assertThat(TypeUtils.Arrays.getArraysComponentType(typeMirror), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat(TypeUtils.Arrays.getArraysComponentType(typeMirror), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -569,21 +605,22 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_isArrayOfType_shouldCheckIfTheTypeMirrorHasASpecificComponentTypeCorrectly_byType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); - MatcherAssert.assertThat("Should detect matching component type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class)); - MatcherAssert.assertThat("Should detect non matching component type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, Boolean.class)); + MatcherAssert.assertThat("Should detect matching component type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class)); + MatcherAssert.assertThat("Should detect non matching component type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, Boolean.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -591,20 +628,22 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_isArrayOfType_shouldCheckIfTheTypeMirrorHasASpecificComponentTypeCorrectly_byCanonicalClassName() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect matching component type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class.getCanonicalName())); - MatcherAssert.assertThat("Should detect non matching component type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, Boolean.class.getCanonicalName())); + MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + MatcherAssert.assertThat("Should detect matching component type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class.getCanonicalName())); + MatcherAssert.assertThat("Should detect non matching component type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, Boolean.class.getCanonicalName())); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -612,20 +651,22 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_isArrayOfType_shouldCheckIfTheTypeMirrorHasASpecificComponentTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); + MatcherAssert.assertThat("PRECONDITION : typeMirror should not be null", typeMirror, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : typeMirror should be array", typeMirror.getKind(), Matchers.is(TypeKind.ARRAY)); - MatcherAssert.assertThat("Should detect matching component type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - MatcherAssert.assertThat("Should detect non matching component type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class))); + MatcherAssert.assertThat("Should detect matching component type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat("Should detect non matching component type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -633,15 +674,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_getArraysComponentType_testIfComponentTypeOfTypeMirrorOfkindArrayIsReturnedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror input = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat(TypeUtils.Arrays.getArraysComponentType(input), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + TypeMirror input = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat(TypeUtils.Arrays.getArraysComponentType(input), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -649,15 +691,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETM_isAssignableTo_Type() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, Object.class)); - MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, InputStream.class)); + MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, Object.class)); + MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, InputStream.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -665,15 +708,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETM_isAssignableTo_TypeElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeElement(Object.class))); - MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeElement(InputStream.class))); + MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeElement(Object.class))); + MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeElement(InputStream.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -681,15 +725,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETM_isAssignableTo_Class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, Object.class)); - MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, InputStream.class)); + MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, Object.class)); + MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, InputStream.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -697,15 +742,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETM_isAssignableTo_TypeMirror() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeMirror(Object.class))); - MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeMirror(InputStream.class))); + MatcherAssert.assertThat("type element should be detected as assignable to Object", TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeMirror(Object.class))); + MatcherAssert.assertThat("type element shouldn't be detected as assignable to InputStream", !TypeUtils.TypeComparison.isAssignableTo(element, TypeUtils.TypeRetrieval.getTypeMirror(InputStream.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -714,14 +760,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETM_isAssignableTo_nullValuedTypeElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("should return false for null valued type element", !TypeUtils.TypeComparison.isAssignableTo((TypeElement) null, TypeUtils.TypeRetrieval.getTypeMirror(Object.class))); + MatcherAssert.assertThat("should return false for null valued type element", !TypeUtils.TypeComparison.isAssignableTo((TypeElement) null, TypeUtils.TypeRetrieval.getTypeMirror(Object.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -729,16 +776,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMCL_isAssignableTo_nullValuedTypeMirrors() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("should return false for null valued type mirror", !TypeUtils.TypeComparison.isAssignableTo((TypeMirror) null, TypeUtils.TypeRetrieval.getTypeMirror(Object.class))); - MatcherAssert.assertThat("should return false for null valued type mirror", !TypeUtils.TypeComparison.isAssignableTo(TypeUtils.TypeRetrieval.getTypeMirror(Object.class), (TypeMirror) null)); - MatcherAssert.assertThat("should return false for null valued type mirror", !TypeUtils.TypeComparison.isAssignableTo((TypeMirror) null, (TypeMirror) null)); + MatcherAssert.assertThat("should return false for null valued type mirror", !TypeUtils.TypeComparison.isAssignableTo((TypeMirror) null, TypeUtils.TypeRetrieval.getTypeMirror(Object.class))); + MatcherAssert.assertThat("should return false for null valued type mirror", !TypeUtils.TypeComparison.isAssignableTo(TypeUtils.TypeRetrieval.getTypeMirror(Object.class), (TypeMirror) null)); + MatcherAssert.assertThat("should return false for null valued type mirror", !TypeUtils.TypeComparison.isAssignableTo((TypeMirror) null, (TypeMirror) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -746,18 +794,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_CLTE_isTypeEqual_matchingByType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); + Class type = StringBuilder.class; + TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); - MatcherAssert.assertThat("Should have found match", TypeUtils.TypeComparison.isTypeEqual(elementForComparison, type)); + MatcherAssert.assertThat("Should have found match", TypeUtils.TypeComparison.isTypeEqual(elementForComparison, type)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -766,17 +815,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_CLTE_isTypeEqual_mismatchingByType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); + Class type = StringBuilder.class; + TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); - MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, String.class)); + MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -784,19 +834,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_CLTE_isTypeEqual_nullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); + Class type = StringBuilder.class; + TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); - MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, String.class)); - MatcherAssert.assertThat("Should return false for null valued class", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, (Class) null)); - MatcherAssert.assertThat("Should return false for null valued type element and class", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, (Class) null)); + MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, String.class)); + MatcherAssert.assertThat("Should return false for null valued class", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, (Class) null)); + MatcherAssert.assertThat("Should return false for null valued type element and class", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, (Class) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -804,20 +855,21 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMTE_isTypeEqual_testIfMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(type); - TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); + Class type = StringBuilder.class; + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(type); + TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); - MatcherAssert.assertThat("Shouldn't have found match", TypeUtils.TypeComparison.isTypeEqual(elementForComparison, typeMirror)); + MatcherAssert.assertThat("Shouldn't have found match", TypeUtils.TypeComparison.isTypeEqual(elementForComparison, typeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -825,19 +877,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMTE_isTypeEqual_testIfNonMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); + Class type = StringBuilder.class; + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); - MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, typeMirror)); + MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, typeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -845,21 +898,22 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMTE_isTypeEqual_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); + Class type = StringBuilder.class; + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + TypeElement elementForComparison = TypeUtils.TypeRetrieval.getTypeElement(type); - MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, typeMirror)); - MatcherAssert.assertThat("Should return false for null valued type mirror", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, (TypeMirror) null)); - MatcherAssert.assertThat("Should return false for null valued type element and type mirror", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, typeMirror)); + MatcherAssert.assertThat("Should return false for null valued type mirror", !TypeUtils.TypeComparison.isTypeEqual(elementForComparison, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false for null valued type element and type mirror", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, (TypeMirror) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -867,18 +921,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETE_isTypeEqual_testIfMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement1 = TypeUtils.TypeRetrieval.getTypeElement(String.class); - TypeElement typeElement2 = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement typeElement1 = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement typeElement2 = TypeUtils.TypeRetrieval.getTypeElement(String.class); - MatcherAssert.assertThat("Should have found match", TypeUtils.TypeComparison.isTypeEqual(typeElement1, typeElement2)); + MatcherAssert.assertThat("Should have found match", TypeUtils.TypeComparison.isTypeEqual(typeElement1, typeElement2)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -886,17 +941,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETE_isTypeEqual_testIfNonMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement1 = TypeUtils.TypeRetrieval.getTypeElement(String.class); - TypeElement typeElement2 = TypeUtils.TypeRetrieval.getTypeElement(Boolean.class); + TypeElement typeElement1 = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement typeElement2 = TypeUtils.TypeRetrieval.getTypeElement(Boolean.class); - MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(typeElement1, typeElement2)); + MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(typeElement1, typeElement2)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -904,19 +960,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TETE_isTypeEqual_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement1 = TypeUtils.TypeRetrieval.getTypeElement(String.class); - TypeElement typeElement2 = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement typeElement1 = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement typeElement2 = TypeUtils.TypeRetrieval.getTypeElement(String.class); - MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, typeElement2)); - MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual(typeElement1, (TypeElement) null)); - MatcherAssert.assertThat("Should return false for null valued type elements", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, (TypeElement) null)); + MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, typeElement2)); + MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual(typeElement1, (TypeElement) null)); + MatcherAssert.assertThat("Should return false for null valued type elements", !TypeUtils.TypeComparison.isTypeEqual((TypeElement) null, (TypeElement) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -924,19 +981,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMTM_isTypeEqual_testIfMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Class type = StringBuilder.class; - TypeMirror typeMirror1 = TypeUtils.TypeRetrieval.getTypeMirror(type); - TypeMirror typeMirror2 = TypeUtils.TypeRetrieval.getTypeMirror(type); + Class type = StringBuilder.class; + TypeMirror typeMirror1 = TypeUtils.TypeRetrieval.getTypeMirror(type); + TypeMirror typeMirror2 = TypeUtils.TypeRetrieval.getTypeMirror(type); - MatcherAssert.assertThat("Shouldn't have found match", TypeUtils.TypeComparison.isTypeEqual(typeMirror1, typeMirror2)); + MatcherAssert.assertThat("Shouldn't have found match", TypeUtils.TypeComparison.isTypeEqual(typeMirror1, typeMirror2)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -944,17 +1002,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMTM_isTypeEqual_testIfNonMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror1 = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - TypeMirror typeMirror2 = TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class); + TypeMirror typeMirror1 = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + TypeMirror typeMirror2 = TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class); - MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(typeMirror1, typeMirror2)); + MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(typeMirror1, typeMirror2)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -962,19 +1021,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMTM_isTypeEqual_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror1 = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - TypeMirror typeMirror2 = TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class); + TypeMirror typeMirror1 = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + TypeMirror typeMirror2 = TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class); - MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, typeMirror2)); - MatcherAssert.assertThat("Should return false for null valued type mirror", !TypeUtils.TypeComparison.isTypeEqual(typeMirror1, (TypeMirror) null)); - MatcherAssert.assertThat("Should return false for null valued type element and class", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false for null valued type element", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, typeMirror2)); + MatcherAssert.assertThat("Should return false for null valued type mirror", !TypeUtils.TypeComparison.isTypeEqual(typeMirror1, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false for null valued type element and class", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, (TypeMirror) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -982,15 +1042,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMCL_isTypeEqual_testIfMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); - MatcherAssert.assertThat("Should have found match", TypeUtils.TypeComparison.isTypeEqual(typeMirror, StringBuilder.class)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); + MatcherAssert.assertThat("Should have found match", TypeUtils.TypeComparison.isTypeEqual(typeMirror, StringBuilder.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -998,16 +1059,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMCL_isTypeEqual_testIfNonMatchingClassIsDetectedCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); - MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(typeMirror, String.class)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); + MatcherAssert.assertThat("Shouldn't have found match", !TypeUtils.TypeComparison.isTypeEqual(typeMirror, String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1015,19 +1077,20 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_TypeComparison_TMCL_isTypeEqual_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); - MatcherAssert.assertThat("Should return false for null valued type mirror", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, String.class)); - MatcherAssert.assertThat("Should return false for null valued class", !TypeUtils.TypeComparison.isTypeEqual(typeMirror, (Class) null)); - MatcherAssert.assertThat("Should return false for null valued type mirror and class", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, (Class) null)); + MatcherAssert.assertThat("Should return false for null valued type mirror", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, String.class)); + MatcherAssert.assertThat("Should return false for null valued class", !TypeUtils.TypeComparison.isTypeEqual(typeMirror, (Class) null)); + MatcherAssert.assertThat("Should return false for null valued type mirror and class", !TypeUtils.TypeComparison.isTypeEqual((TypeMirror) null, (Class) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1035,16 +1098,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_CheckTypeKind_isVoid_testForVoidType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat(TypeUtils.CheckTypeKind.isVoid(ElementUtils.CastElement.castMethod(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod").get(0)).getReturnType()), Matchers.is(true)); - MatcherAssert.assertThat(TypeUtils.CheckTypeKind.isVoid(element.asType()), Matchers.is(false)); + MatcherAssert.assertThat(TypeUtils.CheckTypeKind.isVoid(ElementUtils.CastElement.castMethod(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod").get(0)).getReturnType()), Matchers.is(true)); + MatcherAssert.assertThat(TypeUtils.CheckTypeKind.isVoid(element.asType()), Matchers.is(false)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1052,33 +1116,34 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_shouldBeAbleToCompareGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - MatcherAssert.assertThat("Should be equal and therefore true", - TypeUtils.Generics.genericTypeEquals( - method.getParameters().get(0).asType(), - TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createGenericType(Long.class) + MatcherAssert.assertThat("Should be equal and therefore true", + TypeUtils.Generics.genericTypeEquals( + method.getParameters().get(0).asType(), + TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createGenericType(Long.class) + ) + ) ) - ) - ) - ); + ); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1086,32 +1151,33 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_shouldNotBeAbleToCompareGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - MatcherAssert.assertThat("Should be equal and therefore true", - !TypeUtils.Generics.genericTypeEquals( - method.getParameters().get(0).asType(), - TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createGenericType(Double.class) + MatcherAssert.assertThat("Should be equal and therefore true", + !TypeUtils.Generics.genericTypeEquals( + method.getParameters().get(0).asType(), + TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createGenericType(Double.class) + ) + ) ) - ) - ) - ); + ); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1119,42 +1185,43 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_shouldBeAbleToCompareGenericTypeWithWildcards() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Map>> + // Map>> - MatcherAssert.assertThat("Should be equal and therefore true", - TypeUtils.Generics.genericTypeEquals( - method.getParameters().get(1).asType(), - TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(StringBuilder.class) - ), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithSuperBound( + MatcherAssert.assertThat("Should be equal and therefore true", + TypeUtils.Generics.genericTypeEquals( + method.getParameters().get(1).asType(), + TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(StringBuilder.class) + ), TypeUtils.Generics.createGenericType( - List.class, - TypeUtils.Generics.createPureWildcard() + Comparator.class, + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + List.class, + TypeUtils.Generics.createPureWildcard() + ) + ) + ) ) - ) - ) - ) - ); + ); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1162,43 +1229,44 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_shouldNotBeAbleToCompareGenericTypeWithWildcards() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Map>> + // Map>> - MatcherAssert.assertThat("Should be equal and therefore true", - !TypeUtils.Generics.genericTypeEquals( - method.getParameters().get(1).asType(), - TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(StringBuilder.class) - ), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithSuperBound( + MatcherAssert.assertThat("Should be equal and therefore true", + !TypeUtils.Generics.genericTypeEquals( + method.getParameters().get(1).asType(), + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(StringBuilder.class) + ), TypeUtils.Generics.createGenericType( - List.class, - TypeUtils.Generics.createWildcardWithExtendsBound(TypeUtils.Generics.createGenericType(String.class)) + Comparator.class, + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + List.class, + TypeUtils.Generics.createWildcardWithExtendsBound(TypeUtils.Generics.createGenericType(String.class)) + ) + ) + ) ) - ) - ) - ) - ); + ); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1212,16 +1280,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_isArray_detectArrayCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect array correctly", TypeUtils.Arrays.isArray(typeMirror)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat("Should detect array correctly", TypeUtils.Arrays.isArray(typeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1229,16 +1298,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_isArray_detectNonArrayCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArray(typeMirror)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArray(typeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1246,14 +1316,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_isArray_handleNullValueCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArray(null)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArray(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1261,15 +1332,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_getArraysComponentType_detectArraysComponentTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect array correctly", TypeUtils.Arrays.getArraysComponentType(typeMirror), Matchers.equalTo(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat("Should detect array correctly", TypeUtils.Arrays.getArraysComponentType(typeMirror), Matchers.equalTo(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1278,15 +1350,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_getArraysComponentType_detectForNonArraysCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should detect non array correctly", TypeUtils.Arrays.getArraysComponentType(typeMirror), Matchers.nullValue()); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should detect non array correctly", TypeUtils.Arrays.getArraysComponentType(typeMirror), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1294,14 +1367,15 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_getArraysComponentType_nullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null value", TypeUtils.Arrays.getArraysComponentType(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should return false for null value", TypeUtils.Arrays.getArraysComponentType(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1313,15 +1387,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMCL_isArrayOfType_detectMatchingArrayTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect matching array correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat("Should detect matching array correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1329,15 +1404,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMCL_isArrayOfType_detectMismatchingArrayTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect mismatching array type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, StringBuilder.class)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat("Should detect mismatching array type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, StringBuilder.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1345,15 +1421,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMCL_isArrayOfType_handleNonArrayTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, String.class)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1361,17 +1438,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMCLisArrayOfType_handleNullValueCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType(typeMirror, (Class) null)); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, String.class)); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, (Class) null)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType(typeMirror, (Class) null)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, String.class)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, (Class) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1382,15 +1460,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMSTR_isArrayOfType_detectMatchingArrayTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect matching array correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class.getCanonicalName())); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat("Should detect matching array correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1398,15 +1477,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMSTR_isArrayOfType_detectMismatchingArrayTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect mismatching array type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, StringBuilder.class.getCanonicalName())); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + MatcherAssert.assertThat("Should detect mismatching array type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, StringBuilder.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1414,15 +1494,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMSTR_isArrayOfType_handleNonArrayTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, String.class.getCanonicalName())); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1430,17 +1511,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMSTR_isArrayOfType_handleNullValueCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType(typeMirror, (String) null)); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, String.class.getCanonicalName())); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, (String) null)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType(typeMirror, (String) null)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, String.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, (String) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1451,17 +1533,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isArrayOfType_detectMatchingArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, componentTypeMirror)); + MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayOfType(typeMirror, componentTypeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1469,17 +1552,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isArrayOfType_detectMismatchingArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(StringBuilder.class); - MatcherAssert.assertThat("Should detect mismatching array type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, componentTypeMirror)); + MatcherAssert.assertThat("Should detect mismatching array type correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, componentTypeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1487,15 +1571,16 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isArrayOfType_handleNonArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, typeMirror)); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + MatcherAssert.assertThat("Should detect non array correctly", !TypeUtils.Arrays.isArrayOfType(typeMirror, typeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1503,18 +1588,19 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isArrayOfType_handleNullValuesCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String.class); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType(typeMirror, (TypeMirror) null)); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, typeMirror)); - MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType(typeMirror, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, typeMirror)); + MatcherAssert.assertThat("Should return false for null value", !TypeUtils.Arrays.isArrayOfType((TypeMirror) null, (TypeMirror) null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1522,16 +1608,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMCL_isArrayOfType_detectAssignableArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayAssignableTo(typeMirror, Object.class)); + MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayAssignableTo(typeMirror, Object.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1539,16 +1626,17 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMSTR_isArrayOfType_detectAssignableArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayAssignableTo(typeMirror, Object.class.getCanonicalName())); + MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayAssignableTo(typeMirror, Object.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1556,17 +1644,18 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isArrayOfType_detectAssignableArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); - TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(Object.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(String[].class); + TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(Object.class); - MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayAssignableTo(typeMirror, componentTypeMirror)); + MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isArrayAssignableTo(typeMirror, componentTypeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1574,23 +1663,24 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isErasedArrayAssignableTo_detectAssignableArraysTypeCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(List[].class); - TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(Collection.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(List[].class); + TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(Collection.class); - MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isErasedArrayAssignableTo(typeMirror, componentTypeMirror)); + MatcherAssert.assertThat("Should detect matching array type correctly", TypeUtils.Arrays.isErasedArrayAssignableTo(typeMirror, componentTypeMirror)); - // null safety - MatcherAssert.assertThat("Should return false if first typeMirror is null", !TypeUtils.Arrays.isErasedArrayAssignableTo(null, componentTypeMirror)); - MatcherAssert.assertThat("Should return false if second typeMirror is null", !TypeUtils.Arrays.isErasedArrayAssignableTo(typeMirror, null)); - MatcherAssert.assertThat("Should return false if both typeMirror is null", !TypeUtils.Arrays.isErasedArrayAssignableTo(null, null)); + // null safety + MatcherAssert.assertThat("Should return false if first typeMirror is null", !TypeUtils.Arrays.isErasedArrayAssignableTo(null, componentTypeMirror)); + MatcherAssert.assertThat("Should return false if second typeMirror is null", !TypeUtils.Arrays.isErasedArrayAssignableTo(typeMirror, null)); + MatcherAssert.assertThat("Should return false if both typeMirror is null", !TypeUtils.Arrays.isErasedArrayAssignableTo(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1598,22 +1688,23 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Arrays_TMTM_isArrayAssignableTo_checkNullSafetyAndNonArrayTM() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(List[].class); - TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(Collection.class); + TypeMirror typeMirror = TypeUtils.TypeRetrieval.getTypeMirror(List[].class); + TypeMirror componentTypeMirror = TypeUtils.TypeRetrieval.getTypeMirror(Collection.class); - MatcherAssert.assertThat("Should return false if typeMirror is null", !TypeUtils.Arrays.isArrayAssignableTo(null, componentTypeMirror)); - MatcherAssert.assertThat("Should return false if componentType is null", !TypeUtils.Arrays.isArrayAssignableTo(typeMirror, (TypeMirror) null)); - MatcherAssert.assertThat("Should return false if both typeMirror and componentType are null", !TypeUtils.Arrays.isArrayAssignableTo(null, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false if typeMirror is null", !TypeUtils.Arrays.isArrayAssignableTo(null, componentTypeMirror)); + MatcherAssert.assertThat("Should return false if componentType is null", !TypeUtils.Arrays.isArrayAssignableTo(typeMirror, (TypeMirror) null)); + MatcherAssert.assertThat("Should return false if both typeMirror and componentType are null", !TypeUtils.Arrays.isArrayAssignableTo(null, (TypeMirror) null)); - MatcherAssert.assertThat("Should return for non array typeMirror", !TypeUtils.Arrays.isArrayAssignableTo(TypeUtils.TypeRetrieval.getTypeMirror(List.class), componentTypeMirror)); + MatcherAssert.assertThat("Should return for non array typeMirror", !TypeUtils.Arrays.isArrayAssignableTo(TypeUtils.TypeRetrieval.getTypeMirror(List.class), componentTypeMirror)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtils_GenericsTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtils_GenericsTest.java index 642c3280..1ac0e209 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtils_GenericsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/TypeUtils_GenericsTest.java @@ -1,17 +1,20 @@ package io.toolisticon.aptk.tools; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.generics.GenericType; import io.toolisticon.aptk.tools.generics.GenericTypeKind; import io.toolisticon.aptk.tools.generics.GenericTypeWildcard; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -30,7 +33,7 @@ public class TypeUtils_GenericsTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/GenericsTestClass.java")); @@ -43,20 +46,22 @@ public void init() { @Test public void typeUtils_Generics_createGenericType_simpleNonGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType(String.class); - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat("Should have 0 type parameters", genericType.getTypeParameters().length == 0); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType(String.class); + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat("Should have 0 type parameters", genericType.getTypeParameters().length == 0); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -64,20 +69,21 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_createGenericType_simpleNonGenericType2() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType(String.class.getCanonicalName()); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType(String.class.getCanonicalName()); - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat("Should have 0 type parameters", genericType.getTypeParameters().length == 0); + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat("Should have 0 type parameters", genericType.getTypeParameters().length == 0); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -85,25 +91,26 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_createGenericType_simpleGenericTypeWithOneParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Collection.class, - TypeUtils.Generics.createGenericType(String.class) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Collection.class, + TypeUtils.Generics.createGenericType(String.class) + ); - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); - MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); - MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[0]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); + MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); + MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[0]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -111,24 +118,25 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_createGenericType_simpleGenericTypeWithOnePureWildcardTypeParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Collection.class, - TypeUtils.Generics.createPureWildcard() - ); - - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); - MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); - MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); - MatcherAssert.assertThat("Type parameter shoulb be pure wildcard", ((GenericTypeWildcard) genericType.getTypeParameters()[0]).isPureWildcard()); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Collection.class, + TypeUtils.Generics.createPureWildcard() + ); + + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); + MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); + MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); + MatcherAssert.assertThat("Type parameter shoulb be pure wildcard", ((GenericTypeWildcard) genericType.getTypeParameters()[0]).isPureWildcard()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -136,27 +144,28 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_createGenericType_simpleGenericTypeWithOneExtendsWildcardTypeParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Collection.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(String.class) - ) - ); - - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); - MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); - MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); - MatcherAssert.assertThat("Type parameter should be extends bound wildcard", ((GenericTypeWildcard) genericType.getTypeParameters()[0]).hasExtendsBound()); - MatcherAssert.assertThat(((GenericTypeWildcard) genericType.getTypeParameters()[0]).getExtendsBound().getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Collection.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(String.class) + ) + ); + + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); + MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); + MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); + MatcherAssert.assertThat("Type parameter should be extends bound wildcard", ((GenericTypeWildcard) genericType.getTypeParameters()[0]).hasExtendsBound()); + MatcherAssert.assertThat(((GenericTypeWildcard) genericType.getTypeParameters()[0]).getExtendsBound().getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -164,27 +173,28 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_createGenericType_simpleGenericTypeWithOneSuperWildcardTypeParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Collection.class, - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType(String.class) - ) - ); - - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); - MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); - MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); - MatcherAssert.assertThat("Type parameter should be super bound wildcard", ((GenericTypeWildcard) genericType.getTypeParameters()[0]).hasSuperBound()); - MatcherAssert.assertThat(((GenericTypeWildcard) genericType.getTypeParameters()[0]).getSuperBound().getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Collection.class, + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType(String.class) + ) + ); + + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Collection.class))); + MatcherAssert.assertThat(genericType.getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat("Should have 1 type parameters", genericType.getTypeParameters().length == 1); + MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); + MatcherAssert.assertThat("Type parameter should be super bound wildcard", ((GenericTypeWildcard) genericType.getTypeParameters()[0]).hasSuperBound()); + MatcherAssert.assertThat(((GenericTypeWildcard) genericType.getTypeParameters()[0]).getSuperBound().getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -192,41 +202,42 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_createGenericType_morComplexGenericTypeWithTwoTypeParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createWildcardWithExtendsBound(TypeUtils.Generics.createGenericType(String.class)), - TypeUtils.Generics.createGenericType(String.class) - ) - ); - - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Map.class))); - MatcherAssert.assertThat("Should have 2 type parameters", genericType.getTypeParameters().length == 2); - MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[0]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - - MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Map.class))); - MatcherAssert.assertThat("Should have 2 type parameters", genericType.getTypeParameters().length == 2); - MatcherAssert.assertThat(genericType.getTypeParameters()[1].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[1]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Map.class))); - - MatcherAssert.assertThat("Should have 2 type parameters", ((GenericType) genericType.getTypeParameters()[1]).getTypeParameters().length == 2); - - MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); - MatcherAssert.assertThat(((GenericTypeWildcard) ((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[0]).getExtendsBound().getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - - MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[1].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); - MatcherAssert.assertThat(((GenericType) ((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[1]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - - } - }) + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createWildcardWithExtendsBound(TypeUtils.Generics.createGenericType(String.class)), + TypeUtils.Generics.createGenericType(String.class) + ) + ); + + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Map.class))); + MatcherAssert.assertThat("Should have 2 type parameters", genericType.getTypeParameters().length == 2); + MatcherAssert.assertThat(genericType.getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[0]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + + MatcherAssert.assertThat(genericType.getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Map.class))); + MatcherAssert.assertThat("Should have 2 type parameters", genericType.getTypeParameters().length == 2); + MatcherAssert.assertThat(genericType.getTypeParameters()[1].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[1]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(Map.class))); + + MatcherAssert.assertThat("Should have 2 type parameters", ((GenericType) genericType.getTypeParameters()[1]).getTypeParameters().length == 2); + + MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[0].getType(), Matchers.is(GenericTypeKind.WILDCARD)); + MatcherAssert.assertThat(((GenericTypeWildcard) ((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[0]).getExtendsBound().getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + + MatcherAssert.assertThat(((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[1].getType(), Matchers.is(GenericTypeKind.GENERIC_TYPE)); + MatcherAssert.assertThat(((GenericType) ((GenericType) genericType.getTypeParameters()[1]).getTypeParameters()[1]).getRawType(), Matchers.is(TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -236,38 +247,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_testNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ); - MatcherAssert.assertThat("Should return false if passed typeMirror is null", !TypeUtils.Generics.genericTypeEquals(null, genericType)); - MatcherAssert.assertThat("Should return false if passed genericType is null", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), null)); - MatcherAssert.assertThat("Should return false if passed typeMirror and genericType are null", !TypeUtils.Generics.genericTypeEquals(null, null)); + MatcherAssert.assertThat("Should return false if passed typeMirror is null", !TypeUtils.Generics.genericTypeEquals(null, genericType)); + MatcherAssert.assertThat("Should return false if passed genericType is null", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), null)); + MatcherAssert.assertThat("Should return false if passed typeMirror and genericType are null", !TypeUtils.Generics.genericTypeEquals(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -275,36 +287,37 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_tc1_matchingType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ); - MatcherAssert.assertThat("Should detect matching types and return true", TypeUtils.Generics.genericTypeEquals(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect matching types and return true", TypeUtils.Generics.genericTypeEquals(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -313,36 +326,37 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_tc2_mismatchingType_differentGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(Integer.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(Integer.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ); - MatcherAssert.assertThat("Should detect mismatching types and return false", !TypeUtils.Generics.genericTypeEquals(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect mismatching types and return false", !TypeUtils.Generics.genericTypeEquals(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -350,34 +364,35 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_genericTypeEquals_tc3_mismatchingType_typeParameterRawTypeVsGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Map.class - ) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Map.class + ) + ); - MatcherAssert.assertThat("Should detect mismatching types and return false", !TypeUtils.Generics.genericTypeEquals(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect mismatching types and return false", !TypeUtils.Generics.genericTypeEquals(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -388,36 +403,37 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc1_exactlySameType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ); - MatcherAssert.assertThat("Should detect assignable for exactly the same type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect assignable for exactly the same type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -425,36 +441,37 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc2_nonMatchingTypeParameterInbetween() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - HashMap.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ); - MatcherAssert.assertThat("Should detect non matching type parameter inbetween", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect non matching type parameter inbetween", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -462,34 +479,35 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc3_pureWildcardFor2ndMapInbetween() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createPureWildcard() + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createPureWildcard() - ); + ); - MatcherAssert.assertThat("Should detect assignability for pure wildcard", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect assignability for pure wildcard", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -497,38 +515,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc4_withSuperMatchingTypeParameterForSuperInbetween() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase1") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) - ); + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) + ); - MatcherAssert.assertThat("Should detect assignability for extends case", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect assignability for extends case", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -536,39 +555,40 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc5_withExtends_MatchingTypeParameterForExtendsInbetween() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase2") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase2") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) - ); + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) + ); - MatcherAssert.assertThat("Should detect assignability for extends case", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Should detect assignability for extends case", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -576,38 +596,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc6_withExtends_clauseOnTMAndGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - HashMap.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) - ); + ); - MatcherAssert.assertThat("Extends on assignee side can't be assigned to a Generic Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Extends on assignee side can't be assigned to a Generic Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -615,40 +636,41 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc7_withExtends_clauseOnTMAndSuperOnGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) - ); + ); - MatcherAssert.assertThat("Extends on assignee side can't be assigned to a super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Extends on assignee side can't be assigned to a super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -656,35 +678,35 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc8_withExtends_clauseOnTMAndPureWildcard_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createPureWildcard() + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createPureWildcard() - ); + ); - MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a pure wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a pure wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -692,40 +714,41 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc9_withExtends_clauseOnTMAndValidExtendsWildcard_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType( + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) - ); + ); - MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a valid extends wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a valid extends wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -733,38 +756,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc10_withExtends_withExtendsClauseOnTMAndValidExtendsWildcard_missingGenericTypes_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType( - Map.class - ) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType( + Map.class + ) + ) - ); + ); - MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a valid extends wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a valid extends wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -772,38 +796,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc11_withExtends_withExtendsClauseOnTMAndInvalidExtendsWildcard_missingGenericTypes_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase3") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType( - TreeMap.class - ) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType( + TreeMap.class + ) + ) - ); + ); - MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a invalid extends wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Extends on assignee side must be detected as assignable with a invalid extends wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -814,38 +839,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc12_withExtends_withSuperClauseOnTypeMirrorAndGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - HashMap.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) - ); + ); - MatcherAssert.assertThat("Super on assignee side can't be assigned to a Generic Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side can't be assigned to a Generic Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -853,40 +879,41 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc13_withSuperClauseOnTypeMirrorAndExtendsOnGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) - ); + ); - MatcherAssert.assertThat("Super on assignee side can't be assigned to a super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side can't be assigned to a super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -894,33 +921,34 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc14_withSuperClauseOnTypeMirrorAndPureWildcard_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createPureWildcard() + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createPureWildcard() - ); + ); - MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a pure wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a pure wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -928,39 +956,40 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc15_withSuperClauseOnTypeMirrorAndValidSuperWildcard_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) - ); + ); - MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a valid super wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a valid super wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -968,37 +997,38 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc16_withSuperClauseOnTypeMirrorAndValidSuperWildcard_missingGenericType_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType( - HashMap.class - ) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + HashMap.class + ) + ) - ); + ); - MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a valid super wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a valid super wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1006,37 +1036,38 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc17_withSuperClauseOnTypeMirrorAndInvalidSuperWildcard_missingGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase4") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType( - Collection.class - ) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + Collection.class + ) + ) - ); + ); - MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a invalid super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a invalid super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1046,38 +1077,39 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc18_withPureWildcardClauseOnTypeMirrorAndGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - HashMap.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) - ); + ); - MatcherAssert.assertThat("Pure wildcard on assignee side can't be assigned to a Generic Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Pure wildcard on assignee side can't be assigned to a Generic Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1086,38 +1118,40 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc19_withPureWildcardClauseOnTypeMirrorAndGenericType_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") - .getResult(); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) - ); + ); - MatcherAssert.assertThat("pure wildcard on assignee side can't be assigned to a extends wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("pure wildcard on assignee side can't be assigned to a extends wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1125,32 +1159,34 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc20_withPureWildcardClauseOnTypeMirrorAndGenericType_mustBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") - .getResult(); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") + .getResult(); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createPureWildcard() - ); + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createPureWildcard() + + ); - MatcherAssert.assertThat("Pure wildcard on assignee side must be detected as assignable with a pure wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Pure wildcard on assignee side must be detected as assignable with a pure wildcard Type", TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1158,39 +1194,40 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc21_withPureWildcardClauseOnTypeMirrorAndSuperWildard_mustNotBeAssignable() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase5") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(AbstractUnitTestAnnotationProcessorClass.class); - // Map> - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createWildcardWithSuperBound( - TypeUtils.Generics.createGenericType( - HashMap.class, + // Map> + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType(String.class) - ) - ) + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + HashMap.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType(String.class) + ) + ) - ); + ); - MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a valid super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("Super on assignee side must be detected as assignable with a valid super wildcard Type", !TypeUtils.Generics.genericIsAssignableTo(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1198,29 +1235,30 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc22_comparisionWithGenericType_matching() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Comparator - GenericType genericType = TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createGenericType(String.class) - ); + // Comparator + GenericType genericType = TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createGenericType(String.class) + ); - MatcherAssert.assertThat("comparison with GenericType for exactly matching types should return true", TypeUtils.Arrays.isArrayOfType(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("comparison with GenericType for exactly matching types should return true", TypeUtils.Arrays.isArrayOfType(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1229,29 +1267,30 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc23_comparisionWithGenericType_nonMatching() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Comparator - GenericType genericType = TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createGenericType(Object.class) - ); + // Comparator + GenericType genericType = TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createGenericType(Object.class) + ); - MatcherAssert.assertThat("comparison with GenericType for assignable types should return false", !TypeUtils.Arrays.isArrayOfType(method.getParameters().get(0).asType(), genericType)); + MatcherAssert.assertThat("comparison with GenericType for assignable types should return false", !TypeUtils.Arrays.isArrayOfType(method.getParameters().get(0).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1259,31 +1298,32 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc23_comparisionWithGenericType_matching_withWildcard() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Comparator - GenericType genericType = TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(Map.class) - ) - ); + // Comparator + GenericType genericType = TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(Map.class) + ) + ); - MatcherAssert.assertThat("comparison with GenericType - matching - with wildcard should return true", TypeUtils.Arrays.isArrayAssignableTo(method.getParameters().get(1).asType(), genericType)); + MatcherAssert.assertThat("comparison with GenericType - matching - with wildcard should return true", TypeUtils.Arrays.isArrayAssignableTo(method.getParameters().get(1).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1291,31 +1331,32 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc24_comparisionWithGenericType_withWildcard_nonMatching() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Comparator - GenericType genericType = TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(String.class) - ) - ); + // Comparator + GenericType genericType = TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(String.class) + ) + ); - MatcherAssert.assertThat("comparison with GenericType - with wildcard - non matching return false", !TypeUtils.Arrays.isArrayAssignableTo(method.getParameters().get(1).asType(), genericType)); + MatcherAssert.assertThat("comparison with GenericType - with wildcard - non matching return false", !TypeUtils.Arrays.isArrayAssignableTo(method.getParameters().get(1).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -1323,31 +1364,32 @@ protected void testCase(TypeElement element) { @Test public void typeUtils_Generics_isAssignable_tc25_comparisionWithGenericType_assignableType_withWildcardsOnBothSides() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("isAssignable_testCase6") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Comparator - GenericType genericType = TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(Map.class) - ) - ); + // Comparator + GenericType genericType = TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(Map.class) + ) + ); - MatcherAssert.assertThat("comparison with GenericType - assignable type - with wildcards on both sides should return true", TypeUtils.Arrays.isArrayAssignableTo(method.getParameters().get(2).asType(), genericType)); + MatcherAssert.assertThat("comparison with GenericType - assignable type - with wildcards on both sides should return true", TypeUtils.Arrays.isArrayAssignableTo(method.getParameters().get(2).asType(), genericType)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandTest.java index 9c756d8e..ed815bbb 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.command.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; +import io.toolisticon.aptk.tools.BeanUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; -import io.toolisticon.aptk.tools.BeanUtils; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; /** @@ -24,32 +26,32 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/testcases.commands/GetAttributesCommandTestClass.java")); - @Test public void shouldExecuteSuccessfullyWithGetterAndSetterMethod() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CLASS) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethods") - .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.createCommand().execute(typeElement); + TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CLASS) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethods") + .getResult().get(0); - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); + BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.createCommand().execute(typeElement); - } - }) + MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); + MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); + + } + }) .compilationShouldSucceed() .executeTest(); @@ -59,22 +61,23 @@ protected void testCase(TypeElement element) { @Test public void shouldExecuteSuccessfullyWithGetterAndSetterMethodButWithInvalidParameterType() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CLASS) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType") - .getResult().get(0); + TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CLASS) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType") + .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.createCommand().execute(typeElement); + BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.createCommand().execute(typeElement); - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); + MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandWithInheritanceTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandWithInheritanceTest.java index 032fd8a2..21ecb88f 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandWithInheritanceTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommandWithInheritanceTest.java @@ -1,22 +1,22 @@ package io.toolisticon.aptk.tools.command.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; +import io.toolisticon.aptk.tools.BeanUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; -import io.toolisticon.aptk.tools.BeanUtils; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; import java.util.stream.Collectors; /** @@ -29,33 +29,32 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java")); - @Test public void shouldExecuteSuccessfullyInheritedDataAnnotatedClass() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CLASS) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestInheritedDataAnnotatedClass") - .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); + TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CLASS) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestInheritedDataAnnotatedClass") + .getResult().get(0); + BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - MatcherAssert.assertThat(attributeResult.length, Matchers.is(2)); + MatcherAssert.assertThat(attributeResult.length, Matchers.is(2)); - MatcherAssert.assertThat(Arrays.stream(attributeResult).map(e -> e.getFieldName()).collect(Collectors.toSet()), Matchers.containsInAnyOrder("field1", "field3")); + MatcherAssert.assertThat(Arrays.stream(attributeResult).map(e -> e.getFieldName()).collect(Collectors.toSet()), Matchers.containsInAnyOrder("field1", "field3")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -66,22 +65,23 @@ protected void testCase(TypeElement element) { @Test public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedMethodWithInvalidParameterType() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.IS_CLASS) - .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType") - .getResult().get(0); + TypeElement typeElement = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.IS_CLASS) + .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType") + .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); + BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); + MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/filter/InclusiveCriteriaElementFilterTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/filter/InclusiveCriteriaElementFilterTest.java index cb8be13b..82ee9b0f 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/filter/InclusiveCriteriaElementFilterTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/filter/InclusiveCriteriaElementFilterTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.tools.filter; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; @@ -10,6 +10,7 @@ import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; @@ -31,22 +32,23 @@ public void findByAll_happyPath() { CompileTestBuilder .unitTest() - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - @Override - protected void testCase(TypeElement element) { - List filteredList = AptkCoreMatchers.BY_MODIFIER.getFilter().filterByAllOf((List) element.getEnclosedElements(), Modifier.PUBLIC, Modifier.SYNCHRONIZED); - MatcherAssert.assertThat("Must have exactly one element'", filteredList, Matchers.hasSize(1)); - MatcherAssert.assertThat("Must find one element with name 'synchronizedMethod'", filteredList.get(0).getSimpleName().toString(), Matchers.is("synchronizedMethod")); + List filteredList = AptkCoreMatchers.BY_MODIFIER.getFilter().filterByAllOf((List) element.getEnclosedElements(), Modifier.PUBLIC, Modifier.SYNCHRONIZED); + MatcherAssert.assertThat("Must have exactly one element'", filteredList, Matchers.hasSize(1)); + MatcherAssert.assertThat("Must find one element with name 'synchronizedMethod'", filteredList.get(0).getSimpleName().toString(), Matchers.is("synchronizedMethod")); - // shouldn't find anything - filteredList = AptkCoreMatchers.BY_MODIFIER.getFilter().filterByAllOf((List) element.getEnclosedElements(), Modifier.PUBLIC, Modifier.SYNCHRONIZED, Modifier.PROTECTED); - MatcherAssert.assertThat("Must have noelement'", filteredList, Matchers.empty()); + // shouldn't find anything + filteredList = AptkCoreMatchers.BY_MODIFIER.getFilter().filterByAllOf((List) element.getEnclosedElements(), Modifier.PUBLIC, Modifier.SYNCHRONIZED, Modifier.PROTECTED); + MatcherAssert.assertThat("Must have noelement'", filteredList, Matchers.empty()); - } - }) + } + }) .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ChildElementsTransitionFilterTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ChildElementsTransitionFilterTest.java index a93c57ba..4b868fa9 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ChildElementsTransitionFilterTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ChildElementsTransitionFilterTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.fluentfilter.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.fluentfilter.TransitionFilters; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import java.util.List; @@ -50,7 +52,7 @@ public void init() { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -58,24 +60,24 @@ public void init() { @Test public void childElementsTransitionFilter_testTransitionWithSingleInputElement() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); + TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); - List expectedElements = (List) testElement.getEnclosedElements(); + List expectedElements = (List) testElement.getEnclosedElements(); - List list = FluentElementFilter.createFluentElementFilter(testElement).applyTransitionFilter(TransitionFilters.CHILD_ELEMENTS).getResult(); - MatcherAssert.assertThat(list, Matchers.containsInAnyOrder(expectedElements.get(0), expectedElements.get(1), expectedElements.get(2))); + List list = FluentElementFilter.createFluentElementFilter(testElement).applyTransitionFilter(TransitionFilters.CHILD_ELEMENTS).getResult(); + MatcherAssert.assertThat(list, Matchers.containsInAnyOrder(expectedElements.get(0), expectedElements.get(1), expectedElements.get(2))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -85,34 +87,35 @@ protected void testCase(TypeElement element) { @Test public void childElementsTransitionFilter_testTransitionWithMultipleInputElement() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement testElement1 = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - TypeElement testElement2 = TypeUtils.TypeRetrieval.getTypeElement(TestClass2.class); - MatcherAssert.assertThat("PRECONDITION : testELement1 must not be null", testElement1, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : testELement2 must not be null", testElement2, Matchers.notNullValue()); + TypeElement testElement1 = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); + TypeElement testElement2 = TypeUtils.TypeRetrieval.getTypeElement(TestClass2.class); - List expectedElements1 = (List) testElement1.getEnclosedElements(); - List expectedElements2 = (List) testElement2.getEnclosedElements(); + MatcherAssert.assertThat("PRECONDITION : testELement1 must not be null", testElement1, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : testELement2 must not be null", testElement2, Matchers.notNullValue()); + List expectedElements1 = (List) testElement1.getEnclosedElements(); + List expectedElements2 = (List) testElement2.getEnclosedElements(); - List list = FluentElementFilter.createFluentElementFilter(testElement1, testElement2).applyTransitionFilter(TransitionFilters.CHILD_ELEMENTS).getResult(); - MatcherAssert.assertThat(list, Matchers.containsInAnyOrder( - expectedElements1.get(0), - expectedElements1.get(1), - expectedElements1.get(2), - expectedElements2.get(0), - expectedElements2.get(1), - expectedElements2.get(2) - )); + List list = FluentElementFilter.createFluentElementFilter(testElement1, testElement2).applyTransitionFilter(TransitionFilters.CHILD_ELEMENTS).getResult(); + MatcherAssert.assertThat(list, Matchers.containsInAnyOrder( + expectedElements1.get(0), + expectedElements1.get(1), + expectedElements1.get(2), + expectedElements2.get(0), + expectedElements2.get(1), + expectedElements2.get(2) + )); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ParentElementTransitionFilterTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ParentElementTransitionFilterTest.java index 35f0b3ad..a77fde28 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ParentElementTransitionFilterTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/ParentElementTransitionFilterTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.fluentfilter.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.fluentfilter.TransitionFilters; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import java.util.List; @@ -43,7 +45,7 @@ private String testMethod2() { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -55,23 +57,25 @@ public void init() { @Test public void parentElementTransitionFilter_testTransitionWithSingleInputElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); + TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - TypeElement expectedParentElement = (TypeElement) testElement.getEnclosingElement(); + MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); + TypeElement expectedParentElement = (TypeElement) testElement.getEnclosingElement(); - List list = FluentElementFilter.createFluentElementFilter(testElement).applyTransitionFilter(TransitionFilters.PARENT_ELEMENTS).getResult(); - MatcherAssert.assertThat(list, Matchers.containsInAnyOrder((Element) expectedParentElement)); + List list = FluentElementFilter.createFluentElementFilter(testElement).applyTransitionFilter(TransitionFilters.PARENT_ELEMENTS).getResult(); + MatcherAssert.assertThat(list, Matchers.containsInAnyOrder((Element) expectedParentElement)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); @@ -81,29 +85,30 @@ protected void testCase(TypeElement element) { @Test public void parentElementTransitionFilter_testTransitionWithMultipleInputElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement testElement1 = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - TypeElement testElement2 = TypeUtils.TypeRetrieval.getTypeElement(TestClass2.class); + TypeElement testElement1 = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); + TypeElement testElement2 = TypeUtils.TypeRetrieval.getTypeElement(TestClass2.class); - MatcherAssert.assertThat("PRECONDITION : testElement1 must not be null", testElement1, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : testElement2 must not be null", testElement2, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : testElement1 must not be null", testElement1, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : testElement2 must not be null", testElement2, Matchers.notNullValue()); - Element expectedElements1 = testElement1.getEnclosingElement(); - Element expectedElements2 = testElement2.getEnclosingElement(); + Element expectedElements1 = testElement1.getEnclosingElement(); + Element expectedElements2 = testElement2.getEnclosingElement(); - List list = FluentElementFilter.createFluentElementFilter(testElement1, testElement2).applyTransitionFilter(TransitionFilters.PARENT_ELEMENTS).getResult(); - MatcherAssert.assertThat(list, Matchers.containsInAnyOrder( - expectedElements1, - expectedElements2 - )); + List list = FluentElementFilter.createFluentElementFilter(testElement1, testElement2).applyTransitionFilter(TransitionFilters.PARENT_ELEMENTS).getResult(); + MatcherAssert.assertThat(list, Matchers.containsInAnyOrder( + expectedElements1, + expectedElements2 + )); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/RemoveDuplicatesTransitionFilterTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/RemoveDuplicatesTransitionFilterTest.java index 43087784..679cb1dc 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/RemoveDuplicatesTransitionFilterTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/RemoveDuplicatesTransitionFilterTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.tools.fluentfilter.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.fluentfilter.TransitionFilters; @@ -11,6 +11,7 @@ import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import java.util.List; @@ -30,10 +31,10 @@ public void init() { public void removeDuplicatesTransitionFilter_testTransitionToRemoveDuplicateValues() { CompileTestBuilder.unitTest() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List list = FluentElementFilter.createFluentElementFilter(element, element).applyTransitionFilter(TransitionFilters.REMOVE_DUPLICATES_ELEMENTS).getResult(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/SuperTypesTransitionFilterTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/SuperTypesTransitionFilterTest.java index b2912327..1cc588e6 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/SuperTypesTransitionFilterTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/fluentfilter/impl/SuperTypesTransitionFilterTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.fluentfilter.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.fluentfilter.TransitionFilters; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import java.util.List; @@ -39,7 +41,7 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -47,30 +49,31 @@ public void init() { @Test public void parentElementTransitionFilter_testTransitionWithSingleInputElements() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(InheritingClass.class); - MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); + TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(InheritingClass.class); - TypeElement expectedSuperType1 = TypeUtils.TypeRetrieval.getTypeElement(SuperClass.class); - TypeElement expectedSuperType2 = TypeUtils.TypeRetrieval.getTypeElement(Object.class); - TypeElement expectedSuperType3 = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); + MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : expectedSuperType1 must not be null", expectedSuperType1, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : expectedSuperType2 must not be null", expectedSuperType2, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : expectedSuperType3 must not be null", expectedSuperType3, Matchers.notNullValue()); + TypeElement expectedSuperType1 = TypeUtils.TypeRetrieval.getTypeElement(SuperClass.class); + TypeElement expectedSuperType2 = TypeUtils.TypeRetrieval.getTypeElement(Object.class); + TypeElement expectedSuperType3 = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); + MatcherAssert.assertThat("PRECONDITION : expectedSuperType1 must not be null", expectedSuperType1, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : expectedSuperType2 must not be null", expectedSuperType2, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : expectedSuperType3 must not be null", expectedSuperType3, Matchers.notNullValue()); - List list = FluentElementFilter.createFluentElementFilter(testElement).applyTransitionFilter(TransitionFilters.SUPER_TYPE_ELEMENTS).getResult(); - MatcherAssert.assertThat(list, Matchers.containsInAnyOrder(expectedSuperType1, expectedSuperType2, expectedSuperType3)); + List list = FluentElementFilter.createFluentElementFilter(testElement).applyTransitionFilter(TransitionFilters.SUPER_TYPE_ELEMENTS).getResult(); + MatcherAssert.assertThat(list, Matchers.containsInAnyOrder(expectedSuperType1, expectedSuperType2, expectedSuperType3)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); @@ -79,30 +82,30 @@ protected void testCase(TypeElement element) { @Test public void parentElementTransitionFilter_testTransitionWithMultipleInputElements() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(InheritingClass.class); + TypeElement testElement = TypeUtils.TypeRetrieval.getTypeElement(InheritingClass.class); - MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : testELement must not be null", testElement, Matchers.notNullValue()); - TypeElement expectedSuperType1 = TypeUtils.TypeRetrieval.getTypeElement(SuperClass.class); - TypeElement expectedSuperType2 = TypeUtils.TypeRetrieval.getTypeElement(Object.class); - TypeElement expectedSuperType3 = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); + TypeElement expectedSuperType1 = TypeUtils.TypeRetrieval.getTypeElement(SuperClass.class); + TypeElement expectedSuperType2 = TypeUtils.TypeRetrieval.getTypeElement(Object.class); + TypeElement expectedSuperType3 = TypeUtils.TypeRetrieval.getTypeElement(TestInterface.class); - MatcherAssert.assertThat("PRECONDITION : expectedSuperType1 must not be null", expectedSuperType1, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : expectedSuperType2 must not be null", expectedSuperType2, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : expectedSuperType3 must not be null", expectedSuperType3, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : expectedSuperType1 must not be null", expectedSuperType1, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : expectedSuperType2 must not be null", expectedSuperType2, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : expectedSuperType3 must not be null", expectedSuperType3, Matchers.notNullValue()); - List list = FluentElementFilter.createFluentElementFilter(testElement, testElement).applyTransitionFilter(TransitionFilters.SUPER_TYPE_ELEMENTS).getResult(); - MatcherAssert.assertThat(list, Matchers.containsInAnyOrder(expectedSuperType1, expectedSuperType2, expectedSuperType3, expectedSuperType1, expectedSuperType2, expectedSuperType3)); + List list = FluentElementFilter.createFluentElementFilter(testElement, testElement).applyTransitionFilter(TransitionFilters.SUPER_TYPE_ELEMENTS).getResult(); + MatcherAssert.assertThat(list, Matchers.containsInAnyOrder(expectedSuperType1, expectedSuperType2, expectedSuperType3, expectedSuperType1, expectedSuperType2, expectedSuperType3)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/FluentElementValidatorTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/FluentElementValidatorTest.java index 11530f31..b112039c 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/FluentElementValidatorTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/FluentElementValidatorTest.java @@ -1,23 +1,25 @@ package io.toolisticon.aptk.tools.fluentvalidator; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.ProcessingEnvironmentUtils; +import io.toolisticon.aptk.tools.TestCoreMatcherFactory; import io.toolisticon.aptk.tools.command.Command; import io.toolisticon.aptk.tools.command.CommandWithReturnType; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.corematcher.CoreMatcherValidationMessages; import io.toolisticon.aptk.tools.corematcher.PlainValidationMessage; import io.toolisticon.aptk.tools.corematcher.ValidationMessage; -import io.toolisticon.aptk.tools.TestCoreMatcherFactory; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; @@ -36,23 +38,23 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @Test public void validateByNoneOfCriteriaWithDefaults() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -62,16 +64,16 @@ protected void testCase(TypeElement element) { @Test public void validateByNoneOfCriteriaWithDefaults_failingValidation() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); - } - }) + } + }) .expectErrorMessageThatContains(CoreMatcherValidationMessages.BY_MODIFIER.getCode()) .compilationShouldFail() @@ -83,16 +85,16 @@ protected void testCase(TypeElement element) { @Test public void validateByOneOfCriteriaWithDefaults() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -103,16 +105,16 @@ protected void testCase(TypeElement element) { @Test public void validateByOneOfCriteriaWithDefaults_failingValidation() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); - } - }) + } + }) .expectErrorMessageThatContains(CoreMatcherValidationMessages.BY_MODIFIER.getCode()) @@ -125,16 +127,16 @@ protected void testCase(TypeElement element) { @Test public void validateByAllOfCriteriaWithDefaults() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -144,16 +146,16 @@ protected void testCase(TypeElement element) { @Test public void validateByAllOfCriteriaWithDefaults_failingValidation() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); - } - }) + } + }) .expectErrorMessageThatContains(CoreMatcherValidationMessages.BY_MODIFIER.getCode()) .compilationShouldFail() .executeTest(); @@ -163,14 +165,14 @@ protected void testCase(TypeElement element) { @Test public void validateByAtLeastOneOfCriteriaWithDefaults() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PUBLIC).validateAndIssueMessages(); - } - }) + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PUBLIC).validateAndIssueMessages(); + } + }) .compilationShouldSucceed() .executeTest(); @@ -179,16 +181,16 @@ protected void testCase(TypeElement element) { @Test public void validateByAtLeastOneOfCriteriaWithDefaults_failingValidation() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PROTECTED, Modifier.ABSTRACT).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PROTECTED, Modifier.ABSTRACT).validateAndIssueMessages(); - } - }) + } + }) .expectErrorMessageThatContains(CoreMatcherValidationMessages.BY_MODIFIER.getCode()) .compilationShouldFail() @@ -199,16 +201,16 @@ protected void testCase(TypeElement element) { @Test public void validateByIsCriteria_elementBasedAndTypeElementBased_withDefaults() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_TYPE_ELEMENT).is(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_TYPE_ELEMENT).is(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -217,16 +219,16 @@ protected void testCase(TypeElement element) { @Test public void validateByIsCriteria_elementBasedAndTypeElementBased_withDefaults_failingValidation_ELEMENT_CHECK() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).is(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).is(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); - } - }) + } + }) .expectErrorMessageThatContains(CoreMatcherValidationMessages.IS_EXECUTABLE_ELEMENT.getCode()) @@ -239,16 +241,16 @@ protected void testCase(TypeElement element) { @Test public void validateByIsCriteria_elementBasedAndTypeElementBased_withDefaults_failingValidation_ELEMENT_KIND_CHECK() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_TYPE_ELEMENT).is(AptkCoreMatchers.IS_INTERFACE).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_TYPE_ELEMENT).is(AptkCoreMatchers.IS_INTERFACE).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldFail() .expectErrorMessageThatContains(CoreMatcherValidationMessages.IS_INTERFACE.getCode()) @@ -261,21 +263,21 @@ protected void testCase(TypeElement element) { @Test public void validateByImplicitCriteria_hasReturnType_withDefaults() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); - MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); - MatcherAssert.assertThat("Precondition : element must be method", ElementUtils.CheckKindOfElement.isMethod(methods.get(0))); + List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); + MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); + MatcherAssert.assertThat("Precondition : element must be method", ElementUtils.CheckKindOfElement.isMethod(methods.get(0))); - FluentElementValidator.createFluentElementValidator(ElementUtils.CastElement.castMethod(methods.get(0))).applyValidator(AptkCoreMatchers.HAS_VOID_RETURN_TYPE).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(ElementUtils.CastElement.castMethod(methods.get(0))).applyValidator(AptkCoreMatchers.HAS_VOID_RETURN_TYPE).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -285,10 +287,10 @@ protected void testCase(TypeElement element) { @Test public void validateByImplicitCriteria_hasReturnType_withDefaults_failibgValidation() { unitTestBuilder.compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -314,30 +316,30 @@ protected void testCase(TypeElement element) { @Test public void validateByNoneOfCriteriaWithCustomSettings() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).warning().applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); + FluentElementValidator.createFluentElementValidator(element).warning().applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); - + } @Test public void validateByNoneOfCriteriaWithCustomSettings_failingValidation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); @@ -348,7 +350,7 @@ protected void testCase(TypeElement element) { .expectErrorMessageThatContains(CoreMatcherValidationMessages.BY_MODIFIER.getCode(), "UPS") .executeTest(); - + } @@ -356,10 +358,10 @@ protected void testCase(TypeElement element) { public void validatByOneOfCriteriaWithCustomSettings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); @@ -368,7 +370,7 @@ protected void testCase(TypeElement element) { } ) .executeTest(); - + } @@ -376,10 +378,10 @@ protected void testCase(TypeElement element) { public void validateByOneOfCriteriaWithCustomSettings_failingValidation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); @@ -400,10 +402,10 @@ protected void testCase(TypeElement element) { public void validateByAllOfCriteriaWithCustomSettings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC).validateAndIssueMessages(); @@ -421,10 +423,10 @@ protected void testCase(TypeElement element) { public void validateByAllOfCriteriaWithCustomSettings_failingValidation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); @@ -435,7 +437,7 @@ protected void testCase(TypeElement element) { .expectErrorMessageThatContains(CoreMatcherValidationMessages.BY_MODIFIER.getCode(), "UPS") .executeTest(); - + } @@ -443,10 +445,10 @@ protected void testCase(TypeElement element) { public void validateByAtLeastOneOfCriteriaWithCustomSettings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PUBLIC).validateAndIssueMessages(); @@ -464,10 +466,10 @@ protected void testCase(TypeElement element) { public void validate_by_at_least_one_of_criteria_with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PROTECTED, Modifier.ABSTRACT).validateAndIssueMessages(); @@ -488,10 +490,10 @@ protected void testCase(TypeElement element) { public void validateby_is_criteria__element_based_and_type_element_based__with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).setCustomMessage("UPS").is(AptkCoreMatchers.IS_TYPE_ELEMENT).setCustomMessage("UPS").is(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); @@ -509,10 +511,10 @@ protected void testCase(TypeElement element) { public void validate_by_is_criteria__element_based_and_type_element_based__with_custom_settings__failing_validation__ELEMENT_CHECK() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).setCustomMessage("UPS").is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).is(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); @@ -533,10 +535,10 @@ protected void testCase(TypeElement element) { public void validate_by_is_criteria__element_based_and_type_element_based__with_custom_settings__failing_validation__ELEMENT_KIND_CHECK() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).is(AptkCoreMatchers.IS_TYPE_ELEMENT).setCustomMessage("UPS").is(AptkCoreMatchers.IS_INTERFACE).validateAndIssueMessages(); @@ -557,10 +559,10 @@ protected void testCase(TypeElement element) { public void validate_by_implicit_criteria__has_return_type__with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -583,10 +585,10 @@ protected void testCase(TypeElement element) { public void validate_by_implicit_criteria__has_return_type__with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -616,10 +618,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_none_of_criteria_with_defaults() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); @@ -637,10 +639,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_none_of_criteria_with_defaults__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); @@ -661,10 +663,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_one_of_criteria_with_defaults() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); @@ -682,10 +684,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_one_of_criteria_with_defaults__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); @@ -706,10 +708,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_all_of_criteria_with_defaults() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PROTECTED, Modifier.FINAL).validateAndIssueMessages(); @@ -727,10 +729,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_all_of_criteria_with_defaults__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC).validateAndIssueMessages(); @@ -751,10 +753,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_at_least_one_of_criteria_with_defaults() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PROTECTED, Modifier.ABSTRACT).validateAndIssueMessages(); @@ -772,10 +774,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_at_least_one_of_criteria_with_defaults__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PUBLIC, Modifier.ABSTRACT).validateAndIssueMessages(); @@ -796,10 +798,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_is_criteria__element_based_and_type_element_based__with_defaults() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).isNot(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).isNot(AptkCoreMatchers.IS_INTERFACE).validateAndIssueMessages(); @@ -817,10 +819,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_is_criteria__element_based_and_type_element_based__with_defaults__failing_validation__ELEMENT_CHECK() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).isNot(AptkCoreMatchers.IS_TYPE_ELEMENT).isNot(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); @@ -841,10 +843,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_is_criteria__element_based_and_type_element_based__with_defaults__failing_validation__ELEMENT_KIND_CHECK() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).isNot(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).isNot(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); @@ -865,10 +867,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_implicit_criteria__has_return_type__with_defaults() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -890,10 +892,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_implicit_criteria__has_return_type__with_defaults__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -921,10 +923,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_none_of_criteria_with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); @@ -942,10 +944,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_none_of_criteria_with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); @@ -966,10 +968,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_one_of_criteria_with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PROTECTED).validateAndIssueMessages(); @@ -987,10 +989,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_one_of_criteria_with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.ABSTRACT, Modifier.PUBLIC).validateAndIssueMessages(); @@ -1011,10 +1013,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_all_of_criteria_with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PROTECTED).validateAndIssueMessages(); @@ -1032,10 +1034,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_all_of_criteria_with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC).validateAndIssueMessages(); @@ -1056,10 +1058,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_at_least_one_of_criteria_with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).warning().applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PROTECTED, Modifier.ABSTRACT).validateAndIssueMessages(); @@ -1077,10 +1079,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_at_least_one_of_criteria_with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).setCustomMessage("UPS").applyInvertedValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.PUBLIC).validateAndIssueMessages(); @@ -1101,10 +1103,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_is_criteria__element_based_and_type_element_based__with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).setCustomMessage("UPS").isNot(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).setCustomMessage("UPS").isNot(AptkCoreMatchers.IS_INTERFACE).validateAndIssueMessages(); @@ -1122,10 +1124,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_is_criteria__element_based_and_type_element_based__with_custom_settings__failing_validation__ELEMENT_CHECK() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).setCustomMessage("UPS").isNot(AptkCoreMatchers.IS_TYPE_ELEMENT).isNot(AptkCoreMatchers.IS_METHOD).validateAndIssueMessages(); @@ -1146,10 +1148,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_is_criteria__element_based_and_type_element_based__with_custom_settings__failing_validation__ELEMENT_KIND_CHECK() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator((Element) element).isNot(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).setCustomMessage("UPS").isNot(AptkCoreMatchers.IS_CLASS).validateAndIssueMessages(); @@ -1170,10 +1172,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_implicit_criteria__has_return_type__with_custom_settings() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -1196,10 +1198,10 @@ protected void testCase(TypeElement element) { public void validate_inverted_by_implicit_criteria__has_return_type__with_custom_settings__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -1225,10 +1227,10 @@ protected void testCase(TypeElement element) { public void validate_note_warning_and_error_message__failing_validation_with_setCustomMessage_done_upfront() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -1268,10 +1270,10 @@ protected void testCase(TypeElement element) { public void validate_note_warning_and_error_message__failing_validation() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod"); MatcherAssert.assertThat("Precondition : must have found exactly one element", methods.size() == 1); @@ -1311,10 +1313,10 @@ protected void testCase(TypeElement element) { public void validate_Implicit_Element_based_validator() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1339,10 +1341,10 @@ protected void testCase(TypeElement element) { public void validate_Implicit_validator() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1368,10 +1370,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Implicit_Element_based_validator() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1397,10 +1399,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Implicit_validator() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1426,10 +1428,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_Element_based_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1455,10 +1457,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1484,10 +1486,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_Element_based_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1518,10 +1520,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1552,10 +1554,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_Element_based_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1581,10 +1583,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1610,10 +1612,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_Element_based_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1644,10 +1646,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1678,10 +1680,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_Element_based_validator___at_least_one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1712,10 +1714,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_validator__at_least_one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1746,10 +1748,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_Element_based_validator___at_least_one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1780,10 +1782,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_validator__at_least_one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1814,10 +1816,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_Element_based_validator__all_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1843,10 +1845,10 @@ protected void testCase(TypeElement element) { public void validate_Inclusive_Characteristics_validator__all_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1872,10 +1874,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_Element_based_validator__all_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1906,10 +1908,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Inclusive_Characteristics_validator__all_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1941,10 +1943,10 @@ protected void testCase(TypeElement element) { public void validate_Exclusive_Characteristics_Element_based_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1970,10 +1972,10 @@ protected void testCase(TypeElement element) { public void validate_Exclusive_Characteristics_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -1999,10 +2001,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Exclusive_Characteristics_Element_based_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -2033,10 +2035,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Exclusive_Characteristics_validator__none_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -2067,10 +2069,10 @@ protected void testCase(TypeElement element) { public void validate_Exclusive_Characteristics_Element_based_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -2096,10 +2098,10 @@ protected void testCase(TypeElement element) { public void validate_Exclusive_Characteristics_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -2130,10 +2132,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Exclusive_Characteristics_Element_based_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -2164,10 +2166,10 @@ protected void testCase(TypeElement element) { public void validate_INVERTED_Exclusive_Characteristics_validator__one_of() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element) @@ -2193,10 +2195,10 @@ protected void testCase(TypeElement element) { public void validate_IS_Element_based_validator() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator((Element) element).is(TestCoreMatcherFactory.createElementBasedIsCoreMatcher(TypeElement.class, "SUCCESS", true)).validateAndIssueMessages() @@ -2220,10 +2222,10 @@ protected void testCase(TypeElement element) { public void validate_IS_validator() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( FluentElementValidator.createFluentElementValidator(element).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "SUCCESS", true)).validateAndIssueMessages() @@ -2247,10 +2249,10 @@ protected void testCase(TypeElement element) { public void execute_command__if_validation_succeeds() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "SUCCESS", true)) @@ -2279,10 +2281,10 @@ public void execute(TypeElement element) { public void execute_command_with_return_value__if_validation_succeeds() { unitTestBuilder .compilationShouldSucceed() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { MatcherAssert.assertThat( @@ -2314,20 +2316,21 @@ public String execute(TypeElement element) { public void dont_execute_command_but_trigger_validation_message__if_validation_fails() { unitTestBuilder .compilationShouldSucceed() - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentElementValidator.createFluentElementValidator(element).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) - .executeCommand( - new Command() { - @Override - public void execute(TypeElement element) { - ProcessingEnvironmentUtils.getMessager().printMessage(Diagnostic.Kind.ERROR, "EXECUTED COMMAND"); - } - }); - } - } + FluentElementValidator.createFluentElementValidator(element).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) + .executeCommand( + new Command() { + @Override + public void execute(TypeElement element) { + ProcessingEnvironmentUtils.getMessager().printMessage(Diagnostic.Kind.ERROR, "EXECUTED COMMAND"); + } + }); + } + } ) .executeTest(); @@ -2339,10 +2342,10 @@ public void execute(TypeElement element) { public void dont_execute_command__if_validation_fails() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) .executeCommandAndIssueMessages( @@ -2368,10 +2371,10 @@ public void execute(TypeElement element) { public void dont_execute_command_with_return_value__if_validation_fails() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) .executeCommandAndIssueMessages( @@ -2397,25 +2400,25 @@ public String execute(TypeElement element) { public void custom_message__with_ValidationMessage_class_and_Messageargs() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element) .error().setCustomMessage( - new ValidationMessage() { - @Override - public String getCode() { - return "XXX"; - } - - @Override - public String getMessage() { - return "ERROR ${0} ${0} ${1}!"; - } - }, "YES", "AGAIN" - ).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) + new ValidationMessage() { + @Override + public String getCode() { + return "XXX"; + } + + @Override + public String getMessage() { + return "ERROR ${0} ${0} ${1}!"; + } + }, "YES", "AGAIN" + ).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) .validateAndIssueMessages(); } } @@ -2432,16 +2435,16 @@ public String getMessage() { public void custom_message__with_ValidationMessage_class_without_MessageArgs() { unitTestBuilder .compilationShouldFail() - .useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { + .defineTest( + new APTKUnitTestProcessor() { @Override - protected void testCase(TypeElement element) { + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { FluentElementValidator.createFluentElementValidator(element) .error().setCustomMessage( - PlainValidationMessage.create("XXX", "ERROR!") + PlainValidationMessage.create("XXX", "ERROR!") - ).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) + ).is(TestCoreMatcherFactory.createIsCoreMatcher(TypeElement.class, TypeElement.class, "FAILURE", false)) .validateAndIssueMessages(); } } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/impl/FluentValidatorMessageTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/impl/FluentValidatorMessageTest.java index c388438a..0abd467c 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/impl/FluentValidatorMessageTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/fluentvalidator/impl/FluentValidatorMessageTest.java @@ -1,18 +1,20 @@ package io.toolisticon.aptk.tools.fluentvalidator.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; -import io.toolisticon.aptk.tools.FilterTestAnnotation1; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.AnnotationUtils; import io.toolisticon.aptk.tools.ElementUtils; +import io.toolisticon.aptk.tools.FilterTestAnnotation1; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.PlainValidationMessage; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; @@ -30,7 +32,7 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -38,16 +40,16 @@ public void init() { @Test public void checkErrorElementMessage() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentValidatorMessage message = new FluentValidatorMessage(element, Diagnostic.Kind.ERROR, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); - message.issueMessage(); + FluentValidatorMessage message = new FluentValidatorMessage(element, Diagnostic.Kind.ERROR, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); + message.issueMessage(); - } - }) + } + }) .compilationShouldFail() .executeTest(); @@ -56,16 +58,16 @@ protected void testCase(TypeElement element) { @Test public void checkWarningElementMessage() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentValidatorMessage message = new FluentValidatorMessage(element, Diagnostic.Kind.WARNING, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); - message.issueMessage(); + FluentValidatorMessage message = new FluentValidatorMessage(element, Diagnostic.Kind.WARNING, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); + message.issueMessage(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -74,16 +76,16 @@ protected void testCase(TypeElement element) { @Test public void checkInfoElementMessage() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - FluentValidatorMessage message = new FluentValidatorMessage(element, Diagnostic.Kind.NOTE, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); - message.issueMessage(); + FluentValidatorMessage message = new FluentValidatorMessage(element, Diagnostic.Kind.NOTE, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); + message.issueMessage(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -92,22 +94,23 @@ protected void testCase(TypeElement element) { @Test public void checkElementWithAnnotationMirror() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List annotatedElement = ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, FilterTestAnnotation1.class); - MatcherAssert.assertThat("PRECONDITION : Must have found one element", annotatedElement.size() == 1); - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(annotatedElement.get(0), FilterTestAnnotation1.class); - MatcherAssert.assertThat("PRECONDITION : Must have found one annotation", annotationMirror, Matchers.notNullValue()); + List annotatedElement = ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, FilterTestAnnotation1.class); + MatcherAssert.assertThat("PRECONDITION : Must have found one element", annotatedElement.size() == 1); + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(annotatedElement.get(0), FilterTestAnnotation1.class); + MatcherAssert.assertThat("PRECONDITION : Must have found one annotation", annotationMirror, Matchers.notNullValue()); - FluentValidatorMessage message = new FluentValidatorMessage(annotatedElement.get(0), annotationMirror, Diagnostic.Kind.NOTE, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); - message.issueMessage(); + FluentValidatorMessage message = new FluentValidatorMessage(annotatedElement.get(0), annotationMirror, Diagnostic.Kind.NOTE, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); + message.issueMessage(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -117,22 +120,22 @@ protected void testCase(TypeElement element) { @Test public void checkElementWithAnnotationMirrorAndAnnotationValue() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List annotatedElement = ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, FilterTestAnnotation1.class); - MatcherAssert.assertThat("PRECONDITION : Must have found one element", annotatedElement.size() == 1); - AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(annotatedElement.get(0), FilterTestAnnotation1.class); - MatcherAssert.assertThat("PRECONDITION : Must have found one annotation", annotationMirror, Matchers.notNullValue()); - MatcherAssert.assertThat("PRECONDITION : Must have found one annotation", annotationMirror.getElementValues().size() == 1); + List annotatedElement = ElementUtils.AccessEnclosedElements.getEnclosedElementsWithAllAnnotationsOf(element, FilterTestAnnotation1.class); + MatcherAssert.assertThat("PRECONDITION : Must have found one element", annotatedElement.size() == 1); + AnnotationMirror annotationMirror = AnnotationUtils.getAnnotationMirror(annotatedElement.get(0), FilterTestAnnotation1.class); + MatcherAssert.assertThat("PRECONDITION : Must have found one annotation", annotationMirror, Matchers.notNullValue()); + MatcherAssert.assertThat("PRECONDITION : Must have found one annotation", annotationMirror.getElementValues().size() == 1); - FluentValidatorMessage message = new FluentValidatorMessage(element, annotatedElement.get(0).getAnnotationMirrors().get(0), annotationMirror.getElementValues().get(0), Diagnostic.Kind.NOTE, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); - message.issueMessage(); + FluentValidatorMessage message = new FluentValidatorMessage(element, annotatedElement.get(0).getAnnotationMirrors().get(0), annotationMirror.getElementValues().get(0), Diagnostic.Kind.NOTE, PlainValidationMessage.create("TEST ${0}"), "SUCCESS"); + message.issueMessage(); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByAnnotationMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByAnnotationMatcherTest.java index 12c0bcad..4c7a9305 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByAnnotationMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByAnnotationMatcherTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; import org.hamcrest.MatcherAssert; import org.junit.Test; import org.mockito.Mockito; diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByGenericTypeMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByGenericTypeMatcherTest.java index c81db7fc..0c81948f 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByGenericTypeMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByGenericTypeMatcherTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; @@ -8,11 +8,13 @@ import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.generics.GenericType; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -26,7 +28,7 @@ */ public class ByGenericTypeMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -38,30 +40,32 @@ public void init() { @Test public void getStringRepresentationOfPassedCharacteristic_createStringRepresentationCorrectly() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - GenericType genericTypeToConvert = TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(StringBuilder.class) - ), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithSuperBound( + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + GenericType genericTypeToConvert = TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(StringBuilder.class) + ), TypeUtils.Generics.createGenericType( - List.class, - TypeUtils.Generics.createPureWildcard() - ) - ) + Comparator.class, + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + List.class, + TypeUtils.Generics.createPureWildcard() + ) + ) - ) - ); + ) + ); - MatcherAssert.assertThat(AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(genericTypeToConvert), org.hamcrest.Matchers.is("java.util.Map>>")); + MatcherAssert.assertThat(AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(genericTypeToConvert), org.hamcrest.Matchers.is("java.util.Map>>")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -69,35 +73,35 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_shouldBeAbleToCompareGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - @Override - protected void testCase(TypeElement element) { + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter") + .getResult(); - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter") - .getResult(); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + GenericType genericType = TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createGenericType(Long.class) + ) + ); - GenericType genericType = TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createGenericType(Long.class) - ) - ); - - MatcherAssert.assertThat("Should compare successful", AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(0), genericType)); + MatcherAssert.assertThat("Should compare successful", AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(0), genericType)); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -105,36 +109,36 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_shoulNotdBeAbleToCompareGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter") - .getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter") + .getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - GenericType genericType = TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createGenericType(String.class), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createGenericType(Double.class) - ) + GenericType genericType = TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createGenericType(String.class), + TypeUtils.Generics.createGenericType( + Comparator.class, + TypeUtils.Generics.createGenericType(Double.class) + ) - ); + ); - MatcherAssert.assertThat("Should not compare successful", !AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(0), genericType)); + MatcherAssert.assertThat("Should not compare successful", !AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(0), genericType)); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -143,43 +147,43 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_shouldBeAbleToCompareGenericTypeWithWildcards() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter").getResult(); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - // Map>> + // Map>> - GenericType genericType = TypeUtils.Generics.createGenericType(Map.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(StringBuilder.class) - ), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithSuperBound( + GenericType genericType = TypeUtils.Generics.createGenericType(Map.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(StringBuilder.class) + ), TypeUtils.Generics.createGenericType( - List.class, - TypeUtils.Generics.createPureWildcard() - ) - ) + Comparator.class, + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + List.class, + TypeUtils.Generics.createPureWildcard() + ) + ) - ) - ); + ) + ); - MatcherAssert.assertThat("Should compare successful", AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(1), genericType)); + MatcherAssert.assertThat("Should compare successful", AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(1), genericType)); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -187,47 +191,47 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_shouldNotBeAbleToCompareGenericTypeWithWildcards() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - @Override - protected void testCase(TypeElement element) { + List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter") + .getResult(); - List result = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testGenericsOnParameter") - .getResult(); + ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); - ExecutableElement method = ElementUtils.CastElement.castMethod(result.get(0)); + // Map>> - // Map>> - - GenericType genericType = TypeUtils.Generics.createGenericType( - Map.class, - TypeUtils.Generics.createWildcardWithExtendsBound( - TypeUtils.Generics.createGenericType(StringBuilder.class) - ), - TypeUtils.Generics.createGenericType( - Comparator.class, - TypeUtils.Generics.createWildcardWithSuperBound( + GenericType genericType = TypeUtils.Generics.createGenericType( + Map.class, + TypeUtils.Generics.createWildcardWithExtendsBound( + TypeUtils.Generics.createGenericType(StringBuilder.class) + ), TypeUtils.Generics.createGenericType( - List.class, - TypeUtils.Generics.createWildcardWithExtendsBound(TypeUtils.Generics.createGenericType(String.class)) - ) - ) + Comparator.class, + TypeUtils.Generics.createWildcardWithSuperBound( + TypeUtils.Generics.createGenericType( + List.class, + TypeUtils.Generics.createWildcardWithExtendsBound(TypeUtils.Generics.createGenericType(String.class)) + ) + ) - ) - ); + ) + ); - MatcherAssert.assertThat("Should not compare successful", !AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(1), genericType)); + MatcherAssert.assertThat("Should not compare successful", !AptkCoreMatchers.BY_GENERIC_TYPE.getMatcher().checkForMatchingCharacteristic(method.getParameters().get(1), genericType)); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByNumberOfParametersMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByNumberOfParametersMatcherTest.java index 467021fe..9b33b2d8 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByNumberOfParametersMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByNumberOfParametersMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -37,7 +39,7 @@ public void twoParameters(boolean first, boolean second) { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -50,59 +52,66 @@ public void init() { @Test public void byNumberOfParametersMatcher_methodWith0Parameters() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ByNumberOfParametersMatcherTest.class); - MatcherAssert.assertThat("Precondition: should have found TypeElement", typeElement, Matchers.notNullValue()); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ByNumberOfParametersMatcherTest.class); + MatcherAssert.assertThat("Precondition: should have found TypeElement", typeElement, Matchers.notNullValue()); - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "noParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "noParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Should match 0 parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 0)); - MatcherAssert.assertThat("Should match 1 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 1)); - MatcherAssert.assertThat("Should match 2 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 2)); + MatcherAssert.assertThat("Should match 0 parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 0)); + MatcherAssert.assertThat("Should match 1 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 1)); + MatcherAssert.assertThat("Should match 2 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 2)); - } - }) - .compilationShouldSucceed() - .executeTest(); + + } + }) + . + + compilationShouldSucceed() + . + + executeTest(); } @Test public void byNumberOfParametersMatcher_methodWith1Parameters() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ByNumberOfParametersMatcherTest.class); - MatcherAssert.assertThat("Precondition: should have found TypeElement", typeElement, Matchers.notNullValue()); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ByNumberOfParametersMatcherTest.class); + MatcherAssert.assertThat("Precondition: should have found TypeElement", typeElement, Matchers.notNullValue()); - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "oneParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "oneParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Should match 0 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 0)); - MatcherAssert.assertThat("Should match 1 parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 1)); - MatcherAssert.assertThat("Should match 2 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 2)); - } + MatcherAssert.assertThat("Should match 0 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 0)); + MatcherAssert.assertThat("Should match 1 parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 1)); + MatcherAssert.assertThat("Should match 2 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 2)); + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -111,28 +120,29 @@ protected void testCase(TypeElement element) { @Test public void byNumberOfParametersMatcher_methodWith2Parameters() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ByNumberOfParametersMatcherTest.class); - MatcherAssert.assertThat("Precondition: should have found TypeElement", typeElement, Matchers.notNullValue()); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(ByNumberOfParametersMatcherTest.class); + MatcherAssert.assertThat("Precondition: should have found TypeElement", typeElement, Matchers.notNullValue()); - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "twoParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "twoParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Should match 0 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 0)); - MatcherAssert.assertThat("Should match 1 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 1)); - MatcherAssert.assertThat("Should match 2 parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 2)); - } + MatcherAssert.assertThat("Should match 0 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 0)); + MatcherAssert.assertThat("Should match 1 parameters", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 1)); + MatcherAssert.assertThat("Should match 2 parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, 2)); + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -140,24 +150,25 @@ protected void testCase(TypeElement element) { @Test public void byNumberOfParametersMatcher_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should return false", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should return false", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(null, 1)); - MatcherAssert.assertThat("Should return false", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should return false", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should return false", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(null, 1)); + MatcherAssert.assertThat("Should return false", !AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().checkForMatchingCharacteristic(null, null)); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -165,16 +176,16 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); @@ -183,16 +194,16 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_NUMBER_OF_PARAMETERS.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByPackageNameMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByPackageNameMatcherTest.java index 9b1ea53c..4dc69956 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByPackageNameMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByPackageNameMatcherTest.java @@ -1,18 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; import io.toolisticon.aptk.common.ToolingProvider; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentvalidator.FluentElementValidator; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.PassIn; -import io.toolisticon.cute.UnitTest; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; @@ -23,7 +23,7 @@ public class ByPackageNameMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest(); @@ -35,13 +35,14 @@ public void init() { @Test public void getStringRepresentationOfPassedCharacteristic_happyPath() { - unitTestBuilder.defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - MatcherAssert.assertThat("Should return qualified package name", AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().getStringRepresentationOfPassedCharacteristic("abc").equals("abc")); + unitTestBuilder.defineTest(new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - } - }) + MatcherAssert.assertThat("Should return qualified package name", AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().getStringRepresentationOfPassedCharacteristic("abc").equals("abc")); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -49,13 +50,14 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen @Test public void getStringRepresentationOfPassedCharacteristic_passedNullValue_shouldReturnNull() { - unitTestBuilder.defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - MatcherAssert.assertThat("Should return null for null valued parameter", AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().getStringRepresentationOfPassedCharacteristic(null) == null); + unitTestBuilder.defineTest(new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + MatcherAssert.assertThat("Should return null for null valued parameter", AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().getStringRepresentationOfPassedCharacteristic(null) == null); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -64,14 +66,15 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen @Test public void checkForMatchingCharacteristic_match() { - unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - MatcherAssert.assertThat("Should find match correctly", AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, this.getClass().getPackage().getName())); + MatcherAssert.assertThat("Should find match correctly", AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, this.getClass().getPackage().getName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -79,13 +82,14 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement el @Test public void checkForMatchingCharacteristic_mismatch() { - unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should find match correctly", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, "xyz")); + unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - } - }) + MatcherAssert.assertThat("Should find match correctly", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, "xyz")); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -93,19 +97,20 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement el @Test public void checkForMatchingCharacteristic_mismatch_checkErrorMessage() { - unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - ToolingProvider.setTooling(processingEnvironment); - AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, "xyz"); - FluentElementValidator.createFluentElementValidator(element) - .applyValidator(AptkCoreMatchers.BY_PACKAGE_NAME) - .hasOneOf("abc") - .validateAndIssueMessages(); - ToolingProvider.clearTooling(); - - } - }) + unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + ToolingProvider.setTooling(processingEnvironment); + AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, "xyz"); + FluentElementValidator.createFluentElementValidator(element) + .applyValidator(AptkCoreMatchers.BY_PACKAGE_NAME) + .hasOneOf("abc") + .validateAndIssueMessages(); + ToolingProvider.clearTooling(); + + } + }) .compilationShouldFail() .expectErrorMessageThatContains("(enclosing) PackageElement must have one of the following qualified names: [abc]") .executeTest(); @@ -114,13 +119,14 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement el @Test public void checkForMatchingCharacteristic_nullValuedElement() { - unitTestBuilder.defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(null, "xyz")); + unitTestBuilder.defineTest(new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(null, "xyz")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -128,13 +134,14 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element elemen @Test public void checkForMatchingCharacteristic_nullValuedRawType() { - unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, null)); + unitTestBuilder.defineTestWithPassedInElement(this.getClass(), new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - } - }) + MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(element, null)); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -142,13 +149,14 @@ public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement el @Test public void checkForMatchingCharacteristic_nullValuedElementAndRawType() { - unitTestBuilder.defineTest(new UnitTest() { - @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { - MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(null, null)); + unitTestBuilder.defineTest(new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_PACKAGE_NAME.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeFqnMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeFqnMatcherTest.java index 63423279..26e712f1 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeFqnMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeFqnMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.Utilities; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -23,7 +25,7 @@ */ public class ByParameterTypeFqnMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -36,25 +38,27 @@ public void init() { @Test public void byParameterTypeMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); - MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); + MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName()))); - } - }) + MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName()))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -63,23 +67,25 @@ protected void testCase(TypeElement element) { @Test public void byParameterTypeMatcher_noMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName()))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName()))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName(), String.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName(), String.class.getCanonicalName()))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -87,24 +93,26 @@ protected void testCase(TypeElement element) { @Test public void byParameterTypeMatcher_nullValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName()))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -112,14 +120,16 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -127,14 +137,16 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepreentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName())), Matchers.is("[java.lang.String, java.lang.Boolean]")); + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName())), Matchers.is("[java.lang.String, java.lang.Boolean]")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMatcherTest.java index 80f06f27..763278ba 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMatcherTest.java @@ -1,18 +1,21 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.Utilities; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; +import io.toolisticon.cute.UnitTest; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -25,7 +28,7 @@ public class ByParameterTypeMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -38,25 +41,27 @@ public void init() { @Test public void byParameterTypeMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); - MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); + MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class, String.class))); - } - }) + MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class, String.class))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -72,30 +77,32 @@ public void methodWithGenericParameter(List values, String secondParameter @Test public void byParameterTypeMatcher_match_withGenericType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element1) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - // First get test class - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(GenericTypeTestClass.class); - MatcherAssert.assertThat("Precondition: should have found the testclass", typeElement, Matchers.notNullValue()); + // First get test class + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(GenericTypeTestClass.class); + MatcherAssert.assertThat("Precondition: should have found the testclass", typeElement, Matchers.notNullValue()); - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "methodWithGenericParameter"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "methodWithGenericParameter"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 5 parameters", executableElement.getParameters().size() == 5); - MatcherAssert.assertThat("Precondition: first parameter must be of type List but is " + executableElement.getParameters().get(0).asType().toString(), TypeUtils.getTypes().erasure(executableElement.getParameters().get(0).asType()).toString().equals(List.class.getCanonicalName())); - MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 5 parameters", executableElement.getParameters().size() == 5); + MatcherAssert.assertThat("Precondition: first parameter must be of type List but is " + executableElement.getParameters().get(0).asType().toString(), TypeUtils.getTypes().erasure(executableElement.getParameters().get(0).asType()).toString().equals(List.class.getCanonicalName())); + MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(List.class, String.class, int.class, int[].class, List[].class))); + MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(List.class, String.class, int.class, int[].class, List[].class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -104,23 +111,25 @@ protected void testCase(TypeElement element1) { @Test public void byParameterTypeMatcher_noMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(String.class, Boolean.class))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class, String.class, String.class))); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - } - }) + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(String.class, Boolean.class))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class, String.class, String.class))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -128,23 +137,25 @@ protected void testCase(TypeElement element) { @Test public void byParameterTypeMatcher_nullValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(null, Utilities.convertVarargsToArray(String.class, Boolean.class))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(null, Utilities.convertVarargsToArray(String.class, Boolean.class))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -152,15 +163,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -168,16 +179,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(Utilities.convertVarargsToArray(String.class, Boolean.class)), Matchers.is("[java.lang.String, java.lang.Boolean]")); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_PARAMETER_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(Utilities.convertVarargsToArray(String.class, Boolean.class)), Matchers.is("[java.lang.String, java.lang.Boolean]")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMirrorMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMirrorMatcherTest.java index fc0f94f2..b42d8927 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMirrorMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByParameterTypeMirrorMatcherTest.java @@ -1,18 +1,20 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.Utilities; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -23,7 +25,7 @@ */ public class ByParameterTypeMirrorMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -36,25 +38,27 @@ public void init() { @Test public void byParameterTypeMirrorMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found element has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); - MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found element has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); + MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class)))); - } - }) + MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class)))); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -70,28 +74,29 @@ public void methodWithGenericParameter(List values, String secondParameter @Test public void byParameterTypeMirrorMatcher_match_withGenericParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // First get testclass - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(GenericTypeTestClass.class); - MatcherAssert.assertThat("Precondition: should have found the testclass", typeElement, Matchers.notNullValue()); + // First get testclass + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(GenericTypeTestClass.class); + MatcherAssert.assertThat("Precondition: should have found the testclass", typeElement, Matchers.notNullValue()); - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "methodWithGenericParameter"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found element has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "methodWithGenericParameter"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found element has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 5 parameters", executableElement.getParameters().size() == 5); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 5 parameters", executableElement.getParameters().size() == 5); - MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(List.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(int.class), TypeUtils.TypeRetrieval.getTypeMirror(int[].class), TypeUtils.TypeRetrieval.getTypeMirror(List[].class)))); + MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(List.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(int.class), TypeUtils.TypeRetrieval.getTypeMirror(int[].class), TypeUtils.TypeRetrieval.getTypeMirror(List[].class)))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -99,24 +104,26 @@ protected void testCase(TypeElement element) { @Test public void byParameterTypeMirrorMatcher_noMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class)))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class)))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class)))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class)))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class)))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(String.class)))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -124,23 +131,24 @@ protected void testCase(TypeElement element) { @Test public void byParameterTypeMirrorMatcher_nullValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class)))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class)))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -148,14 +156,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -163,15 +172,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class))), Matchers.is("[java.lang.String, java.lang.Boolean]")); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_PARAMETER_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(Utilities.convertVarargsToArray(TypeUtils.TypeRetrieval.getTypeMirror(String.class), TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class))), Matchers.is("[java.lang.String, java.lang.Boolean]")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeFqnMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeFqnMatcherTest.java index 6d682d3f..98472b76 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeFqnMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeFqnMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; -import io.toolisticon.aptk.tools.TestAnnotation; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; +import io.toolisticon.cute.TestAnnotation; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -20,7 +22,7 @@ public class ByRawTypeFqnMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -33,11 +35,13 @@ public void init() { @Test public void getStringRepresentationOfPassedCharacteristic_happyPath() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return cannonical class name of annotation class", AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(ByRawTypeFqnMatcherTest.class.getCanonicalName()).equals(ByRawTypeFqnMatcherTest.class.getCanonicalName())); + + MatcherAssert.assertThat("Should return cannonical class name of annotation class", AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(ByRawTypeFqnMatcherTest.class.getCanonicalName()).equals(ByRawTypeFqnMatcherTest.class.getCanonicalName())); } }) @@ -48,11 +52,13 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_passedNullValue_shouldReturnNull() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - MatcherAssert.assertThat("Should return null for null valued parameter", AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null) == null); + MatcherAssert.assertThat("Should return null for null valued parameter", AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null) == null); } }) @@ -63,11 +69,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(ByRawTypeFqnMatcherTest.class); + TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(ByRawTypeFqnMatcherTest.class); MatcherAssert.assertThat("Should find match correctly", AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(tmpElement, ByRawTypeFqnMatcherTest.class.getCanonicalName())); } @@ -79,11 +86,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_mismatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(String.class); MatcherAssert.assertThat("Should find match correctly", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(tmpElement, ByRawTypeFqnMatcherTest.class.getCanonicalName())); } @@ -95,11 +103,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_nullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, TestAnnotation.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, TestAnnotation.class.getCanonicalName())); } }) @@ -110,11 +119,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_nullValuedRawType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued annotation", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false in case of null valued annotation", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(element, null)); } }) @@ -125,11 +135,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_nullValuedElementAndRawType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued parameters", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should return false in case of null valued parameters", !AptkCoreMatchers.BY_RAW_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeMatcherTest.java index ea809a76..b527386b 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByRawTypeMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; +import io.toolisticon.cute.TestAnnotation; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -20,7 +22,7 @@ public class ByRawTypeMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -33,11 +35,12 @@ public void init() { @Test public void getStringRepresentationOfPassedCharacteristic_happyPath() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return cannonical class name of annotation class", AptkCoreMatchers.BY_RAW_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(ByRawTypeMatcherTest.class).equals(ByRawTypeMatcherTest.class.getCanonicalName())); + MatcherAssert.assertThat("Should return cannonical class name of annotation class", AptkCoreMatchers.BY_RAW_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(ByRawTypeMatcherTest.class).equals(ByRawTypeMatcherTest.class.getCanonicalName())); } }) @@ -48,11 +51,12 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_passedNullValue_shouldReturnNull() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return null for null valued parameter", AptkCoreMatchers.BY_RAW_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(null) == null); + MatcherAssert.assertThat("Should return null for null valued parameter", AptkCoreMatchers.BY_RAW_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(null) == null); } }) @@ -63,11 +67,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(ByRawTypeMatcherTest.class); + TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(ByRawTypeMatcherTest.class); MatcherAssert.assertThat("Should find match correctly", AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(tmpElement, ByRawTypeMatcherTest.class)); } @@ -79,11 +84,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_mismatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(String.class); + TypeElement tmpElement = TypeUtils.TypeRetrieval.getTypeElement(String.class); MatcherAssert.assertThat("Should find match correctly", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(tmpElement, ByRawTypeMatcherTest.class)); } @@ -95,11 +101,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_nullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(null, TestAnnotation.class)); + MatcherAssert.assertThat("Should return false in case of null valued element", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(null, TestAnnotation.class)); } }) @@ -110,11 +117,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_nullValuedRawType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued annotation", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false in case of null valued annotation", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(element, null)); } }) @@ -125,11 +133,12 @@ protected void testCase(TypeElement element) { @Test public void checkForMatchingCharacteristic_nullValuedElementAndRawType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false in case of null valued parameters", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should return false in case of null valued parameters", !AptkCoreMatchers.BY_RAW_TYPE.getMatcher().checkForMatchingCharacteristic(null, null)); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeFqnMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeFqnMatcherTest.java index 0e8e91d7..fee41c54 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeFqnMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeFqnMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -23,7 +25,7 @@ public class ByReturnTypeFqnMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -36,25 +38,26 @@ public void init() { @Test public void byReturnTypeMirrorMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching return type", AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, String.class.getCanonicalName())); + MatcherAssert.assertThat("Should have found matching return type", AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -62,24 +65,25 @@ protected void testCase(TypeElement element) { @Test public void byReturnTypeMirrorMatcher_noMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found a non matching return type", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Boolean.class.getCanonicalName())); + MatcherAssert.assertThat("Should have found a non matching return type", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Boolean.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -87,25 +91,26 @@ protected void testCase(TypeElement element) { @Test public void byReturnTypeMirrorMatcher_nullValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, String.class.getCanonicalName())); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, String.class.getCanonicalName())); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -113,14 +118,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.is("")); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.is("")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -128,14 +134,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class.getCanonicalName()), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_RETURN_TYPE_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class.getCanonicalName()), Matchers.is(String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMatcherTest.java index d04a0e0c..fa1837c4 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -22,7 +24,7 @@ */ public class ByReturnTypeMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -35,24 +37,25 @@ public void init() { @Test public void byReturnTypeMirrorMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching return type", AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, String.class)); + MatcherAssert.assertThat("Should have found matching return type", AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -60,24 +63,25 @@ protected void testCase(TypeElement element) { @Test public void byReturnTypeMirrorMatcher_noMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found a non matching return type", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Boolean.class)); + MatcherAssert.assertThat("Should have found a non matching return type", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, Boolean.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -85,24 +89,25 @@ protected void testCase(TypeElement element) { @Test public void byReturnTypeMirrorMatcher_nullValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(null, String.class)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(null, String.class)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -110,14 +115,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.is("")); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.is("")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -125,14 +131,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresetation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_RETURN_TYPE.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class), Matchers.is(String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMirrorMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMirrorMatcherTest.java index f8d170a8..66d042ce 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMirrorMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ByReturnTypeMirrorMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -23,7 +25,7 @@ */ public class ByReturnTypeMirrorMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -36,24 +38,25 @@ public void init() { @Test public void byReturnTypeMirrorMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching return type", AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat("Should have found matching return type", AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -61,24 +64,25 @@ protected void testCase(TypeElement element) { @Test public void byReturnTypeMirrorMatcher_noMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found a non matching return type", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class))); + MatcherAssert.assertThat("Should have found a non matching return type", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, TypeUtils.TypeRetrieval.getTypeMirror(Boolean.class))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -86,25 +90,26 @@ protected void testCase(TypeElement element) { @Test public void byReturnTypeMirrorMatcher_nullValues() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); - MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have a return type", executableElement.getReturnType(), Matchers.notNullValue()); + MatcherAssert.assertThat("Precondition: return type must be of type String but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getReturnType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, TypeUtils.TypeRetrieval.getTypeMirror(String.class))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, null)); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, TypeUtils.TypeRetrieval.getTypeMirror(String.class))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(executableElement, null)); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -112,15 +117,16 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.is("")); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.is("")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -128,15 +134,16 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(TypeUtils.TypeRetrieval.getTypeMirror(String.class)), Matchers.is(String.class.getCanonicalName())); + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.BY_RETURN_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(TypeUtils.TypeRetrieval.getTypeMirror(String.class)), Matchers.is(String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasPublicNoargConstructorMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasPublicNoargConstructorMatcherTest.java index 544d2b64..8504e0a6 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasPublicNoargConstructorMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/HasPublicNoargConstructorMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; @@ -60,7 +62,7 @@ public enum TestEnum { TEST } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -73,16 +75,17 @@ public void init() { @Test public void checkDefaultConstructor() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(DefaultNoargConstructor.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(DefaultNoargConstructor.class); - MatcherAssert.assertThat("Must return true for class with default constructor", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); + MatcherAssert.assertThat("Must return true for class with default constructor", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -90,17 +93,18 @@ protected void testCase(TypeElement element) { @Test public void checkWithNoargConstructor() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(NonNoargConstructor.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(NonNoargConstructor.class); - MatcherAssert.assertThat("Must return false for class with no noarg constructor", !AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); + MatcherAssert.assertThat("Must return false for class with no noarg constructor", !AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -109,17 +113,18 @@ protected void testCase(TypeElement element) { @Test public void checkWithPublicNoargConstructor() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(NoPublicNoargConstructor.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(NoPublicNoargConstructor.class); - MatcherAssert.assertThat("Must return false for class with no public noarg constructor", !AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); + MatcherAssert.assertThat("Must return false for class with no public noarg constructor", !AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -127,17 +132,18 @@ protected void testCase(TypeElement element) { @Test public void checkWithPublicNoargConstructorNextToOtherConstructor() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(PublicNoargConstructorNextToOtherConstructors.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(PublicNoargConstructorNextToOtherConstructors.class); - MatcherAssert.assertThat("Must return true for class with default constructor", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); + MatcherAssert.assertThat("Must return true for class with default constructor", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(typeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -145,20 +151,21 @@ protected void testCase(TypeElement element) { @Test public void checkWithPublicNoargConstructorNextToOtherConstructors() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - Element testElement = FluentElementFilter.createFluentElementFilter( - TypeUtils.TypeRetrieval.getTypeElement(HasPublicNoargConstructorMatcherTest.class).getEnclosedElements() - ).applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testField") - .getResult().get(0); + Element testElement = FluentElementFilter.createFluentElementFilter( + TypeUtils.TypeRetrieval.getTypeElement(HasPublicNoargConstructorMatcherTest.class).getEnclosedElements() + ).applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf("testField") + .getResult().get(0); - MatcherAssert.assertThat("Must return true for class with default constructor", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(testElement)); + MatcherAssert.assertThat("Must return true for class with default constructor", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(testElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -166,14 +173,15 @@ protected void testCase(TypeElement element) { @Test public void checkestNullSafety() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Must return false for null valued parameter", !AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(null)); + MatcherAssert.assertThat("Must return false for null valued parameter", !AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -186,14 +194,15 @@ protected void testCase(TypeElement element) { @Test public void checkestLombokNoConstructoButWithAllArgConstructorAnnotation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Must return false for Class with arg constructor annotated with NoArgsConstructor annotation", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(element)); + MatcherAssert.assertThat("Must return false for Class with arg constructor annotated with NoArgsConstructor annotation", AptkCoreMatchers.HAS_PUBLIC_NOARG_CONSTRUCTOR.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAnnotationTypeMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAnnotationTypeMatcherTest.java index c49f8a21..2ccfccac 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAnnotationTypeMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAnnotationTypeMatcherTest.java @@ -1,15 +1,17 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -19,7 +21,7 @@ public class IsAnnotationTypeMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -32,17 +34,18 @@ public void init() { @Test public void checkMatchingAnnotationType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(Override.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(Override.class); - MatcherAssert.assertThat("Should return true for annotation type : ", AptkCoreMatchers.IS_ANNOTATION_TYPE.getMatcher().check(typeElement)); + MatcherAssert.assertThat("Should return true for annotation type : ", AptkCoreMatchers.IS_ANNOTATION_TYPE.getMatcher().check(typeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -50,15 +53,16 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAnnotationType() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non annotation (class) : ", !AptkCoreMatchers.IS_ANNOTATION_TYPE.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non annotation (class) : ", !AptkCoreMatchers.IS_ANNOTATION_TYPE.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -66,14 +70,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ANNOTATION_TYPE.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ANNOTATION_TYPE.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToFqnMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToFqnMatcherTest.java index d6582b6f..411ee858 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToFqnMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToFqnMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -20,7 +22,7 @@ public class IsAssignableToFqnMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -33,15 +35,16 @@ public void init() { @Test public void checkMatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class.getCanonicalName())); + MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -50,15 +53,16 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -67,17 +71,18 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElementAndClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(null, String.class.getCanonicalName())); - MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(element, null)); - MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(null, String.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -85,14 +90,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -100,14 +106,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToMatcherTest.java index dbaa0ff7..60edbd73 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -20,7 +22,7 @@ public class IsAssignableToMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -33,15 +35,16 @@ public void init() { @Test public void checkMatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class)); + MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -50,15 +53,16 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class)); + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -67,17 +71,18 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElementAndClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(null, String.class)); - MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(element, null)); - MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(null, String.class)); + MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -85,14 +90,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -100,14 +106,14 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToTypeMirrorMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToTypeMirrorMatcherTest.java index c3a6a2b2..2b3c260b 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToTypeMirrorMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAssignableToTypeMirrorMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeMirrorWrapper; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -21,7 +23,7 @@ public class IsAssignableToTypeMirrorMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -34,15 +36,16 @@ public void init() { @Test public void checkMatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), TypeMirrorWrapper.wrap(Object.class).unwrap())); + MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), TypeMirrorWrapper.wrap(Object.class).unwrap())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -51,15 +54,16 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), TypeMirrorWrapper.wrap(String.class).unwrap())); + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), TypeMirrorWrapper.wrap(String.class).unwrap())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -68,17 +72,17 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElementAndClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, TypeMirrorWrapper.wrap(String.class).unwrap())); + MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, null)); - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, TypeMirrorWrapper.wrap(String.class).unwrap())); - MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(element, null)); - MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().checkForMatchingCharacteristic(null, null)); - - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -86,14 +90,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -101,14 +106,15 @@ protected void testCase(TypeElement element) { @Test public void getStringRepresentationOfPassedCharacteristic_getStringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_ASSIGNABLE_TO_TYPE_MIRROR.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAttributeFieldMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAttributeFieldMatcherTest.java index 9662d93c..df84d10d 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAttributeFieldMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsAttributeFieldMatcherTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; @@ -9,6 +9,7 @@ import org.hamcrest.MatcherAssert; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import java.util.List; @@ -51,18 +52,20 @@ public void test_isAttributeField_match__shouldReturnTrue() { CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorUnitTestClassInternal.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Do test - MatcherAssert.assertThat("Should return true for non static field with getter and setter : ", - AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("validAttributeField"))); + // Do test + MatcherAssert.assertThat("Should return true for non static field with getter and setter : ", + AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("validAttributeField"))); - } - }) + } + + }) .compilationShouldSucceed() .executeTest(); ; @@ -75,18 +78,19 @@ public void test_isNoAttributeField_noGetter_shouldReturnFalse() { CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorUnitTestClassInternal.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Do test - MatcherAssert.assertThat("Should return false for non static field without getter : ", - !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("fieldWithoutGetter"))); + // Do test + MatcherAssert.assertThat("Should return false for non static field without getter : ", + !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("fieldWithoutGetter"))); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); ; @@ -99,18 +103,19 @@ public void test_isNoAttributeField_noSetter_shouldReturnFalse() { CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorUnitTestClassInternal.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Do test - MatcherAssert.assertThat("Should return false for non static field without setter : ", - !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("fieldWithoutSetter"))); + // Do test + MatcherAssert.assertThat("Should return false for non static field without setter : ", + !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("fieldWithoutSetter"))); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); ; @@ -123,18 +128,19 @@ public void test_isNoAttributeField_isStatic_shouldReturnFalse() { CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorUnitTestClassInternal.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Do test - MatcherAssert.assertThat("Should return false for static field : ", - !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("staticField"))); + // Do test + MatcherAssert.assertThat("Should return false for static field : ", + !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(getField("staticField"))); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); ; @@ -147,18 +153,19 @@ public void test_passedNullValue_shouldReturnFalse() { CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorUnitTestClassInternal.java")) - .useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + .defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // Do test - MatcherAssert.assertThat("Should return false for passed null value : ", - !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(null)); + // Do test + MatcherAssert.assertThat("Should return false for passed null value : ", + !AptkCoreMatchers.IS_ATTRIBUTE_FIELD.getMatcher().check(null)); - } + } - }) + }) .compilationShouldSucceed() .executeTest(); ; @@ -168,8 +175,8 @@ protected void testCase(TypeElement element) { private static VariableElement getField(String fieldName) { List variableElement = FluentElementFilter.createFluentElementFilter( - TypeUtils.TypeRetrieval.getTypeElement(TestClass.class) - .getEnclosedElements()) + TypeUtils.TypeRetrieval.getTypeElement(TestClass.class) + .getEnclosedElements()) .applyFilter(AptkCoreMatchers.IS_FIELD) .applyFilter(AptkCoreMatchers.BY_NAME).filterByOneOf(fieldName) .getResult(); diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsClassMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsClassMatcherTest.java index e04e54bc..68799454 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsClassMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsClassMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; @@ -28,7 +30,7 @@ public enum TestEnum { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -41,15 +43,16 @@ public void init() { @Test public void checkMatchingCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for class : ", AptkCoreMatchers.IS_CLASS.getMatcher().check(element)); + MatcherAssert.assertThat("Should return true for class : ", AptkCoreMatchers.IS_CLASS.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -57,19 +60,20 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingClass_enum() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsClassMatcherTest.class); - List enums = ElementUtils.AccessEnclosedElements.getEnclosedElementsOfKind(typeElement, ElementKind.ENUM); - MatcherAssert.assertThat("Precondition: must have found a enum", enums.size() >= 1); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsClassMatcherTest.class); + List enums = ElementUtils.AccessEnclosedElements.getEnclosedElementsOfKind(typeElement, ElementKind.ENUM); + MatcherAssert.assertThat("Precondition: must have found a enum", enums.size() >= 1); - MatcherAssert.assertThat("Should return false for enum : ", !AptkCoreMatchers.IS_CLASS.getMatcher().check(enums.get(0))); + MatcherAssert.assertThat("Should return false for enum : ", !AptkCoreMatchers.IS_CLASS.getMatcher().check(enums.get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -77,14 +81,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_CLASS.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_CLASS.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsConstructorMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsConstructorMatcherTest.java index 78a64069..9929d989 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsConstructorMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsConstructorMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; @@ -22,7 +24,7 @@ */ public class IsConstructorMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -35,19 +37,20 @@ public void init() { @Test public void checkMatchingConstructor() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsConstructorMatcherTest.class); - List constructors = ElementUtils.AccessEnclosedElements.getEnclosedElementsOfKind(typeElement, ElementKind.CONSTRUCTOR); - MatcherAssert.assertThat("Precondition: must have found a enum", constructors.size() >= 1); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsConstructorMatcherTest.class); + List constructors = ElementUtils.AccessEnclosedElements.getEnclosedElementsOfKind(typeElement, ElementKind.CONSTRUCTOR); + MatcherAssert.assertThat("Precondition: must have found a enum", constructors.size() >= 1); - MatcherAssert.assertThat("Should return true for enum : ", AptkCoreMatchers.IS_CONSTRUCTOR.getMatcher().check(constructors.get(0))); + MatcherAssert.assertThat("Should return true for enum : ", AptkCoreMatchers.IS_CONSTRUCTOR.getMatcher().check(constructors.get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -55,14 +58,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingConstructor() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non constructor : ", !AptkCoreMatchers.IS_CONSTRUCTOR.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non constructor : ", !AptkCoreMatchers.IS_CONSTRUCTOR.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -70,14 +74,15 @@ protected void testCase(TypeElement element) { @Test public void checknullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_CONSTRUCTOR.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_CONSTRUCTOR.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsEnumMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsEnumMatcherTest.java index 9c3133a2..e83f6bb7 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsEnumMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsEnumMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import java.util.List; @@ -26,7 +28,7 @@ public enum TestEnum { TEST } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -39,19 +41,20 @@ public void init() { @Test public void checkMatchingEnum() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsEnumMatcherTest.class); - List enumList = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "TestEnum"); - MatcherAssert.assertThat("Precondition: must have found a enum", enumList.size() >= 1); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsEnumMatcherTest.class); + List enumList = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "TestEnum"); + MatcherAssert.assertThat("Precondition: must have found a enum", enumList.size() >= 1); - MatcherAssert.assertThat("Should return true for enum : ", AptkCoreMatchers.IS_ENUM.getMatcher().check(enumList.get(0))); + MatcherAssert.assertThat("Should return true for enum : ", AptkCoreMatchers.IS_ENUM.getMatcher().check(enumList.get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -59,14 +62,15 @@ protected void testCase(TypeElement element) { @Test public void checkMisatchingEnum_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non enum : ", !AptkCoreMatchers.IS_ENUM.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non enum : ", !AptkCoreMatchers.IS_ENUM.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -74,14 +78,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ENUM.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_ENUM.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsExecutableElementMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsExecutableElementMatcherTest.java index 044c9fe0..a620d711 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsExecutableElementMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsExecutableElementMatcherTest.java @@ -1,15 +1,17 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -20,7 +22,7 @@ */ public class IsExecutableElementMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -33,20 +35,21 @@ public void init() { @Test public void checkMatchingExecutableElement_method() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: found method has to be of type ExecutableElement", result.get(0) instanceof ExecutableElement); - MatcherAssert.assertThat("Should return true for method : ", AptkCoreMatchers.IS_EXECUTABLE_ELEMENT.getMatcher().check(result.get(0))); + MatcherAssert.assertThat("Should return true for method : ", AptkCoreMatchers.IS_EXECUTABLE_ELEMENT.getMatcher().check(result.get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -54,14 +57,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingExecutableElement_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non ExecutableElement : ", !AptkCoreMatchers.IS_EXECUTABLE_ELEMENT.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non ExecutableElement : ", !AptkCoreMatchers.IS_EXECUTABLE_ELEMENT.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -69,14 +73,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_EXECUTABLE_ELEMENT.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_EXECUTABLE_ELEMENT.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsFieldMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsFieldMatcherTest.java index c9d5c8ab..b2357981 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsFieldMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsFieldMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import java.util.List; @@ -25,7 +27,7 @@ public class IsFieldMatcherTest { public String testField = "XXX"; - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -38,19 +40,20 @@ public void init() { @Test public void checkMatchingInterface() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsFieldMatcherTest.class); - List fieldList = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "testField"); - MatcherAssert.assertThat("Precondition: must have found a field", fieldList.size() >= 1); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsFieldMatcherTest.class); + List fieldList = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "testField"); + MatcherAssert.assertThat("Precondition: must have found a field", fieldList.size() >= 1); - MatcherAssert.assertThat("Should return true for field : ", AptkCoreMatchers.IS_FIELD.getMatcher().check(fieldList.get(0))); + MatcherAssert.assertThat("Should return true for field : ", AptkCoreMatchers.IS_FIELD.getMatcher().check(fieldList.get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -58,14 +61,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingMethod_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non field : ", !AptkCoreMatchers.IS_FIELD.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non field : ", !AptkCoreMatchers.IS_FIELD.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -73,14 +77,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_FIELD.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_FIELD.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsGetterMethodMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsGetterMethodMatcherTest.java index ac6609a7..899f3e1a 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsGetterMethodMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsGetterMethodMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import java.util.List; @@ -68,7 +70,7 @@ public String isGetterInvalid() { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -81,26 +83,27 @@ public void init() { @Test public void checkMatchingInterface() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - checkGetter(typeElement, "getNoReturnType", false); - checkGetter(typeElement, "getNonVisible", false); - checkGetter(typeElement, "getIsStatic", false); - checkGetter(typeElement, "getIsAbstract", false); - checkGetter(typeElement, "getValid", true); - checkGetter(typeElement, "getGetterValid", true); - checkGetter(typeElement, "hasGetterValid", true); - checkGetter(typeElement, "isGetterValid", true); - checkGetter(typeElement, "hasGetterInvalid", false); - checkGetter(typeElement, "isGetterInvalid", false); + checkGetter(typeElement, "getNoReturnType", false); + checkGetter(typeElement, "getNonVisible", false); + checkGetter(typeElement, "getIsStatic", false); + checkGetter(typeElement, "getIsAbstract", false); + checkGetter(typeElement, "getValid", true); + checkGetter(typeElement, "getGetterValid", true); + checkGetter(typeElement, "hasGetterValid", true); + checkGetter(typeElement, "isGetterValid", true); + checkGetter(typeElement, "hasGetterInvalid", false); + checkGetter(typeElement, "isGetterInvalid", false); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -109,15 +112,16 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_GETTER_METHOD.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_GETTER_METHOD.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsInterfaceMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsInterfaceMatcherTest.java index d45b1b99..7fb8e92d 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsInterfaceMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsInterfaceMatcherTest.java @@ -1,15 +1,17 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import java.io.Serializable; @@ -19,7 +21,7 @@ */ public class IsInterfaceMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -32,15 +34,16 @@ public void init() { @Test public void checkMatchingInterface() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(Serializable.class); - MatcherAssert.assertThat("Should return true for interface : ", AptkCoreMatchers.IS_INTERFACE.getMatcher().check(typeElement)); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(Serializable.class); + MatcherAssert.assertThat("Should return true for interface : ", AptkCoreMatchers.IS_INTERFACE.getMatcher().check(typeElement)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -49,15 +52,16 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingMethod_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non method : ", !AptkCoreMatchers.IS_INTERFACE.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non method : ", !AptkCoreMatchers.IS_INTERFACE.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -65,14 +69,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_INTERFACE.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_INTERFACE.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsMethodMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsMethodMatcherTest.java index c594fa7d..30c07d9a 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsMethodMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsMethodMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import java.util.List; @@ -26,7 +28,7 @@ public void testMethod(String parameter) { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -39,18 +41,18 @@ public void init() { @Test public void checkMatchingMethod() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsParameterMatcherTest.class); + List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "testMethod"); + MatcherAssert.assertThat("Precondition: found test method", methods.size() == 1); - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsParameterMatcherTest.class); - List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "testMethod"); - MatcherAssert.assertThat("Precondition: found test method", methods.size() == 1); + MatcherAssert.assertThat("Should return true for method : ", AptkCoreMatchers.IS_METHOD.getMatcher().check(methods.get(0))); - MatcherAssert.assertThat("Should return true for method : ", AptkCoreMatchers.IS_METHOD.getMatcher().check(methods.get(0))); - - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -58,14 +60,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingMethod() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non method : ", !AptkCoreMatchers.IS_METHOD.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non method : ", !AptkCoreMatchers.IS_METHOD.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -73,14 +76,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_METHOD.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_METHOD.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageElementMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageElementMatcherTest.java index aab17317..c9789af8 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageElementMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageElementMatcherTest.java @@ -1,15 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; +import io.toolisticon.cute.UnitTest; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.PackageElement; @@ -20,7 +24,7 @@ */ public class IsPackageElementMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -33,11 +37,12 @@ public void init() { @Test public void checkMatchingPackageElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field + // find field Element result = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(element, ElementKind.PACKAGE); MatcherAssert.assertThat("Precondition: should have found one method", result != null); MatcherAssert.assertThat("Precondition: found method has to be of type PackageElement", result instanceof PackageElement); @@ -53,11 +58,12 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingPackageElement_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non PackageElement : ", !AptkCoreMatchers.IS_PACKAGE_ELEMENT.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non PackageElement : ", !AptkCoreMatchers.IS_PACKAGE_ELEMENT.getMatcher().check(element)); } }) @@ -68,11 +74,12 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new UnitTest() { + @Override + public void unitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_PACKAGE_ELEMENT.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_PACKAGE_ELEMENT.getMatcher().check(null)); } }) diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageMatcherTest.java index 8e7c0585..37f69a1d 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsPackageMatcherTest.java @@ -1,15 +1,17 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.PackageElement; @@ -22,7 +24,7 @@ public class IsPackageMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -35,20 +37,21 @@ public void init() { @Test public void checkMatchingPackage() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - Element result = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(element, ElementKind.PACKAGE); - MatcherAssert.assertThat("Precondition: should have found one method", result != null); - MatcherAssert.assertThat("Precondition: found method has to be of type package", result instanceof PackageElement); + // find field + Element result = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(element, ElementKind.PACKAGE); + MatcherAssert.assertThat("Precondition: should have found one method", result != null); + MatcherAssert.assertThat("Precondition: found method has to be of type package", result instanceof PackageElement); - MatcherAssert.assertThat("Should return true for method : ", AptkCoreMatchers.IS_PACKAGE.getMatcher().check(result)); + MatcherAssert.assertThat("Should return true for method : ", AptkCoreMatchers.IS_PACKAGE.getMatcher().check(result)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -56,14 +59,14 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingPackageElement_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should return false for non Package : ", !AptkCoreMatchers.IS_PACKAGE.getMatcher().check(element)); - MatcherAssert.assertThat("Should return false for non Package : ", !AptkCoreMatchers.IS_PACKAGE.getMatcher().check(element)); - - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -71,14 +74,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_PACKAGE.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_PACKAGE.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsParameterMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsParameterMatcherTest.java index af9defba..31db1b02 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsParameterMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsParameterMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -27,7 +29,7 @@ public void testMethod(String parameter) { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -40,20 +42,21 @@ public void init() { @Test public void checkMatchingParameter() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsParameterMatcherTest.class); - List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "testMethod"); - MatcherAssert.assertThat("Precondition: found test method", methods.size() == 1); - ExecutableElement testMethod = (ExecutableElement) methods.get(0); - MatcherAssert.assertThat("Precondition: found at least one parameter", ((ExecutableElement) methods.get(0)).getParameters().size() >= 1); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(IsParameterMatcherTest.class); + List methods = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(typeElement, "testMethod"); + MatcherAssert.assertThat("Precondition: found test method", methods.size() == 1); + ExecutableElement testMethod = (ExecutableElement) methods.get(0); + MatcherAssert.assertThat("Precondition: found at least one parameter", ((ExecutableElement) methods.get(0)).getParameters().size() >= 1); - MatcherAssert.assertThat("Should return true for parameter : ", AptkCoreMatchers.IS_PARAMETER.getMatcher().check(testMethod.getParameters().get(0))); + MatcherAssert.assertThat("Should return true for parameter : ", AptkCoreMatchers.IS_PARAMETER.getMatcher().check(testMethod.getParameters().get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -61,14 +64,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingParameter_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non parameter : ", !AptkCoreMatchers.IS_PARAMETER.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non parameter : ", !AptkCoreMatchers.IS_PARAMETER.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -76,14 +80,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_PARAMETER.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_PARAMETER.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsSetterMethodMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsSetterMethodMatcherTest.java index b9b7043d..ef908af9 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsSetterMethodMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsSetterMethodMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import java.util.List; @@ -59,7 +61,7 @@ public void testMethod(String parameter) { } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -72,23 +74,24 @@ public void init() { @Test public void checkMatchingInterface() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); + TypeElement typeElement = TypeUtils.TypeRetrieval.getTypeElement(TestClass.class); - checkSetter(typeElement, "setWithReturnType", false); - checkSetter(typeElement, "setNonVisible", false); - checkSetter(typeElement, "setHasMultipleParam", false); - checkSetter(typeElement, "setHasNoParam", false); - checkSetter(typeElement, "setIsStatic", false); - checkSetter(typeElement, "setIsAbstract", false); - checkSetter(typeElement, "xxxNameInvalid", false); - checkSetter(typeElement, "setValid", true); + checkSetter(typeElement, "setWithReturnType", false); + checkSetter(typeElement, "setNonVisible", false); + checkSetter(typeElement, "setHasMultipleParam", false); + checkSetter(typeElement, "setHasNoParam", false); + checkSetter(typeElement, "setIsStatic", false); + checkSetter(typeElement, "setIsAbstract", false); + checkSetter(typeElement, "xxxNameInvalid", false); + checkSetter(typeElement, "setValid", true); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -97,15 +100,16 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_SETTER_METHOD.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_SETTER_METHOD.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeElementMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeElementMatcherTest.java index 00863e15..95d36e4b 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeElementMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeElementMatcherTest.java @@ -1,15 +1,17 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.PackageElement; @@ -21,7 +23,7 @@ */ public class IsTypeElementMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -34,14 +36,15 @@ public void init() { @Test public void checkMatchingTypeElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non TypeElement : ", AptkCoreMatchers.IS_TYPE_ELEMENT.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non TypeElement : ", AptkCoreMatchers.IS_TYPE_ELEMENT.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -49,19 +52,20 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingTypeElement_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - Element result = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(element, ElementKind.PACKAGE); - MatcherAssert.assertThat("Precondition: should have found one method", result != null); - MatcherAssert.assertThat("Precondition: found method has to be of zype PackageElement", result instanceof PackageElement); + // find field + Element result = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(element, ElementKind.PACKAGE); + MatcherAssert.assertThat("Precondition: should have found one method", result != null); + MatcherAssert.assertThat("Precondition: found method has to be of zype PackageElement", result instanceof PackageElement); - MatcherAssert.assertThat("Should return false for package : ", !AptkCoreMatchers.IS_TYPE_ELEMENT.getMatcher().check(result)); + MatcherAssert.assertThat("Should return false for package : ", !AptkCoreMatchers.IS_TYPE_ELEMENT.getMatcher().check(result)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -69,14 +73,15 @@ protected void testCase(TypeElement element) { @Test public void checkNullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_TYPE_ELEMENT.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_TYPE_ELEMENT.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualFqnMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualFqnMatcherTest.java index 876e6684..70dd5c27 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualFqnMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualFqnMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import java.util.List; @@ -23,7 +25,7 @@ public class IsTypeEqualFqnMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -35,14 +37,16 @@ public void init() { @Test public void checkMatchingEqualToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), String.class.getCanonicalName())); - } - }) + MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), String.class.getCanonicalName())); + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -66,20 +70,23 @@ public static VariableElement getField(TypeElement typeElement, String fieldName @Test public void checkMatchingEqualToCase_intValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeElement testcaseElement = TypeUtils.TypeRetrieval.getTypeElement(MatcherTestCases.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + + TypeElement testcaseElement = TypeUtils.TypeRetrieval.getTypeElement(MatcherTestCases.class); - MatcherAssert.assertThat("Should return true for matching assignable to case (primitive) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intType"), int.class.getCanonicalName())); - MatcherAssert.assertThat("Should return true for matching assignable to case (array) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intArray"), int[].class.getCanonicalName())); - MatcherAssert.assertThat("Should return true for matching assignable to case (generic type) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericType"), List.class.getCanonicalName())); - MatcherAssert.assertThat("Should return true for matching assignable to case (generic type array) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericTypeArray"), List[].class.getCanonicalName())); + MatcherAssert.assertThat("Should return true for matching assignable to case (primitive) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intType"), int.class.getCanonicalName())); + MatcherAssert.assertThat("Should return true for matching assignable to case (array) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intArray"), int[].class.getCanonicalName())); + MatcherAssert.assertThat("Should return true for matching assignable to case (generic type) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericType"), List.class.getCanonicalName())); + MatcherAssert.assertThat("Should return true for matching assignable to case (generic type array) : ", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericTypeArray"), List[].class.getCanonicalName())); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -87,14 +94,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -102,58 +110,66 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase_Object() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class.getCanonicalName())); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } public void checkNullValuedElementAndClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(null, String.class.getCanonicalName())); - MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(element, null)); - MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(null, String.class.getCanonicalName())); + MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().checkForMatchingCharacteristic(null, null)); + + } + }) .compilationShouldSucceed() .executeTest(); } public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } public void getStringRepresentationOfPassedCharacteristic_getSTringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class.getCanonicalName()), Matchers.is("java.lang.String")); + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.IS_TYPE_EQUAL_FQN.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class.getCanonicalName()), Matchers.is("java.lang.String")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualMatcherTest.java index ce823187..fe1b0e1a 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsTypeEqualMatcherTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import java.util.List; @@ -23,7 +25,7 @@ public class IsTypeEqualMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -35,14 +37,15 @@ public void init() { @Test public void checkMatchingEqualToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), String.class)); + MatcherAssert.assertThat("Should return true for matching assignable to case : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -66,20 +69,22 @@ public static VariableElement getField(TypeElement typeElement, String fieldName @Test public void checkMatchingEqualToCase_intValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - TypeElement testcaseElement = TypeUtils.TypeRetrieval.getTypeElement(MatcherTestCases.class); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + TypeElement testcaseElement = TypeUtils.TypeRetrieval.getTypeElement(MatcherTestCases.class); - MatcherAssert.assertThat("Should return true for matching assignable to case (primitive) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intType"), int.class)); - MatcherAssert.assertThat("Should return true for matching assignable to case (array) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intArray"), int[].class)); - MatcherAssert.assertThat("Should return true for matching assignable to case (generic type) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericType"), List.class)); - MatcherAssert.assertThat("Should return true for matching assignable to case (generic type array) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericTypeArray"), List[].class)); + MatcherAssert.assertThat("Should return true for matching assignable to case (primitive) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intType"), int.class)); + MatcherAssert.assertThat("Should return true for matching assignable to case (array) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "intArray"), int[].class)); + MatcherAssert.assertThat("Should return true for matching assignable to case (generic type) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericType"), List.class)); + MatcherAssert.assertThat("Should return true for matching assignable to case (generic type array) : ", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(getField(testcaseElement, "genericTypeArray"), List[].class)); - } - }) + + } + }) .compilationShouldSucceed() .executeTest(); } @@ -87,14 +92,14 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class)); + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(Object.class), String.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -102,58 +107,62 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingAssignableToCase_Object() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class)); + MatcherAssert.assertThat("Should return false for mismatching assignable to case : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(TypeUtils.TypeRetrieval.getTypeElement(String.class), Object.class)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } public void checkNullValuedElementAndClass() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(null, String.class)); - MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(element, null)); - MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(null, null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(null, String.class)); + MatcherAssert.assertThat("Should return false for null valued assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(element, null)); + MatcherAssert.assertThat("Should return false for null valued element and assignable to class : ", !AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().checkForMatchingCharacteristic(null, null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } public void getStringRepresentationOfPassedCharacteristic_nullValue() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); + MatcherAssert.assertThat("Should not have found matching parameters", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().getStringRepresentationOfPassedCharacteristic(null), Matchers.nullValue()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } public void getStringRepresentationOfPassedCharacteristic_getSTringRepresentation() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class), Matchers.is("java.lang.String")); + MatcherAssert.assertThat("Should have created valid string representation", AptkCoreMatchers.IS_TYPE_EQUAL.getMatcher().getStringRepresentationOfPassedCharacteristic(String.class), Matchers.is("java.lang.String")); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsVariableElementMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsVariableElementMatcherTest.java index e0257ce3..f0147296 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsVariableElementMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/IsVariableElementMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.TypeUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; @@ -26,7 +28,7 @@ public class IsVariableElementMatcherTest { private String field = "sds"; - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationClassAttributeTestClass.java")); @@ -38,19 +40,20 @@ public void init() { @Test public void checkMatchingVariableElement_field() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsOfKind(TypeUtils.TypeRetrieval.getTypeElement(IsVariableElementMatcherTest.class), ElementKind.FIELD); - MatcherAssert.assertThat("Precondition: should have found one field", result.size() >= 1); - MatcherAssert.assertThat("Precondition: found method has to be of type VariableElement", result.get(0) instanceof VariableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsOfKind(TypeUtils.TypeRetrieval.getTypeElement(IsVariableElementMatcherTest.class), ElementKind.FIELD); + MatcherAssert.assertThat("Precondition: should have found one field", result.size() >= 1); + MatcherAssert.assertThat("Precondition: found method has to be of type VariableElement", result.get(0) instanceof VariableElement); - MatcherAssert.assertThat("Should return true for field : ", AptkCoreMatchers.IS_VARIABLE_ELEMENT.getMatcher().check(result.get(0))); + MatcherAssert.assertThat("Should return true for field : ", AptkCoreMatchers.IS_VARIABLE_ELEMENT.getMatcher().check(result.get(0))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -58,14 +61,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingVariableElement_class() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for non VariableElement : ", !AptkCoreMatchers.IS_VARIABLE_ELEMENT.getMatcher().check(element)); + MatcherAssert.assertThat("Should return false for non VariableElement : ", !AptkCoreMatchers.IS_VARIABLE_ELEMENT.getMatcher().check(element)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -73,14 +77,15 @@ protected void testCase(TypeElement element) { @Test public void checkMismatchingVariableElement_nullValuedElement() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_VARIABLE_ELEMENT.getMatcher().check(null)); + MatcherAssert.assertThat("Should return false for null valued element : ", !AptkCoreMatchers.IS_VARIABLE_ELEMENT.getMatcher().check(null)); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ParameterTypeFqnMatcherTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ParameterTypeFqnMatcherTest.java index 1c65818a..20485f8a 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ParameterTypeFqnMatcherTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/matcher/impl/ParameterTypeFqnMatcherTest.java @@ -1,16 +1,18 @@ package io.toolisticon.aptk.tools.matcher.impl; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.Utilities; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -22,7 +24,7 @@ */ public class ParameterTypeFqnMatcherTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -34,26 +36,27 @@ public void init() { @Test public void byParameterTypeFqnMatcher_match() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // find field - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + // find field + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); - MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + MatcherAssert.assertThat("Precondition: first parameter must be of type Boolean but is " + executableElement.getParameters().get(0).asType().toString(), executableElement.getParameters().get(0).asType().toString().equals(Boolean.class.getCanonicalName())); + MatcherAssert.assertThat("Precondition: second parameter must be of type String but is " + executableElement.getParameters().get(1).asType().toString(), executableElement.getParameters().get(1).asType().toString().equals(String.class.getCanonicalName())); - MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName()))); + MatcherAssert.assertThat("Should have found matching parameters", AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName()))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } @@ -61,25 +64,26 @@ protected void testCase(TypeElement element) { @Test public void byParameterTypeFqnMatcher_NoMatch() { - unitTestBuilder.useProcessor(new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); - MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); - MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); + List result = ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "methodWithReturnTypeAndParameters"); + MatcherAssert.assertThat("Precondition: should have found one method", result.size() == 1); + MatcherAssert.assertThat("Precondition: dound method has to be of zype ExecutableElement", result.get(0) instanceof ExecutableElement); - ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); - MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); + ExecutableElement executableElement = ElementUtils.CastElement.castElementList(result, ExecutableElement.class).get(0); + MatcherAssert.assertThat("Precondition: method must have 2 parameters", executableElement.getParameters().size() == 2); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName()))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName()))); - MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName(), String.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(String.class.getCanonicalName(), Boolean.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName()))); + MatcherAssert.assertThat("Should not have found matching parameters", !AptkCoreMatchers.BY_PARAMETER_TYPE_FQN.getMatcher().checkForMatchingCharacteristic(executableElement, Utilities.convertVarargsToArray(Boolean.class.getCanonicalName(), String.class.getCanonicalName(), String.class.getCanonicalName()))); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); } diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/validator/AnnotationValidatorTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/validator/AnnotationValidatorTest.java index 4b981b01..f85fb908 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/validator/AnnotationValidatorTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/validator/AnnotationValidatorTest.java @@ -1,10 +1,10 @@ package io.toolisticon.aptk.tools.validator; import io.toolisticon.aptk.tools.FilterTestAnnotation2; -import io.toolisticon.aptk.tools.TestAnnotation; import io.toolisticon.aptk.tools.matcher.CriteriaMatcher; import io.toolisticon.aptk.tools.matcher.impl.ByAnnotationMatcher; import io.toolisticon.aptk.tools.DummyValidatorMessage; +import io.toolisticon.cute.TestAnnotation; import org.hamcrest.MatcherAssert; import org.junit.Test; import org.mockito.Mockito; diff --git a/tools/src/test/java/io/toolisticon/aptk/tools/wrapper/ExecutableElementWrapperTest.java b/tools/src/test/java/io/toolisticon/aptk/tools/wrapper/ExecutableElementWrapperTest.java index b03ed8c9..2e70116d 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/wrapper/ExecutableElementWrapperTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/wrapper/ExecutableElementWrapperTest.java @@ -2,6 +2,7 @@ import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.PassIn; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -21,7 +22,7 @@ public class ExecutableElementWrapperTest { - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest(); @Before diff --git a/tools/src/test/java/io/toolisticon/aptk/validators/FluentElementValidatorTest.java b/tools/src/test/java/io/toolisticon/aptk/validators/FluentElementValidatorTest.java index 32600303..18f11977 100644 --- a/tools/src/test/java/io/toolisticon/aptk/validators/FluentElementValidatorTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/validators/FluentElementValidatorTest.java @@ -1,17 +1,19 @@ package io.toolisticon.aptk.validators; -import io.toolisticon.aptk.tools.AbstractUnitTestAnnotationProcessorClass; +import io.toolisticon.aptk.cute.APTKUnitTestProcessor; import io.toolisticon.aptk.tools.ElementUtils; import io.toolisticon.aptk.tools.MessagerUtils; import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.fluentvalidator.FluentElementValidator; import io.toolisticon.cute.CompileTestBuilder; +import io.toolisticon.cute.CompileTestBuilderApi; import io.toolisticon.cute.JavaFileObjectUtils; import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -30,7 +32,7 @@ public void init() { MessagerUtils.setPrintMessageCodes(true); } - private CompileTestBuilder.UnitTestBuilder unitTestBuilder = CompileTestBuilder + private CompileTestBuilderApi.UnitTestBuilder unitTestBuilder = CompileTestBuilder .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/AnnotationProcessorTestClass.java")); @@ -38,25 +40,25 @@ public void init() { @Test public void shouldValidateSuccessfullyWithAllOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -66,25 +68,24 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateWithFailureWithAllOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // Test + MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC, Modifier.FINAL).validateAndIssueMessages()); - // Test - MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC, Modifier.FINAL).validateAndIssueMessages()); - - } - }) + } + }) .compilationShouldFail() .executeTest(); @@ -94,25 +95,25 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateSuccessfullyWithAtLeastOneOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -122,25 +123,24 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateWithFailureWithAtLeastOneOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { - + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.STATIC, Modifier.FINAL).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAtLeastOneOf(Modifier.STATIC, Modifier.FINAL).validateAndIssueMessages()); - } - }) + } + }) .compilationShouldFail() .executeTest(); @@ -151,25 +151,25 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateSuccessfullyWithOneOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.SYNCHRONIZED, Modifier.FINAL, Modifier.ABSTRACT).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasOneOf(Modifier.SYNCHRONIZED, Modifier.FINAL, Modifier.ABSTRACT).validateAndIssueMessages()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -179,25 +179,25 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateWithFailureWithOneOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); - } - }) + } + }) .compilationShouldFail() .executeTest(); @@ -208,25 +208,25 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateSuccessfullyWithNoneOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.FINAL, Modifier.STATIC).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as true", FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.FINAL, Modifier.STATIC).validateAndIssueMessages()); - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -236,26 +236,26 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateWithFailureWithNoneOf() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + ExecutableElement testElement = ElementUtils.CastElement.castMethod(elements.get(0)); - // Test - MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); + // Test + MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(testElement).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasNoneOf(Modifier.SYNCHRONIZED, Modifier.PUBLIC).validateAndIssueMessages()); - } + } - }) + }) .compilationShouldFail() .executeTest(); @@ -265,25 +265,25 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateSuccessfullyIsMatcher() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(ElementUtils.AccessEnclosedElements.getEnclosedElementsByName(element, "synchronizedMethod")) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.METHOD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() == 1); - // Test - MatcherAssert.assertThat("Should be successfully validated", FluentElementValidator.createFluentElementValidator(elements.get(0)).is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).validateAndIssueMessages()) - ; + // Test + MatcherAssert.assertThat("Should be successfully validated", FluentElementValidator.createFluentElementValidator(elements.get(0)).is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).validateAndIssueMessages()) + ; - } - }) + } + }) .compilationShouldSucceed() .executeTest(); @@ -293,25 +293,25 @@ protected void testCase(TypeElement element) { @Test public void shouldValidateWithFailureIsMatcher() { - unitTestBuilder.useProcessor( - new AbstractUnitTestAnnotationProcessorClass() { - @Override - protected void testCase(TypeElement element) { + unitTestBuilder.defineTest( + new APTKUnitTestProcessor() { + @Override + public void aptkUnitTest(ProcessingEnvironment processingEnvironment, TypeElement element) { - // check null value - List elements = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) - .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) - .getResult(); - MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() >= 1); + // check null value + List elements = FluentElementFilter.createFluentElementFilter(element.getEnclosedElements()) + .applyFilter(AptkCoreMatchers.BY_ELEMENT_KIND).filterByOneOf(ElementKind.FIELD) + .getResult(); + MatcherAssert.assertThat("precondition : must have found unique testelement", elements.size() >= 1); - // Test - MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(elements.get(0)).is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC, Modifier.STATIC).validateAndIssueMessages()) - ; + // Test + MatcherAssert.assertThat("Should be validated as false", !FluentElementValidator.createFluentElementValidator(elements.get(0)).is(AptkCoreMatchers.IS_EXECUTABLE_ELEMENT).applyValidator(AptkCoreMatchers.BY_MODIFIER).hasAllOf(Modifier.PUBLIC, Modifier.STATIC).validateAndIssueMessages()) + ; - } - }) + } + }) .compilationShouldFail() .executeTest(); diff --git a/tools/src/test/resources/AnnotationClassAttributeTestClass.java b/tools/src/test/resources/AnnotationClassAttributeTestClass.java index 2cacf0e2..82eccace 100644 --- a/tools/src/test/resources/AnnotationClassAttributeTestClass.java +++ b/tools/src/test/resources/AnnotationClassAttributeTestClass.java @@ -1,9 +1,10 @@ package io.toolisticon.annotationprocessor; -import io.toolisticon.aptk.tools.TestAnnotation; + import io.toolisticon.aptk.tools.annotationutilstestclasses.ClassArrayAttributeAnnotation; import io.toolisticon.aptk.tools.annotationutilstestclasses.ClassAttributeAnnotation; import io.toolisticon.aptk.tools.annotationutilstestclasses.DefaultValueAnnotation; +import io.toolisticon.cute.TestAnnotation; /** * Test class for annotation processor tools. diff --git a/tools/src/test/resources/AnnotationProcessorTestClass.java b/tools/src/test/resources/AnnotationProcessorTestClass.java index da3adf5a..5f177cb6 100644 --- a/tools/src/test/resources/AnnotationProcessorTestClass.java +++ b/tools/src/test/resources/AnnotationProcessorTestClass.java @@ -2,7 +2,8 @@ import io.toolisticon.aptk.tools.FilterTestAnnotation1; import io.toolisticon.aptk.tools.FilterTestAnnotation2; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; + import java.util.Comparator; import java.util.List; diff --git a/tools/src/test/resources/AnnotationProcessorUnitTestClassInternal.java b/tools/src/test/resources/AnnotationProcessorUnitTestClassInternal.java index 03d1ae5e..9aac4fe6 100644 --- a/tools/src/test/resources/AnnotationProcessorUnitTestClassInternal.java +++ b/tools/src/test/resources/AnnotationProcessorUnitTestClassInternal.java @@ -1,6 +1,7 @@ package io.toolisticon.annotationprocessor; -import io.toolisticon.aptk.tools.TestAnnotation; + +import io.toolisticon.cute.TestAnnotation; import java.util.Comparator; import java.util.List; diff --git a/tools/src/test/resources/AnnotationValueUtilsTestClass.java b/tools/src/test/resources/AnnotationValueUtilsTestClass.java index e0b2064a..10fdfec5 100644 --- a/tools/src/test/resources/AnnotationValueUtilsTestClass.java +++ b/tools/src/test/resources/AnnotationValueUtilsTestClass.java @@ -1,6 +1,6 @@ package io.toolisticon.annotationprocessor; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; import io.toolisticon.aptk.tools.annotationvalueutilstestclasses.AnnotationValueTestAnnotation; import javax.tools.StandardLocation; diff --git a/tools/src/test/resources/GenericsTestClass.java b/tools/src/test/resources/GenericsTestClass.java index 51ef2944..de8d0ab8 100644 --- a/tools/src/test/resources/GenericsTestClass.java +++ b/tools/src/test/resources/GenericsTestClass.java @@ -1,4 +1,6 @@ -import io.toolisticon.aptk.tools.TestAnnotation; + + +import io.toolisticon.cute.TestAnnotation; import java.util.Comparator; import java.util.HashMap; diff --git a/tools/src/test/resources/testcases.beanutils/DefaultNoargConstructorTest.java b/tools/src/test/resources/testcases.beanutils/DefaultNoargConstructorTest.java index 8559c058..bc149a33 100644 --- a/tools/src/test/resources/testcases.beanutils/DefaultNoargConstructorTest.java +++ b/tools/src/test/resources/testcases.beanutils/DefaultNoargConstructorTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation public class DefaultNoargConstructorTest { diff --git a/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest.java b/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest.java index e9d297c4..e52c12cd 100644 --- a/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest.java +++ b/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation public class ExplicitNoargConstructorTest { diff --git a/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest2.java b/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest2.java index b114b693..a6eb0cd2 100644 --- a/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest2.java +++ b/tools/src/test/resources/testcases.beanutils/ExplicitNoargConstructorTest2.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation public class ExplicitNoargConstructorTest2 { diff --git a/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java b/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java index 59281a6d..e0ca90a3 100644 --- a/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java +++ b/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java @@ -1,7 +1,7 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation diff --git a/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java b/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java index a2ef7f26..7e03b6cf 100644 --- a/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java +++ b/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation public class TypeHierarchyTestClass { diff --git a/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java b/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java index a1d6a38f..3f63a3d4 100644 --- a/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java +++ b/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java @@ -1,7 +1,7 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation public class GetAttributesCommandTestClass { diff --git a/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java b/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java index fc472c92..7802666d 100644 --- a/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java +++ b/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk.test; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; @TestAnnotation public class GetAttributesCommandWithInheritanceTestClass { diff --git a/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoArgsConstructorAnnotation.java b/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoArgsConstructorAnnotation.java index 8026b9c5..2cdd0a22 100644 --- a/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoArgsConstructorAnnotation.java +++ b/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoArgsConstructorAnnotation.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; import lombok.NoArgsConstructor; @TestAnnotation diff --git a/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoConstructorWithAllArgsConstructorAnnotation.java b/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoConstructorWithAllArgsConstructorAnnotation.java index 4c2d491d..28dd1778 100644 --- a/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoConstructorWithAllArgsConstructorAnnotation.java +++ b/tools/src/test/resources/testcases.matchers.hasnoargsconstructormatcher/LombokNoConstructorWithAllArgsConstructorAnnotation.java @@ -1,6 +1,6 @@ package io.toolisticon.aptk; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; import lombok.AllArgsConstructor; @TestAnnotation diff --git a/tools/src/test/resources/testcases/generators/FilerUtilsTestClass.java b/tools/src/test/resources/testcases/generators/FilerUtilsTestClass.java index 82f91ecf..97592465 100644 --- a/tools/src/test/resources/testcases/generators/FilerUtilsTestClass.java +++ b/tools/src/test/resources/testcases/generators/FilerUtilsTestClass.java @@ -1,7 +1,7 @@ package io.toolisticon.annotationprocessor; import io.toolisticon.aptk.tools.generators.FileObjectUtilsTestAnnotation; -import io.toolisticon.aptk.tools.TestAnnotation; +import io.toolisticon.cute.TestAnnotation; /** * Test class for annotation processor tools.