From 76af93e756861dedd18dd865d8f37df52de0de34 Mon Sep 17 00:00:00 2001 From: Tobias Stamann Date: Tue, 9 Jan 2024 18:45:37 +0100 Subject: [PATCH] Removed checks for lombok specific annotations in BeanUtils (Lombok must take care itself that its Java standard comform) --- pom.xml | 9 +- .../io/toolisticon/aptk/tools/BeanUtils.java | 125 +++----- .../command/impl/GetAttributesCommand.java | 17 +- .../tools/wrapper/TypeElementWrapper.java | 11 +- .../wrapper/TypeParameterElementWrapper.java | 10 + .../toolisticon/aptk/tools/BeanUtilsTest.java | 170 ----------- .../impl/GetAttributesCommandTest.java | 244 +--------------- ...tAttributesCommandWithInheritanceTest.java | 269 +----------------- .../FieldLevelTestcases.java | 25 -- .../LombokDataOnClass.java | 16 -- .../LombokGetterOnClass.java | 16 -- .../LombokSetterOnClass.java | 16 -- .../TypeHierarchyTestClass.java | 46 ++- .../GetAttributesCommandTestClass.java | 75 +---- ...ibutesCommandWithInheritanceTestClass.java | 85 ++---- 15 files changed, 140 insertions(+), 994 deletions(-) delete mode 100644 tools/src/test/resources/testcases.beanutils/LombokDataOnClass.java delete mode 100644 tools/src/test/resources/testcases.beanutils/LombokGetterOnClass.java delete mode 100644 tools/src/test/resources/testcases.beanutils/LombokSetterOnClass.java diff --git a/pom.xml b/pom.xml index f73867c6..2b1c644e 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,6 @@ 4.13.2 2.2 4.3.1 - 1.18.30 https://oss.sonatype.org/content/repositories/snapshots/ @@ -689,13 +688,7 @@ - - - org.projectlombok - lombok - ${lombok.version} - provided - + diff --git a/tools/src/main/java/io/toolisticon/aptk/tools/BeanUtils.java b/tools/src/main/java/io/toolisticon/aptk/tools/BeanUtils.java index e16e06ba..dc0cb27f 100644 --- a/tools/src/main/java/io/toolisticon/aptk/tools/BeanUtils.java +++ b/tools/src/main/java/io/toolisticon/aptk/tools/BeanUtils.java @@ -5,6 +5,7 @@ import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; import io.toolisticon.aptk.tools.fluentvalidator.FluentElementValidator; +import io.toolisticon.aptk.tools.wrapper.TypeElementWrapper; import io.toolisticon.aptk.tools.wrapper.VariableElementWrapper; import javax.lang.model.element.ElementKind; @@ -15,7 +16,10 @@ import javax.lang.model.type.TypeMirror; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.regex.Pattern; /** @@ -166,7 +170,7 @@ public static boolean isDefaultNoargConstructor(ExecutableElement element) { return false; } - return Pattern.compile("^\\s*super\\(\\)[;]{0,1}\\s*$").matcher(statements.get(0).toString()).matches(); + return Pattern.compile("^\\s*super\\(\\);?\\s*$").matcher(statements.get(0).toString()).matches(); } @@ -176,12 +180,21 @@ public static boolean isAttribute(VariableElement field) { } - public static AttributeResult[] getAttributesWithInheritance(TypeElement typeElement) { - List resultList = new ArrayList<>(Arrays.asList(GetAttributesCommand.INSTANCE.execute(typeElement))); + public static AttributeResult[] getAttributesWithInheritance(TypeElement typeElement, TypeMirrorWrapper... typeArguments) { + + + // this doesn't support getting generic fields in parent classes + List resultList = new ArrayList<>(Arrays.asList(GetAttributesCommand.createCommand().execute(typeElement))); // process super types for (TypeElement superTypeElement : ElementUtils.AccessTypeHierarchy.getSuperTypeElementsOfKindType(typeElement)) { - resultList.addAll(Arrays.asList(GetAttributesCommand.INSTANCE.execute(superTypeElement))); + TypeElementWrapper wrappedSuperTypeElement = TypeElementWrapper.wrap(superTypeElement); + Map resolvedTypeArgumentMap = new HashMap<>(); + if (wrappedSuperTypeElement.hasTypeParameters()) { + List resolvedTypeArgumentTypes = InterfaceUtils.getResolvedTypeArgumentOfSuperTypeOrInterface(TypeElementWrapper.wrap(typeElement), TypeMirrorWrapper.wrap(superTypeElement), typeArguments); + resolvedTypeArgumentMap = InterfaceUtils.mapTypeVars(wrappedSuperTypeElement, resolvedTypeArgumentTypes.toArray(new TypeMirrorWrapper[0])); + } + resultList.addAll(Arrays.asList(GetAttributesCommand.createCommand(resolvedTypeArgumentMap).execute(superTypeElement))); } return resultList.toArray(new AttributeResult[0]); @@ -204,18 +217,18 @@ public static AttributeResult[] getAttributes(TypeElement typeElement) { for (VariableElement field : fields) { - AttributeResult attributeResult = new AttributeResult(); - attributeResult.setField(VariableElementWrapper.wrap(field)); - - String getterMethodName = BeanUtils.getGetterMethodName(field); - attributeResult.setGetterMethodName(BeanUtils.getGetterMethodName(field)); - attributeResult.setSetterMethodName(BeanUtils.getSetterMethodName(field)); - - // just add those fields with both getters and setters - if (attributeResult.hasGetter() && attributeResult.hasSetter()) { + Optional getterMethodName = BeanUtils.getGetterMethodName(field); + Optional setterMethodName = BeanUtils.getSetterMethodName(field); + if (getterMethodName.isPresent() && setterMethodName.isPresent()) { + + AttributeResult attributeResult = new AttributeResult(); + attributeResult.setField(VariableElementWrapper.wrap(field)); + attributeResult.setGetterMethodName(getterMethodName.get()); + attributeResult.setSetterMethodName(setterMethodName.get()); result.add(attributeResult); } + } return result.toArray(new AttributeResult[0]); @@ -236,14 +249,10 @@ public static boolean checkHasGetter(VariableElement field) { return false; } - TypeElement typeElement = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS); + TypeElement typeElement = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS); - return checkLombokDataAnnotation(typeElement) - || checkLombokGetterAnnotationOnType(typeElement) - || checkLombokGetterAnnotationOnField(field) - || checkHasGetterMethod(field, typeElement) - ; + return checkHasGetterMethod(field, typeElement); } @@ -260,53 +269,16 @@ public static boolean checkHasSetter(VariableElement field) { return false; } - TypeElement typeElement = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS); + TypeElement typeElement = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS); - return checkLombokDataAnnotation(typeElement) - || checkLombokSetterAnnotationOnType(typeElement) + return checkLombokSetterAnnotationOnType(typeElement) || checkLombokSetterAnnotationOnField(field) || checkHasSetterMethod(field, typeElement) ; } - /** - * Checks if lombok.Data annotation is present on passed TypeElement. - * - * @param typeElement the TypeElement to check - * @return true if Data annotation can be found on passed typeElement otherwise false - */ - public static boolean checkLombokDataAnnotation(TypeElement typeElement) { - - return AnnotationUtils.getAnnotationMirror(typeElement, "lombok.Data") != null; - - } - - /** - * Checks if lombok.Getter annotation is present on passed TypeElement. - * - * @param typeElement the TypeElement to check - * @return true if Getter annotation can be found on passed TypeElement otherwise false - */ - public static boolean checkLombokGetterAnnotationOnType(TypeElement typeElement) { - - return AnnotationUtils.getAnnotationMirror(typeElement, "lombok.Getter") != null; - - } - - /** - * Checks if lombok.Getter annotation is present on passed TypeElement. - * - * @param variableElement the VariableElement to check - * @return true if Getter annotation can be found on passed VariableElement otherwise false - */ - public static boolean checkLombokGetterAnnotationOnField(VariableElement variableElement) { - - return AnnotationUtils.getAnnotationMirror(variableElement, "lombok.Getter") != null; - - } - /** * Get the getters method name. @@ -314,30 +286,21 @@ public static boolean checkLombokGetterAnnotationOnField(VariableElement variabl * @param field The field * @return the getters method name or null if field has no getter */ - public static String getGetterMethodName(VariableElement field) { + public static Optional getGetterMethodName(VariableElement field) { if (field == null || field.getKind() != ElementKind.FIELD) { - return null; + return Optional.empty(); } - TypeElement typeElement = (TypeElement) ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS); - + TypeElement typeElement = ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS); ExecutableElement getterMethod = getGetterMethod(field, typeElement); if (getterMethod != null) { - return getterMethod.getSimpleName().toString(); - } - - if (checkLombokDataAnnotation(typeElement) - || checkLombokGetterAnnotationOnType(typeElement) - || checkLombokGetterAnnotationOnField(field)) { - - return TypeUtils.TypeComparison.isTypeEqual(field.asType(), TypeUtils.TypeRetrieval.getTypeMirror(boolean.class)) ? getPrefixedName("is", field.getSimpleName().toString()) : getPrefixedName("get", field.getSimpleName().toString()); - + return Optional.of(getterMethod.getSimpleName().toString()); } - return null; + return Optional.empty(); } /** @@ -346,12 +309,12 @@ public static String getGetterMethodName(VariableElement field) { * @param field the fields VariableElement * @return the name of the setter method */ - public static String getSetterMethodName(VariableElement field) { + public static Optional getSetterMethodName(VariableElement field) { if (field == null || field.getKind() != ElementKind.FIELD) { - return null; + return Optional.empty(); } - return checkHasSetter(field) ? getPrefixedName("set", field.getSimpleName().toString()) : null; + return checkHasSetter(field) ? Optional.of(getPrefixedName("set", field.getSimpleName().toString())) : Optional.empty(); } /** @@ -361,13 +324,13 @@ public static String getSetterMethodName(VariableElement field) { * @param typeElement the TypeElement * @return true if field has a getter method, otherwise false */ - protected static boolean checkHasGetterMethod(VariableElement field, TypeElement typeElement) { + static boolean checkHasGetterMethod(VariableElement field, TypeElement typeElement) { - return getGetterMethod(field, ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS)) != null; + return getGetterMethod(field, ElementUtils.AccessEnclosingElements.getFirstEnclosingElementOfKind(field, ElementKind.CLASS)) != null; } - protected static ExecutableElement getGetterMethod(VariableElement field, TypeElement typeElement) { + static ExecutableElement getGetterMethod(VariableElement field, TypeElement typeElement) { List result = FluentElementFilter.createFluentElementFilter(typeElement.getEnclosedElements()) .applyFilter(AptkCoreMatchers.IS_METHOD) .applyFilter(AptkCoreMatchers.BY_MODIFIER).filterByAllOf(Modifier.PUBLIC) @@ -380,7 +343,7 @@ protected static ExecutableElement getGetterMethod(VariableElement field, TypeEl return result.size() >= 1 ? result.get(0) : null; } - protected static boolean checkHasSetterMethod(VariableElement field, TypeElement typeElement) { + static boolean checkHasSetterMethod(VariableElement field, TypeElement typeElement) { return getSetterMethod(field, typeElement) != null; @@ -388,7 +351,7 @@ protected static boolean checkHasSetterMethod(VariableElement field, TypeElement } - protected static ExecutableElement getSetterMethod(VariableElement field, TypeElement typeElement) { + static ExecutableElement getSetterMethod(VariableElement field, TypeElement typeElement) { TypeMirror[] parameters = {field.asType()}; @@ -404,7 +367,7 @@ protected static ExecutableElement getSetterMethod(VariableElement field, TypeEl return result.size() >= 1 ? result.get(0) : null; } - protected static String[] getPossibleGetterOrSetterNames(VariableElement field, String[] prefixes) { + static String[] getPossibleGetterOrSetterNames(VariableElement field, String[] prefixes) { String[] result = new String[prefixes.length]; for (int i = 0; i < prefixes.length; i++) { diff --git a/tools/src/main/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommand.java b/tools/src/main/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommand.java index 741a5a4b..66f6beb4 100644 --- a/tools/src/main/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommand.java +++ b/tools/src/main/java/io/toolisticon/aptk/tools/command/impl/GetAttributesCommand.java @@ -1,10 +1,13 @@ package io.toolisticon.aptk.tools.command.impl; -import io.toolisticon.aptk.tools.command.CommandWithReturnType; import io.toolisticon.aptk.tools.BeanUtils; import io.toolisticon.aptk.tools.BeanUtils.AttributeResult; +import io.toolisticon.aptk.tools.TypeMirrorWrapper; +import io.toolisticon.aptk.tools.command.CommandWithReturnType; import javax.lang.model.element.TypeElement; +import java.util.HashMap; +import java.util.Map; /** * Get all attributes of passed TypeElement. @@ -12,7 +15,11 @@ */ public class GetAttributesCommand implements CommandWithReturnType { - public final static GetAttributesCommand INSTANCE = new GetAttributesCommand(); + private final Map resolvedTypeArgumentMap; + + public GetAttributesCommand(Map resolvedTypeArgumentMap) { + this.resolvedTypeArgumentMap = resolvedTypeArgumentMap; + } @Override public AttributeResult[] execute(TypeElement element) { @@ -21,5 +28,11 @@ public AttributeResult[] execute(TypeElement element) { } + public static GetAttributesCommand createCommand(Map resolvedTypeArgumentMap) { + return new GetAttributesCommand(resolvedTypeArgumentMap); + } + public static GetAttributesCommand createCommand() { + return createCommand(new HashMap<>()); + } } diff --git a/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java b/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java index 1810b662..830676e0 100644 --- a/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java +++ b/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java @@ -5,7 +5,6 @@ import io.toolisticon.aptk.tools.corematcher.AptkCoreMatchers; import io.toolisticon.aptk.tools.fluentfilter.FluentElementFilter; -import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -117,6 +116,15 @@ public List getTypeParameters() { return this.element.getTypeParameters().stream().map(TypeParameterElementWrapper::wrap).collect(Collectors.toList()); } + /** + * Checks if wrapped TypeElement has type parameters. + * + * @return true, if TypeElement has type parameters, otherwise false. + */ + public boolean hasTypeParameters() { + return getTypeParameters().size() > 0; + } + /** * Returns an enclosed method. * Works only if all parameter types are already compiled. @@ -239,6 +247,7 @@ public Optional getOuterTopLevelType() { /** * Gets all enum constant names of enum as VariableElements. + * * @return A list containing all enum constant names or null if wrapped TypeElement is no enum. */ public List getEnumValues() { diff --git a/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeParameterElementWrapper.java b/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeParameterElementWrapper.java index 8326e152..c00a5810 100644 --- a/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeParameterElementWrapper.java +++ b/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeParameterElementWrapper.java @@ -5,6 +5,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeParameterElement; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; /** @@ -42,6 +43,15 @@ public String toStringWithExtendsAndBounds() { List extendedTypes = getBounds(); return toString() + (extendedTypes.size() == 0 ? "" : extendedTypes.stream().map(e -> e.getTypeDeclaration()).collect(Collectors.joining(" & ", " extends ",""))); } + + /** + * Gets a Set containing the fully qualified names of all bounds. + * @return a Set containing all fqn of all bounds + */ + public Set getImports() { + return getBounds().stream().map(TypeMirrorWrapper::getQualifiedName).collect(Collectors.toSet()); + } + /** * Wraps a TypeParameterElement. * Will throw IllegalArgumentException if passed element is null. 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 3393043c..1e2b98b1 100644 --- a/tools/src/test/java/io/toolisticon/aptk/tools/BeanUtilsTest.java +++ b/tools/src/test/java/io/toolisticon/aptk/tools/BeanUtilsTest.java @@ -95,46 +95,9 @@ protected void testCase(TypeElement element) { .executeTest(); } - @Test - public void fieldWithImplementedGetterAndSetterAnnotation_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("fieldWithImplementedGetterAndSetterAnnotation") - .getResult().get(0); - - - MatcherAssert.assertThat("Should detect lombok generated setter ", BeanUtils.checkHasSetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } - - @Test - public void fieldWithImplementedGetterAndSetterAnnotation_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("fieldWithImplementedSetterAndGetterAnnotation") - .getResult().get(0); - // shouldn't find nonexisting - MatcherAssert.assertThat("Should detect lombok generated getter ", BeanUtils.checkHasGetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } @Test public void fieldWithoutGetter_checkHasGetter() { @@ -178,140 +141,7 @@ protected void testCase(TypeElement element) { } - // ----------------------------------- - // Type level lombok annotations - // ----------------------------------- - - @Test - public void fieldWithoutSetter_checkHasLombokSetter() { - - unitTestBuilder - .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/LombokDataOnClass.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("testField") - .getResult().get(0); - - - MatcherAssert.assertThat("Should detect setter ", BeanUtils.checkHasSetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } - - @Test - public void fieldWithoutSetter_checkHasLombokGetterOnClass() { - - unitTestBuilder - .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/LombokGetterOnClass.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("testField") - .getResult().get(0); - - - MatcherAssert.assertThat("Should detect getter ", BeanUtils.checkHasGetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } - - @Test - public void fieldWithoutSetter_checkHasLombokSetterOnClass() { - unitTestBuilder - .useSource(JavaFileObjectUtils.readFromResource("testcases.beanutils/LombokSetterOnClass.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("testField") - .getResult().get(0); - - - MatcherAssert.assertThat("Should detect setter ", BeanUtils.checkHasSetter(field)); - } - }) - .compilationShouldSucceed() - .executeTest(); - } - - - // ----------------------- - // get getter name - // ----------------------- - - @Test - public void getGetterName_booleanFieldWithLombokGetter() { - - 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("booleanFieldWithGetterAnnotation") - .getResult().get(0); - - - MatcherAssert.assertThat(BeanUtils.getGetterMethodName(field), Matchers.is("isBooleanFieldWithGetterAnnotation")); - } - }) - .compilationShouldSucceed() - .executeTest(); - } - - @Test - public void getGetterName_nonBooleanFieldWithLombokGetter() { - - 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("fieldWithImplementedSetterAndGetterAnnotation") - .getResult().get(0); - - - MatcherAssert.assertThat(BeanUtils.getGetterMethodName(field), Matchers.is("getFieldWithImplementedSetterAndGetterAnnotation")); - } - }) - .compilationShouldSucceed() - .executeTest(); - } - - @Test - public void getGetterName_nonBooleanFieldWithLombokGetterAndSetter() { - - 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(BeanUtils.getGetterMethodName(field), Matchers.is("getFieldWithImplementedGetterAndSetters")); - } - }) - .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 f22565e9..9c756d8e 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 @@ -28,246 +28,10 @@ public void init() { .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/testcases.commands/GetAttributesCommandTestClass.java")); - @Test - public void shouldExecuteSuccessfullyDataAnnotatedClass() { - - unitTestBuilder.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(".*TestDataAnnotatedClass") - .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullyGetterAnnotatedClass() { - - unitTestBuilder.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(".*TestJustGetterAnnotatedClass") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullySetterAnnotatedClass() { - - unitTestBuilder.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(".*TestJustSetterAnnotatedClass") - .getResult().get(0); - - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedClass() { - - unitTestBuilder.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(".*TestGetterAndSetterAnnotatedClass") - .getResult().get(0); - - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyMixedGetterAndSetterAnnotatedClassAndField2() { - - unitTestBuilder.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(".*TestMixedGetterAndSetterAnnotatedClassAndField1") - .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyMixedGetterAndSetterAnnotatedClassAndField2_() { - - unitTestBuilder.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(".*TestMixedGetterAndSetterAnnotatedClassAndField2") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyGetterAnnotatedField() { - - unitTestBuilder.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(".*TestJustGetterAnnotatedField") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullySetterAnnotatedField() { - - unitTestBuilder.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(".*TestJustSetterAnnotatedField") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedField() { - - unitTestBuilder.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(".*TestGetterAndSetterAnnotatedField") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedMethod() { + public void shouldExecuteSuccessfullyWithGetterAndSetterMethod() { unitTestBuilder.useProcessor( new AbstractUnitTestAnnotationProcessorClass() { @@ -279,7 +43,7 @@ protected void testCase(TypeElement element) { .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethods") .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); + BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.createCommand().execute(typeElement); MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); @@ -293,7 +57,7 @@ protected void testCase(TypeElement element) { } @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedMethodWithInvalidParameterType() { + public void shouldExecuteSuccessfullyWithGetterAndSetterMethodButWithInvalidParameterType() { unitTestBuilder.useProcessor( new AbstractUnitTestAnnotationProcessorClass() { @@ -305,7 +69,7 @@ protected void testCase(TypeElement element) { .applyFilter(AptkCoreMatchers.BY_REGEX_NAME).filterByOneOf(".*TestFieldGetterAndSetterMethodsWithInvalidSetterParameterType") .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.INSTANCE.execute(typeElement); + BeanUtils.AttributeResult[] attributeResult = GetAttributesCommand.createCommand().execute(typeElement); MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); 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 498936ff..032fd8a2 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 @@ -14,8 +14,10 @@ import org.junit.Test; import javax.lang.model.element.TypeElement; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; /** * Unit Test for {@link GetAttributesCommandWithInheritance}. @@ -31,30 +33,7 @@ public void init() { .unitTest() .useSource(JavaFileObjectUtils.readFromResource("/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java")); - @Test - public void shouldExecuteSuccessfullyDataAnnotatedClass() { - unitTestBuilder.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(".*TestDataAnnotatedClass") - .getResult().get(0); - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } @Test public void shouldExecuteSuccessfullyInheritedDataAnnotatedClass() { @@ -72,120 +51,8 @@ protected void testCase(TypeElement element) { MatcherAssert.assertThat(attributeResult.length, Matchers.is(2)); - Set fields = new HashSet(); - for (BeanUtils.AttributeResult item : attributeResult) { - fields.add(item.getFieldName()); - } - - MatcherAssert.assertThat(fields, Matchers.containsInAnyOrder("field1", "field3")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullyGetterAnnotatedClass() { - - unitTestBuilder.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(".*TestJustGetterAnnotatedClass") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullySetterAnnotatedClass() { - - unitTestBuilder.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(".*TestJustSetterAnnotatedClass") - .getResult().get(0); - - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedClass() { - - unitTestBuilder.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(".*TestGetterAndSetterAnnotatedClass") - .getResult().get(0); - - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyMixedGetterAndSetterAnnotatedClassAndField2() { - - unitTestBuilder.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(".*TestMixedGetterAndSetterAnnotatedClassAndField1") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); + MatcherAssert.assertThat(Arrays.stream(attributeResult).map(e -> e.getFieldName()).collect(Collectors.toSet()), Matchers.containsInAnyOrder("field1", "field3")); } }) @@ -196,136 +63,6 @@ protected void testCase(TypeElement element) { } - @Test - public void shouldExecuteSuccessfullyMixedGetterAndSetterAnnotatedClassAndField2_() { - - unitTestBuilder.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(".*TestMixedGetterAndSetterAnnotatedClassAndField2") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - - @Test - public void shouldExecuteSuccessfullyGetterAnnotatedField() { - - unitTestBuilder.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(".*TestJustGetterAnnotatedField") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullySetterAnnotatedField() { - - unitTestBuilder.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(".*TestJustSetterAnnotatedField") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(0)); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedField() { - - unitTestBuilder.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(".*TestGetterAndSetterAnnotatedField") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - - @Test - public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedMethod() { - - unitTestBuilder.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(".*TestFieldGetterAndSetterMethods") - .getResult().get(0); - - BeanUtils.AttributeResult[] attributeResult = GetAttributesCommandWithInheritance.INSTANCE.execute(typeElement); - - MatcherAssert.assertThat(attributeResult.length, Matchers.is(1)); - MatcherAssert.assertThat(attributeResult[0].getFieldName(), Matchers.is("field1")); - - } - }) - - .compilationShouldSucceed() - .executeTest(); - - } - @Test public void shouldExecuteSuccessfullyGetterAndSetterAnnotatedMethodWithInvalidParameterType() { diff --git a/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java b/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java index 50d8a508..59281a6d 100644 --- a/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java +++ b/tools/src/test/resources/testcases.beanutils/FieldLevelTestcases.java @@ -2,8 +2,6 @@ import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Getter; -import lombok.Setter; @TestAnnotation @@ -25,29 +23,6 @@ public void setFieldWithImplementedGetterAndSetters(String fieldWithImplementedG // -------------------------------------------------------------- - @Setter - private String fieldWithImplementedGetterAndSetterAnnotation; - - public String getFieldWithImplementedGetterAndSetterAnnotation() { - return fieldWithImplementedGetterAndSetterAnnotation; - } - - // -------------------------------------------------------------- - - @Getter - private String fieldWithImplementedSetterAndGetterAnnotation; - - public void setFieldWithImplementedSetterAndGetterAnnotation(String fieldWithImplementedSetterAndGetterAnnotation) { - this.fieldWithImplementedSetterAndGetterAnnotation = fieldWithImplementedSetterAndGetterAnnotation; - } - - // -------------------------------------------------------------- - - @Getter - private boolean booleanFieldWithGetterAnnotation; - - // -------------------------------------------------------------- - private String fieldWithoutGetterAndSetter; // -------------------------------------------------------------- diff --git a/tools/src/test/resources/testcases.beanutils/LombokDataOnClass.java b/tools/src/test/resources/testcases.beanutils/LombokDataOnClass.java deleted file mode 100644 index 6990b188..00000000 --- a/tools/src/test/resources/testcases.beanutils/LombokDataOnClass.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.toolisticon.aptk.test; - - -import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Data; - - -@TestAnnotation -@Data -public class LombokDataOnClass { - - private String testField; - - -} - diff --git a/tools/src/test/resources/testcases.beanutils/LombokGetterOnClass.java b/tools/src/test/resources/testcases.beanutils/LombokGetterOnClass.java deleted file mode 100644 index d3e1fe48..00000000 --- a/tools/src/test/resources/testcases.beanutils/LombokGetterOnClass.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.toolisticon.aptk.test; - - -import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Getter; - - -@TestAnnotation -@Getter -public class LombokGetterOnClass { - - private String testField; - - -} - diff --git a/tools/src/test/resources/testcases.beanutils/LombokSetterOnClass.java b/tools/src/test/resources/testcases.beanutils/LombokSetterOnClass.java deleted file mode 100644 index db9ee8f2..00000000 --- a/tools/src/test/resources/testcases.beanutils/LombokSetterOnClass.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.toolisticon.aptk.test; - - -import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Setter; - - -@TestAnnotation -@Setter -public class LombokSetterOnClass { - - private String testField; - - -} - diff --git a/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java b/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java index 68224c0f..a2ef7f26 100644 --- a/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java +++ b/tools/src/test/resources/testcases.beanutils/TypeHierarchyTestClass.java @@ -1,37 +1,63 @@ package io.toolisticon.aptk.test; import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; @TestAnnotation public class TypeHierarchyTestClass { - @Data + public static class SuperType { private boolean superBooleanField; private String superStringField; + public boolean isSuperBooleanField() { + return superBooleanField; + } + + public void setSuperBooleanField(boolean superBooleanField) { + this.superBooleanField = superBooleanField; + } + + public String getSuperStringField() { + return superStringField; + } + + public void setSuperStringField(String superStringField) { + this.superStringField = superStringField; + } } public static class InheritingType extends SuperType{ - @Getter - @Setter private boolean booleanField; - @Getter - @Setter + public boolean isBooleanField() { + return booleanField; + } + + public void setBooleanField(boolean booleanField) { + this.booleanField = booleanField; + } + private String stringField; - @Getter - private String nonAttributeField; + public String getStringField() { + return stringField; + } + + public void setStringField(String stringField) { + this.stringField = stringField; + } + private String nonAttributeField; + + public String getNonAttributeField() { + return nonAttributeField; + } } } \ No newline at end of file diff --git a/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java b/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java index 63905c82..a1d6a38f 100644 --- a/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java +++ b/tools/src/test/resources/testcases.commands/GetAttributesCommandTestClass.java @@ -1,83 +1,10 @@ package io.toolisticon.aptk.test; import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; + @TestAnnotation public class GetAttributesCommandTestClass { - @Data - private static class TestDataAnnotatedClass { - - private String field1; - private static String field2; - - } - - @Getter - private static class TestJustGetterAnnotatedClass { - - private String field1; - private static String field2; - - } - - @Getter - private static class TestJustSetterAnnotatedClass { - - private String field1; - private static String field2; - - } - - @Getter - @Setter - private static class TestGetterAndSetterAnnotatedClass { - - private String field1; - private static String field2; - - } - - @Setter - private static class TestMixedGetterAndSetterAnnotatedClassAndField1 { - - @Getter - private String field1; - - } - - @Getter - private static class TestMixedGetterAndSetterAnnotatedClassAndField2 { - - @Setter - private String field1; - - } - - - private static class TestJustSetterAnnotatedField { - - @Setter - private String field1; - - } - - private static class TestJustGetterAnnotatedField { - - @Setter - private String field1; - - } - - private static class TestGetterAndSetterAnnotatedField { - - @Setter - @Getter - private String field1; - - } private static class TestFieldGetterAndSetterMethods { diff --git a/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java b/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java index 3a206dbb..fc472c92 100644 --- a/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java +++ b/tools/src/test/resources/testcases.commands/GetAttributesCommandWithInheritanceTestClass.java @@ -1,85 +1,25 @@ package io.toolisticon.aptk.test; import io.toolisticon.aptk.tools.TestAnnotation; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; @TestAnnotation public class GetAttributesCommandWithInheritanceTestClass { - @Data - private static class TestDataAnnotatedClass { - - private String field1; - private static String field2; - - } - - @Getter - private static class TestJustGetterAnnotatedClass { - - private String field1; - private static String field2; - - } - - @Getter - private static class TestJustSetterAnnotatedClass { - private String field1; - private static String field2; - - } - @Getter - @Setter - private static class TestGetterAndSetterAnnotatedClass { + private static class TestDataAnnotatedClass { private String field1; private static String field2; - } - - @Setter - private static class TestMixedGetterAndSetterAnnotatedClassAndField1 { - - @Getter - private String field1; - - } - - @Getter - private static class TestMixedGetterAndSetterAnnotatedClassAndField2 { - - @Setter - private String field1; - - } - - - private static class TestJustSetterAnnotatedField { - - @Setter - private String field1; - - } - - private static class TestJustGetterAnnotatedField { - - @Setter - private String field1; - - } - - private static class TestGetterAndSetterAnnotatedField { - - @Setter - @Getter - private String field1; + public String getField1() { + return field1; + } + public void setField1(String field1) { + this.field1 = field1; + } } - private static class TestFieldGetterAndSetterMethods { private String field1; @@ -108,12 +48,19 @@ public void setField1(Long field) { } - @Data - private static class TestInheritedDataAnnotatedClass extends TestDataAnnotatedClass{ + + private static class TestInheritedDataAnnotatedClass extends TestDataAnnotatedClass { private String field3; private static String field4; + public String getField3() { + return field3; + } + + public void setField3(String field3) { + this.field3 = field3; + } } } \ No newline at end of file