From fde9bba882e81b73fd146b61633fd7f924ab7fbe Mon Sep 17 00:00:00 2001 From: Tobias Stamann Date: Sat, 23 Apr 2022 03:17:18 +0200 Subject: [PATCH] Code cleanup / Move to Java 7 --- .github/workflows/default.yml | 4 +- ...UnitTestAnnotationProcessorWithPassIn.java | 5 +- .../toolisticon/cute/CompileTestBuilder.java | 43 +++++++------- .../toolisticon/cute/JavaFileObjectUtils.java | 42 ++++++-------- ...nitTestForTestingAnnotationProcessors.java | 8 +-- .../io/toolisticon/cute/impl/CompileTest.java | 10 ++-- .../cute/impl/CompileTestConfiguration.java | 56 +++++++++---------- .../cute/impl/CompileTestFileManager.java | 21 ++++--- .../cute/impl/DebugOutputGenerator.java | 9 ++- .../cute/impl/Java9SupportCheck.java | 4 +- .../BinaryGeneratedFileObjectMatcher.java | 3 +- ...insStringsGeneratedFileObjectMatcher.java} | 6 +- .../CoreGeneratedFileObjectMatchers.java | 4 +- ...LineEndingsGeneratedFileObjectMatcher.java | 6 +- ...llFormedXmlGeneratedFileObjectMatcher.java | 6 +- .../cute/CompileTestBuilderTest.java | 30 +++++----- .../impl/CompileTestConfigurationTest.java | 4 +- ...tringsGeneratedFileObjectMatcherTest.java} | 4 +- .../CoreGeneratedFileObjectMatchersTest.java | 4 +- .../modulesupport/ModuleSupportService.java | 6 +- .../integrationtest/junit4/Junit4Test.java | 8 +-- .../integrationtest/junit5/Junit5Test.java | 12 ++-- .../integrationtest/testng/TestNgTest.java | 10 ++-- pom.xml | 12 ++-- 24 files changed, 152 insertions(+), 165 deletions(-) rename cute/src/main/java/io/toolisticon/cute/matchers/{ContainsStringsGeneratedFileOjectMatcher.java => ContainsStringsGeneratedFileObjectMatcher.java} (82%) rename cute/src/test/java/io/toolisticon/cute/matchers/{ContainsStringsGeneratedFileOjectMatcherTest.java => ContainsStringsGeneratedFileObjectMatcherTest.java} (90%) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 518ab19..2012412 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -12,8 +12,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest,macos-latest,windows-latest] - java: [ 7, 7.0.181, 8, 8.0.192, 9.0.x, 10, 11.0.x, 11.0.3, 12] + os: [ ubuntu-latest,macos-latest,windows-latest ] + java: [ 7.0.x, 8.0.x, 9.0.x, 10.0.x, 11.0.x, 12.0.x, 13.0.x, 14.0.x, 15.0.x, 16.0.x, 17.0.x ] steps: - uses: actions/checkout@v1 diff --git a/cute/src/main/java/io/toolisticon/cute/AbstractUnitTestAnnotationProcessorWithPassIn.java b/cute/src/main/java/io/toolisticon/cute/AbstractUnitTestAnnotationProcessorWithPassIn.java index 3cdca77..f7262f8 100644 --- a/cute/src/main/java/io/toolisticon/cute/AbstractUnitTestAnnotationProcessorWithPassIn.java +++ b/cute/src/main/java/io/toolisticon/cute/AbstractUnitTestAnnotationProcessorWithPassIn.java @@ -4,7 +4,6 @@ import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; @@ -68,9 +67,7 @@ protected List getAllSubElements(Element elementToScan) { result.add(elementToScan); if (elementToScan.getKind() == ElementKind.CONSTRUCTOR || elementToScan.getKind() == ElementKind.METHOD) { - for (VariableElement parameters : ((ExecutableElement) elementToScan).getParameters()) { - result.add(parameters); - } + result.addAll(((ExecutableElement) elementToScan).getParameters()); } for (Element enclosedElement : elementToScan.getEnclosedElements()) { diff --git a/cute/src/main/java/io/toolisticon/cute/CompileTestBuilder.java b/cute/src/main/java/io/toolisticon/cute/CompileTestBuilder.java index 412efc7..6f60ac9 100644 --- a/cute/src/main/java/io/toolisticon/cute/CompileTestBuilder.java +++ b/cute/src/main/java/io/toolisticon/cute/CompileTestBuilder.java @@ -136,7 +136,7 @@ public T useModules(String... modules) { */ public CompileMessageCheckBuilder expectErrorMessage() { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - return new CompileMessageCheckBuilder(createNextInstance(nextConfiguration), Diagnostic.Kind.ERROR); + return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.ERROR); } /** @@ -146,7 +146,7 @@ public CompileMessageCheckBuilder expectErrorMessage() { */ public CompileMessageCheckBuilder expectMandatoryWarningMessage() { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - return new CompileMessageCheckBuilder(createNextInstance(nextConfiguration), Diagnostic.Kind.MANDATORY_WARNING); + return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.MANDATORY_WARNING); } /** @@ -156,7 +156,7 @@ public CompileMessageCheckBuilder expectMandatoryWarningMessage() { */ public CompileMessageCheckBuilder expectWarningMessage() { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - return new CompileMessageCheckBuilder(createNextInstance(nextConfiguration), Diagnostic.Kind.WARNING); + return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.WARNING); } /** @@ -166,7 +166,7 @@ public CompileMessageCheckBuilder expectWarningMessage() { */ public CompileMessageCheckBuilder expectNoteMessage() { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - return new CompileMessageCheckBuilder(createNextInstance(nextConfiguration), Diagnostic.Kind.NOTE); + return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.NOTE); } /** @@ -178,7 +178,7 @@ public CompileMessageCheckBuilder expectNoteMessage() { public T expectWarningMessageThatContains(String... warningChecks) { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); if (warningChecks != null) { - nextConfiguration.addWarningMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, warningChecks); + nextConfiguration.addWarningMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, warningChecks); } return createNextInstance(nextConfiguration); @@ -194,7 +194,7 @@ public T expectMandatoryWarningMessageThatContains(String... mandatoryWarningChe CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); if (mandatoryWarningChecks != null) { - nextConfiguration.addMandatoryWarningMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, mandatoryWarningChecks); + nextConfiguration.addMandatoryWarningMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, mandatoryWarningChecks); } return createNextInstance(nextConfiguration); @@ -210,7 +210,7 @@ public T expectErrorMessageThatContains(String... errorChecksToSet) { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); if (errorChecksToSet != null) { - nextConfiguration.addErrorMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, errorChecksToSet); + nextConfiguration.addErrorMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, errorChecksToSet); } return createNextInstance(nextConfiguration); @@ -226,7 +226,7 @@ public T expectNoteMessageThatContains(String... noteChecksToSet) { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); if (noteChecksToSet != null) { - nextConfiguration.addNoteMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, noteChecksToSet); + nextConfiguration.addNoteMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, noteChecksToSet); } return createNextInstance(nextConfiguration); @@ -323,7 +323,6 @@ public T expectThatFileObjectExists( * @param generatedFileObjectMatcher the matcher to use * @return the next builder instance */ - @SafeVarargs public final T expectThatFileObjectExists( JavaFileManager.Location location, String packageName, @@ -351,7 +350,7 @@ public T expectThatFileObjectDoesntExist( String relativeName) { CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - nextConfiguration.addGeneratedFileObjectCheck(CompileTestConfiguration.FileObjectCheckType.DOESNT_EXIST, location, packageName, relativeName, null); + nextConfiguration.addGeneratedFileObjectCheck(CompileTestConfiguration.FileObjectCheckType.DOESNT_EXIST, location, packageName, relativeName); return createNextInstance(nextConfiguration); } @@ -712,7 +711,7 @@ public UnitTestBuilder defineTest(Class(customAnnotationType, unitTest)); + nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClass<>(customAnnotationType, unitTest)); return createNextInstance(nextConfiguration); } @@ -768,7 +767,7 @@ public UnitTestBuilder defineTestWithPassedInElem // remove existing processor nextConfiguration.getProcessors().clear(); - nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassWithPassIn(classToScan, annotationToSearch != null ? annotationToSearch : PassIn.class, unitTest)); + nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassWithPassIn<>(classToScan, annotationToSearch != null ? annotationToSearch : PassIn.class, unitTest)); return createNextInstance(nextConfiguration); } @@ -827,7 +826,7 @@ public Un CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - PROCESSOR_UNDER_TEST processorUnderTest = null; + PROCESSOR_UNDER_TEST processorUnderTest; try { processorUnderTest = processorUnderTestClass.getDeclaredConstructor().newInstance(); @@ -838,7 +837,7 @@ public Un // remove existing processor nextConfiguration.getProcessors().clear(); - nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassForTestingAnnotationProcessors(processorUnderTest, customAnnotationType, unitTestForTestingAnnotationProcessors)); + nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassForTestingAnnotationProcessors<>(processorUnderTest, customAnnotationType, unitTestForTestingAnnotationProcessors)); return createNextInstance(nextConfiguration); } @@ -888,7 +887,7 @@ public Un CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration); - PROCESSOR_UNDER_TEST processorUnderTest = null; + PROCESSOR_UNDER_TEST processorUnderTest; try { processorUnderTest = processorUnderTestClass.getDeclaredConstructor().newInstance(); @@ -1010,7 +1009,7 @@ public static class CompileMessageCheckBuilder withLocale(Locale locale) /** * Do check if compiler message is linked for a specific source * - * @param source + * @param source the source * @return the next immutable builder instance */ public CompileMessageCheckBuilder atSource(String source) { @@ -1086,10 +1085,10 @@ public CompileMessageCheckBuilder atSource(String source) { public COMPILETESTBUILDER thatContains(String expectedContainedMessageToken) { CompileMessageCheckBuilder nextBuilder = createNextBuilder(); - nextBuilder.comparisionKind = CompileTestConfiguration.ComparisionKind.CONTAINS; + nextBuilder.comparisonKind = CompileTestConfiguration.ComparisonKind.CONTAINS; nextBuilder.expectedMessage = expectedContainedMessageToken; - CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisionKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber); + CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisonKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber); return compileTestBuilder.addCompilerMessageCheck(compilerMessageCheck); } @@ -1103,10 +1102,10 @@ public COMPILETESTBUILDER thatContains(String expectedContainedMessageToken) { public COMPILETESTBUILDER thatIsEqualTo(String expectedMessage) { CompileMessageCheckBuilder nextBuilder = createNextBuilder(); - nextBuilder.comparisionKind = CompileTestConfiguration.ComparisionKind.EQUALS; + nextBuilder.comparisonKind = CompileTestConfiguration.ComparisonKind.EQUALS; nextBuilder.expectedMessage = expectedMessage; - CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisionKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber); + CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisonKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber); return compileTestBuilder.addCompilerMessageCheck(compilerMessageCheck); } @@ -1122,7 +1121,7 @@ CompileMessageCheckBuilder createNextBuilder() { CompileMessageCheckBuilder nextBuilder = new CompileMessageCheckBuilder<>(this.compileTestBuilder, this.kind); nextBuilder.kind = this.kind; - nextBuilder.comparisionKind = this.comparisionKind; + nextBuilder.comparisonKind = this.comparisonKind; nextBuilder.expectedMessage = this.expectedMessage; nextBuilder.locale = this.locale; nextBuilder.source = this.source; diff --git a/cute/src/main/java/io/toolisticon/cute/JavaFileObjectUtils.java b/cute/src/main/java/io/toolisticon/cute/JavaFileObjectUtils.java index 1ce75f1..376bebe 100644 --- a/cute/src/main/java/io/toolisticon/cute/JavaFileObjectUtils.java +++ b/cute/src/main/java/io/toolisticon/cute/JavaFileObjectUtils.java @@ -3,12 +3,12 @@ import io.toolisticon.cute.impl.CommonUtilities; import javax.tools.SimpleJavaFileObject; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; -import java.io.StringBufferInputStream; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -17,7 +17,7 @@ /** * Utility class to create JavaFileObjects and therefore also FileObjects. - * These files can be used for comparision or as source files during compilation. + * These files can be used for comparison or as source files during compilation. */ public class JavaFileObjectUtils { @@ -44,12 +44,12 @@ private JavaSourceFromString(String name, String content) { } @Override - public InputStream openInputStream() throws IOException { - return new StringBufferInputStream(this.content); + public InputStream openInputStream() { + return new ByteArrayInputStream(this.content.getBytes()); } @Override - public Reader openReader(boolean ignoreEncodingErrors) throws IOException { + public Reader openReader(boolean ignoreEncodingErrors) { return new InputStreamReader(openInputStream()); } @@ -66,27 +66,21 @@ public CharSequence getCharContent(boolean ignoreEncodingErrors) { */ public static class JavaSourceFromResource extends SimpleJavaFileObject { - private final static String JAVA_COMPATIBILTY_FILE_ENDING_SUFFIX = ".ct"; + private final static String JAVA_COMPATIBILITY_FILE_ENDING_SUFFIX = ".ct"; private final Class relativeLocationRoot; private final String location; - private JavaSourceFromResource(String location) { - - this(location, null); - - } - private JavaSourceFromResource(String location, Class relativeLocationRoot) { - super(URI.create("resource://" + (location.endsWith(".java" + JAVA_COMPATIBILTY_FILE_ENDING_SUFFIX) ? location.substring(0, location.length() - JAVA_COMPATIBILTY_FILE_ENDING_SUFFIX.length()) : location)), Kind.SOURCE); + super(URI.create("resource://" + (location.endsWith(".java" + JAVA_COMPATIBILITY_FILE_ENDING_SUFFIX) ? location.substring(0, location.length() - JAVA_COMPATIBILITY_FILE_ENDING_SUFFIX.length()) : location)), Kind.SOURCE); this.relativeLocationRoot = relativeLocationRoot; this.location = location; } @Override - public InputStream openInputStream() throws IOException { + public InputStream openInputStream() { Class relativeRoot = relativeLocationRoot != null ? relativeLocationRoot : JavaFileObjectUtils.class; InputStream inputStream = relativeRoot.getResourceAsStream(location); @@ -99,7 +93,7 @@ public InputStream openInputStream() throws IOException { } @Override - public Reader openReader(boolean ignoreEncodingErrors) throws IOException { + public Reader openReader(boolean ignoreEncodingErrors) { return new InputStreamReader(openInputStream()); } @@ -145,7 +139,7 @@ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOExcept *

* Some IDEs like Eclipse don't like resource files ending with *.java. * In this case extend the file name by ".ct" suffix (f.e. "JavaClass.java.ct"). - * The suffix will be ignored for looking up files via the compile test file manager. + * The suffix will be ignored for looking up files via the compile-test file manager. * * * * @param location the location @@ -167,7 +161,7 @@ public static SimpleJavaFileObject readFromResource(String location, Class re *

* Some IDEs like Eclipse don't like resource files ending with *.java. * In this case extend the file name by ".ct" suffix (f.e. "JavaClass.java.ct"). - * The suffix will be ignored for looking up files via the compile test file manager. + * The suffix will be ignored for looking up files via the compile-test file manager. * * @param location the location * @return The SimpleJavaFileObject for resource @@ -187,20 +181,20 @@ public static SimpleJavaFileObject readFromResource(String location) { *

* Some IDEs like Eclipse don't like resource files ending with *.java. * In this case extend the file name by ".ct" suffix (f.e. "JavaClass.java.ct"). - * The suffix will be ignored for looking up files via the compile test file manager. + * The suffix will be ignored for looking up files via the compile-test file manager. * * @param locations the location * @return The SimpleJavaFileObject for resource */ public static SimpleJavaFileObject[] readFromResources(String... locations) { - List resourceFiles = new ArrayList(); + List resourceFiles = new ArrayList<>(); for (String location : locations) { resourceFiles.add(readFromResource(location)); } - return resourceFiles.toArray(new SimpleJavaFileObject[resourceFiles.size()]); + return resourceFiles.toArray(new SimpleJavaFileObject[0]); } /** @@ -225,7 +219,7 @@ public static SimpleJavaFileObject readFromString(String location, String conten /** * Read a java source file from resources. - * This one works great if you don't rely on the location, f.e. in case of comparision. + * This one works great if you don't rely on the location, f.e. in case of comparison. * * @param content content of the file * @return he SimpleJavaFileObject for passed content string @@ -240,7 +234,7 @@ public static SimpleJavaFileObject readFromString(String content) { /** - * Read a java source file from resurces. + * Read a java source file from resources. * * @param url the location * @return The SimpleJavaFileObject for passed URL @@ -269,7 +263,7 @@ private static String readFromInputStream(InputStream stream) throws IOException byte[] buffer = new byte[10000]; ByteArrayOutputStream os = new ByteArrayOutputStream(); - int line = 0; + int line; // read bytes from stream, and store them in buffer while ((line = stream.read(buffer)) != -1) { // Writes bytes from byte array (buffer) into output stream. @@ -279,7 +273,7 @@ private static String readFromInputStream(InputStream stream) throws IOException os.flush(); os.close(); - return new String(os.toByteArray()); + return os.toString(); } diff --git a/cute/src/main/java/io/toolisticon/cute/UnitTestForTestingAnnotationProcessors.java b/cute/src/main/java/io/toolisticon/cute/UnitTestForTestingAnnotationProcessors.java index 86a390f..cbf8165 100644 --- a/cute/src/main/java/io/toolisticon/cute/UnitTestForTestingAnnotationProcessors.java +++ b/cute/src/main/java/io/toolisticon/cute/UnitTestForTestingAnnotationProcessors.java @@ -6,9 +6,9 @@ /** * Interface that is used during unit test creation. It allows setting up a unit test without the need to create a valid annotation processor. - * In comparision to {@link UnitTest} an instance of the processor under test will be created and it's init method will be called. + * In comparison to {@link UnitTest} an instance of the processor under test will be created and it's init method will be called. * - * @param the processor to use + * @param the processor to use * @param the expected element type to be found */ public interface UnitTestForTestingAnnotationProcessors { @@ -18,7 +18,7 @@ public interface UnitTestForTestingAnnotationProcessors 0) { @@ -196,7 +196,7 @@ static String getFileObjectInfoString(CompileTestConfiguration.GeneratedFileObje /** * Init the compilation and compile. * - * @param compileTestConfiguration the compile test configuration to use + * @param compileTestConfiguration the compile-test configuration to use * @return the compilation result */ public static CompilationResult compile(CompileTestConfiguration compileTestConfiguration) { @@ -280,7 +280,7 @@ void checkMessages(DiagnosticCollector diagnostics) { // Check message - switch (messageToCheck.getComparisionKind()) { + switch (messageToCheck.getComparisonKind()) { case EQUALS: { if (!localizedMessage.equals(messageToCheck.getExpectedMessage())) { diff --git a/cute/src/main/java/io/toolisticon/cute/impl/CompileTestConfiguration.java b/cute/src/main/java/io/toolisticon/cute/impl/CompileTestConfiguration.java index 7ff7544..532ff94 100644 --- a/cute/src/main/java/io/toolisticon/cute/impl/CompileTestConfiguration.java +++ b/cute/src/main/java/io/toolisticon/cute/impl/CompileTestConfiguration.java @@ -11,14 +11,14 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; /** - * The compile test configuration to use for compilation test. + * The compile-test configuration to use for compilation test. */ public class CompileTestConfiguration { @@ -96,15 +96,15 @@ public String toString() { } } - public enum ComparisionKind { + public enum ComparisonKind { EQUALS, - CONTAINS; + CONTAINS } public static class CompilerMessageCheck { private final Diagnostic.Kind kind; - private final ComparisionKind comparisionKind; + private final ComparisonKind comparisonKind; private final String expectedMessage; private final Locale locale; private final String source; @@ -112,9 +112,9 @@ public static class CompilerMessageCheck { private final Long column; - public CompilerMessageCheck(Diagnostic.Kind kind, ComparisionKind comparisionKind, String expectedMessage, Locale locale, String source, Long row, Long column) { + public CompilerMessageCheck(Diagnostic.Kind kind, ComparisonKind comparisonKind, String expectedMessage, Locale locale, String source, Long row, Long column) { this.kind = kind; - this.comparisionKind = comparisionKind; + this.comparisonKind = comparisonKind; this.expectedMessage = expectedMessage; this.locale = locale; this.source = source; @@ -126,8 +126,8 @@ public Diagnostic.Kind getKind() { return kind; } - public ComparisionKind getComparisionKind() { - return comparisionKind; + public ComparisonKind getComparisonKind() { + return comparisonKind; } public String getExpectedMessage() { @@ -159,20 +159,20 @@ public boolean equals(Object o) { CompilerMessageCheck that = (CompilerMessageCheck) o; if (kind != that.kind) return false; - if (comparisionKind != null ? !comparisionKind.equals(that.comparisionKind) : that.comparisionKind != null) + if (!Objects.equals(comparisonKind, that.comparisonKind)) return false; - if (expectedMessage != null ? !expectedMessage.equals(that.expectedMessage) : that.expectedMessage != null) + if (!Objects.equals(expectedMessage, that.expectedMessage)) return false; - if (locale != null ? !locale.equals(that.locale) : that.locale != null) return false; - if (source != null ? !source.equals(that.source) : that.source != null) return false; - if (row != null ? !row.equals(that.row) : that.row != null) return false; - return column != null ? column.equals(that.column) : that.column == null; + if (!Objects.equals(locale, that.locale)) return false; + if (!Objects.equals(source, that.source)) return false; + if (!Objects.equals(row, that.row)) return false; + return Objects.equals(column, that.column); } @Override public int hashCode() { int result = kind != null ? kind.hashCode() : 0; - result = 31 * result + (comparisionKind != null ? comparisionKind.hashCode() : 0); + result = 31 * result + (comparisonKind != null ? comparisonKind.hashCode() : 0); result = 31 * result + (expectedMessage != null ? expectedMessage.hashCode() : 0); result = 31 * result + (locale != null ? locale.hashCode() : 0); result = 31 * result + (source != null ? source.hashCode() : 0); @@ -185,7 +185,7 @@ public int hashCode() { public String toString() { return "CompilerMessageCheck{" + "kind=" + kind + - ", comparisionKind=" + comparisionKind + + ", comparisonKind=" + comparisonKind + ", expectedMessage='" + expectedMessage + '\'' + ", locale=" + locale + ", source='" + source + '\'' + @@ -493,7 +493,7 @@ public String toString() { } } - public class PassInConfiguration { + public static class PassInConfiguration { private final Class passedInClass; private final Class annotationToScanFor; @@ -550,7 +550,7 @@ public String toString() { private Set wrappedProcessors = null; /** - * Global processor independant expected exceptions. + * Global processor independent expected exceptions. */ private Class expectedThrownException = null; @@ -708,23 +708,23 @@ public void clearModules() { this.modules = null; } - public void addWarningMessageCheck(ComparisionKind comparisonKind, String... messages) { + public void addWarningMessageCheck(ComparisonKind comparisonKind, String... messages) { addCompilerMessage(Diagnostic.Kind.WARNING, comparisonKind, messages); } - public void addMandatoryWarningMessageCheck(ComparisionKind comparisonKind, String... messages) { + public void addMandatoryWarningMessageCheck(ComparisonKind comparisonKind, String... messages) { addCompilerMessage(Diagnostic.Kind.MANDATORY_WARNING, comparisonKind, messages); } - public void addErrorMessageCheck(ComparisionKind comparisonKind, String... messages) { + public void addErrorMessageCheck(ComparisonKind comparisonKind, String... messages) { addCompilerMessage(Diagnostic.Kind.ERROR, comparisonKind, messages); } - public void addNoteMessageCheck(ComparisionKind comparisonKind, String... messages) { + public void addNoteMessageCheck(ComparisonKind comparisonKind, String... messages) { addCompilerMessage(Diagnostic.Kind.NOTE, comparisonKind, messages); } - private void addCompilerMessage(Diagnostic.Kind kind, ComparisionKind comparisonKind, String... messages) { + private void addCompilerMessage(Diagnostic.Kind kind, ComparisonKind comparisonKind, String... messages) { if (messages != null) { for (String message : messages) { if (message != null) { @@ -746,7 +746,6 @@ public void addGeneratedJavaFileObjectCheck(FileObjectCheckType checkType, JavaF this.generatedJavaFileObjectChecks.add(new GeneratedJavaFileObjectCheck(checkType, location, className, kind, null)); } - @SafeVarargs public final void addGeneratedFileObjectCheck(FileObjectCheckType checkType, JavaFileManager.Location location, String packageName, String relativeName, GeneratedFileObjectMatcher... generatedFileObjectMatcher) { this.generatedFileObjectChecks.add(new GeneratedFileObjectCheck(checkType, location, packageName, relativeName, generatedFileObjectMatcher)); } @@ -818,7 +817,7 @@ public Set getWrappedProcessors() { for (Class processorType : this.processorTypes) { try { - Processor processor = (Processor) processorType.getDeclaredConstructor().newInstance(); + Processor processor = processorType.getDeclaredConstructor().newInstance(); wrappedProcessors.add(AnnotationProcessorWrapper.wrapProcessor(processor, expectedThrownException)); @@ -873,10 +872,9 @@ public Map> getCompilerMessageCheckB public long countErrorMessageChecks() { long count = 0; - Iterator iterator = compilerMessageChecks.iterator(); - while (iterator.hasNext()) { - if (Diagnostic.Kind.ERROR.equals(iterator.next().getKind())) { + for (CompilerMessageCheck compilerMessageCheck : compilerMessageChecks) { + if (Diagnostic.Kind.ERROR.equals(compilerMessageCheck.getKind())) { count++; } } diff --git a/cute/src/main/java/io/toolisticon/cute/impl/CompileTestFileManager.java b/cute/src/main/java/io/toolisticon/cute/impl/CompileTestFileManager.java index 2c1ec78..c16352d 100644 --- a/cute/src/main/java/io/toolisticon/cute/impl/CompileTestFileManager.java +++ b/cute/src/main/java/io/toolisticon/cute/impl/CompileTestFileManager.java @@ -69,11 +69,11 @@ public CompileTestFileManager(StandardJavaFileManager standardJavaFileManager) { } List getGeneratedJavaFileObjects() { - return new ArrayList(generatedJavaFileObjectCache.getEntries()); + return new ArrayList<>(generatedJavaFileObjectCache.getEntries()); } List getGeneratedFileObjects() { - return new ArrayList(generatedFileObjectCache.getEntries()); + return new ArrayList<>(generatedFileObjectCache.getEntries()); } @Override @@ -82,8 +82,7 @@ public boolean isSameFile(FileObject a, FileObject b) { } @Override - public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException { - + public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind, FileObject sibling) { JavaFileObject result = new InMemoryOutputJavaFileObject(uriForJavaFileObject(location, className, kind), kind); generatedJavaFileObjectCache.addFileObject(result.toUri(), result); @@ -92,7 +91,7 @@ public JavaFileObject getJavaFileForOutput(Location location, String className, } @Override - public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException { + public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) { JavaFileObject result = new InMemoryOutputJavaFileObject(uriForFileObject(location, packageName, relativeName), JavaFileObject.Kind.OTHER); generatedFileObjectCache.addFileObject(result.toUri(), result); return result; @@ -198,27 +197,27 @@ public void setContent(byte[] content) { } @Override - public InputStream openInputStream() throws IOException { + public InputStream openInputStream() { return new ByteArrayInputStream(content); } @Override - public OutputStream openOutputStream() throws IOException { + public OutputStream openOutputStream() { return new InMemoryOutputStream(this); } @Override - public Reader openReader(boolean ignoreEncodingErrors) throws IOException { + public Reader openReader(boolean ignoreEncodingErrors) { return new InputStreamReader(openInputStream()); } @Override - public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + public CharSequence getCharContent(boolean ignoreEncodingErrors){ return new String(content); } @Override - public Writer openWriter() throws IOException { + public Writer openWriter(){ return new OutputStreamWriter(openOutputStream()); } } @@ -244,7 +243,7 @@ public void close() throws IOException { } @Override - public void write(byte[] b) throws IOException { + public void write( byte[] b) throws IOException { super.write(b); outputStreamCallback.setContent(this.toByteArray()); } diff --git a/cute/src/main/java/io/toolisticon/cute/impl/DebugOutputGenerator.java b/cute/src/main/java/io/toolisticon/cute/impl/DebugOutputGenerator.java index 0b6abf2..f7e4e3b 100644 --- a/cute/src/main/java/io/toolisticon/cute/impl/DebugOutputGenerator.java +++ b/cute/src/main/java/io/toolisticon/cute/impl/DebugOutputGenerator.java @@ -43,7 +43,7 @@ static String getDebugOutput(CompilationResult compilationResult, CompileTestCon stringBuilder.append(getDebugOutputHeader("UNEXPECTED EXCEPTION")) .append("MESSAGE : ").append(message != null ? message : "").append("\n") - .append("STACKTRACE : ").append(stacktraceStringWriter.toString()).append("\n"); + .append("STACKTRACE : ").append(stacktraceStringWriter).append("\n"); } if (compilationResult != null) { @@ -83,7 +83,7 @@ private static String getDebugOutputHeader(String headerString) { /** * Used to determine the build folder. *

- * Maybe "target" for Maven builds and a folder containing "build" in it's name for gradle. + * Maybe "target" for Maven builds and a folder containing "build" in its name for gradle. * Defaults to "target". * * @return the build folder name @@ -95,7 +95,7 @@ private static String determineBuildFolder() { } else if (new File("build").isDirectory()) { return "build"; } else { - // a folder containing build in it's name + // a folder containing build in its name File[] possibleBuildDirectories = new File(".").listFiles(new FileFilter() { @Override public boolean accept(File pathname) { @@ -142,13 +142,12 @@ private static String getDebugMessages(CompilationResult compilationResult, Diag private static String getGeneratedFileOverview(CompilationResult compilationResult) { - String stringBuilder = "{\n" + + return "{\n" + " 'GENERATED JAVA FILE OBJECTS' : " + createGeneratedFileObjectOverview(compilationResult.getCompileTestFileManager().getGeneratedJavaFileObjects()) + ",\n 'GENERATED FILE OBJECTS' :" + createGeneratedFileObjectOverview(compilationResult.getCompileTestFileManager().getGeneratedFileObjects()) + "\n}"; - return stringBuilder; } diff --git a/cute/src/main/java/io/toolisticon/cute/impl/Java9SupportCheck.java b/cute/src/main/java/io/toolisticon/cute/impl/Java9SupportCheck.java index fb4fe41..7d908b3 100644 --- a/cute/src/main/java/io/toolisticon/cute/impl/Java9SupportCheck.java +++ b/cute/src/main/java/io/toolisticon/cute/impl/Java9SupportCheck.java @@ -13,7 +13,7 @@ final class Java9SupportCheck { static { // get ModuleFinderClass - Class moduleFinderClass = null; + Class moduleFinderClass = null; try { moduleFinderClass = Class.forName("java.lang.module.ModuleFinder"); } catch (Exception e) { @@ -25,7 +25,7 @@ final class Java9SupportCheck { } /** - * Hiddden constructor. + * Hidden constructor. */ private Java9SupportCheck() { diff --git a/cute/src/main/java/io/toolisticon/cute/matchers/BinaryGeneratedFileObjectMatcher.java b/cute/src/main/java/io/toolisticon/cute/matchers/BinaryGeneratedFileObjectMatcher.java index e3f14cb..02abce1 100644 --- a/cute/src/main/java/io/toolisticon/cute/matchers/BinaryGeneratedFileObjectMatcher.java +++ b/cute/src/main/java/io/toolisticon/cute/matchers/BinaryGeneratedFileObjectMatcher.java @@ -8,6 +8,7 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Objects; import java.util.regex.PatternSyntaxException; /** @@ -73,7 +74,7 @@ public boolean equals(Object o) { BinaryGeneratedFileObjectMatcher that = (BinaryGeneratedFileObjectMatcher) o; - return expectedFileObject != null ? expectedFileObject.equals(that.expectedFileObject) : that.expectedFileObject == null; + return Objects.equals(expectedFileObject, that.expectedFileObject); } @Override diff --git a/cute/src/main/java/io/toolisticon/cute/matchers/ContainsStringsGeneratedFileOjectMatcher.java b/cute/src/main/java/io/toolisticon/cute/matchers/ContainsStringsGeneratedFileObjectMatcher.java similarity index 82% rename from cute/src/main/java/io/toolisticon/cute/matchers/ContainsStringsGeneratedFileOjectMatcher.java rename to cute/src/main/java/io/toolisticon/cute/matchers/ContainsStringsGeneratedFileObjectMatcher.java index 1065f7b..8b1b1da 100644 --- a/cute/src/main/java/io/toolisticon/cute/matchers/ContainsStringsGeneratedFileOjectMatcher.java +++ b/cute/src/main/java/io/toolisticon/cute/matchers/ContainsStringsGeneratedFileObjectMatcher.java @@ -10,7 +10,7 @@ /** * Validates if the generated file contains all passed Strings. */ -class ContainsStringsGeneratedFileOjectMatcher implements GeneratedFileObjectMatcher { +class ContainsStringsGeneratedFileObjectMatcher implements GeneratedFileObjectMatcher { String[] stringsToCheck; @@ -18,7 +18,7 @@ class ContainsStringsGeneratedFileOjectMatcher implements GeneratedFileObjectMat /** * Hidden constructor */ - ContainsStringsGeneratedFileOjectMatcher(String... stringsToCheck) { + ContainsStringsGeneratedFileObjectMatcher(String... stringsToCheck) { this.stringsToCheck = stringsToCheck; } @@ -30,7 +30,7 @@ public boolean check(FileObject fileObject) throws IOException { for (String stringToCheck : stringsToCheck) { if (!fileContent.contains(stringToCheck)) { - throw new FailingAssertionException(Constants.Messages.GFOM_COULDNT_FIND_SUBSTRING.produceMessage(stringToCheck, fileObject.getName().toString())); + throw new FailingAssertionException(Constants.Messages.GFOM_COULDNT_FIND_SUBSTRING.produceMessage(stringToCheck, fileObject.getName())); } } diff --git a/cute/src/main/java/io/toolisticon/cute/matchers/CoreGeneratedFileObjectMatchers.java b/cute/src/main/java/io/toolisticon/cute/matchers/CoreGeneratedFileObjectMatchers.java index f26603c..5c26d1c 100644 --- a/cute/src/main/java/io/toolisticon/cute/matchers/CoreGeneratedFileObjectMatchers.java +++ b/cute/src/main/java/io/toolisticon/cute/matchers/CoreGeneratedFileObjectMatchers.java @@ -36,13 +36,13 @@ public static GeneratedFileObjectMatcher createRegexMatcher(String pattern) { } /** - * Static function to create a {@link ContainsStringsGeneratedFileOjectMatcher} instance. + * Static function to create a {@link ContainsStringsGeneratedFileObjectMatcher} instance. * * @return the instance * @throws PatternSyntaxException If the expression's syntax is invalid */ public static GeneratedFileObjectMatcher createContainsSubstringsMatcher(String... stringsToSearch) { - return new ContainsStringsGeneratedFileOjectMatcher(stringsToSearch); + return new ContainsStringsGeneratedFileObjectMatcher(stringsToSearch); } diff --git a/cute/src/main/java/io/toolisticon/cute/matchers/IgnoreLineEndingsGeneratedFileObjectMatcher.java b/cute/src/main/java/io/toolisticon/cute/matchers/IgnoreLineEndingsGeneratedFileObjectMatcher.java index f1cee76..5a47b1d 100644 --- a/cute/src/main/java/io/toolisticon/cute/matchers/IgnoreLineEndingsGeneratedFileObjectMatcher.java +++ b/cute/src/main/java/io/toolisticon/cute/matchers/IgnoreLineEndingsGeneratedFileObjectMatcher.java @@ -6,16 +6,16 @@ import javax.tools.FileObject; import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.Objects; import java.util.regex.PatternSyntaxException; /** * Validates if file objects are matching. * Does validation line by line and ignores line endings. - * (this is good for text files since windows and linux operation systems are using different line endings) + * (this is good for text files since windows and linux operation-systems are using different line endings) */ public class IgnoreLineEndingsGeneratedFileObjectMatcher implements GeneratedFileObjectMatcher { @@ -78,7 +78,7 @@ public boolean equals(Object o) { IgnoreLineEndingsGeneratedFileObjectMatcher that = (IgnoreLineEndingsGeneratedFileObjectMatcher) o; - return expectedFileObject != null ? expectedFileObject.equals(that.expectedFileObject) : that.expectedFileObject == null; + return Objects.equals(expectedFileObject, that.expectedFileObject); } @Override diff --git a/cute/src/main/java/io/toolisticon/cute/matchers/WellFormedXmlGeneratedFileObjectMatcher.java b/cute/src/main/java/io/toolisticon/cute/matchers/WellFormedXmlGeneratedFileObjectMatcher.java index 530ff79..218e29d 100644 --- a/cute/src/main/java/io/toolisticon/cute/matchers/WellFormedXmlGeneratedFileObjectMatcher.java +++ b/cute/src/main/java/io/toolisticon/cute/matchers/WellFormedXmlGeneratedFileObjectMatcher.java @@ -11,7 +11,7 @@ import java.io.IOException; /** - * Matcher to check if file contains well formed xml. + * Matcher to check if file contains well-formed xml. */ class WellFormedXmlGeneratedFileObjectMatcher implements GeneratedFileObjectMatcher { @@ -28,7 +28,7 @@ public boolean check(FileObject fileObject) throws IOException { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - // speed up processing by preventing dowwnloading of dtds + // speed up processing by preventing downloading of dtds factory.setValidating(false); factory.setNamespaceAware(false); factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); @@ -39,7 +39,7 @@ public boolean check(FileObject fileObject) throws IOException { return true; } catch (Exception e) { - throw new FailingAssertionException(Constants.Messages.GFOM_FILEOBJECT_IS_NOT_WELL_FORMED.produceMessage(fileObject.getName().toString())); + throw new FailingAssertionException(Constants.Messages.GFOM_FILEOBJECT_IS_NOT_WELL_FORMED.produceMessage(fileObject.getName())); } diff --git a/cute/src/test/java/io/toolisticon/cute/CompileTestBuilderTest.java b/cute/src/test/java/io/toolisticon/cute/CompileTestBuilderTest.java index 7f2db8d..320a40b 100644 --- a/cute/src/test/java/io/toolisticon/cute/CompileTestBuilderTest.java +++ b/cute/src/test/java/io/toolisticon/cute/CompileTestBuilderTest.java @@ -170,7 +170,7 @@ public void unitTest(ProcessingEnvironment processingEnvironment, Element typeEl } - private void assertCompilerMessages(Set compilerMessageChecks, Diagnostic.Kind kind, CompileTestConfiguration.ComparisionKind comparisionKind, String... expectedMessages) { + private void assertCompilerMessages(Set compilerMessageChecks, Diagnostic.Kind kind, CompileTestConfiguration.ComparisonKind comparisonKind, String... expectedMessages) { List configuredExpectedMessages = new ArrayList<>(); @@ -178,7 +178,7 @@ private void assertCompilerMessages(Set files = new ArrayList(); + List files = new ArrayList<>(); for (String module : modules) { File moduleFile = moduleNameToJarMap.get(module); @@ -73,7 +73,7 @@ public void writeModuleDebugOutput(StringBuilder stringBuilder) { Map getModuleNameToJarMap(Set modules) { // get a map for lookup of jar files by module name - Map moduleToJarMap = new HashMap(); + Map moduleToJarMap = new HashMap<>(); if (modules != null) { try { @@ -161,7 +161,7 @@ static ModuleReference getMatchingModuleReferenceWrapper(Set mo static List getJarsFromClasspath() { - List urls = new ArrayList(); + List urls = new ArrayList<>(); String[] pathElements = System.getProperty("java.class.path").split(System.getProperty("path.separator")); diff --git a/integration-test/junit4/src/test/java/io/toolisticon/cute/integrationtest/junit4/Junit4Test.java b/integration-test/junit4/src/test/java/io/toolisticon/cute/integrationtest/junit4/Junit4Test.java index 3bf16b4..63cc313 100644 --- a/integration-test/junit4/src/test/java/io/toolisticon/cute/integrationtest/junit4/Junit4Test.java +++ b/integration-test/junit4/src/test/java/io/toolisticon/cute/integrationtest/junit4/Junit4Test.java @@ -32,7 +32,7 @@ public void warningMessageTest() { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.WARNING, "WARNING!"); @@ -50,9 +50,9 @@ public void successfullFailingCompilationTest_ByErrorMessage() { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { + public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!"); } }) @@ -69,7 +69,7 @@ public void failingCompilationTest_ByErrorMessage() { try { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!"); diff --git a/integration-test/junit5/src/test/java/io/toolisticon/cute/integrationtest/junit5/Junit5Test.java b/integration-test/junit5/src/test/java/io/toolisticon/cute/integrationtest/junit5/Junit5Test.java index 3a45b55..b1de845 100644 --- a/integration-test/junit5/src/test/java/io/toolisticon/cute/integrationtest/junit5/Junit5Test.java +++ b/integration-test/junit5/src/test/java/io/toolisticon/cute/integrationtest/junit5/Junit5Test.java @@ -31,9 +31,9 @@ public void warningMessageTest() { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { + public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.WARNING, "WARNING!"); } }) @@ -49,9 +49,9 @@ public void successfullFailingCompilationTest_ByErrorMessage() { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { + public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!"); } }) @@ -68,9 +68,9 @@ public void failingCompilationTest_ByErrorMessage() { try { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { + public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!"); } }) diff --git a/integration-test/testng/src/test/java/io/toolisticon/cute/integrationtest/testng/TestNgTest.java b/integration-test/testng/src/test/java/io/toolisticon/cute/integrationtest/testng/TestNgTest.java index 82ecc36..fdfc02e 100644 --- a/integration-test/testng/src/test/java/io/toolisticon/cute/integrationtest/testng/TestNgTest.java +++ b/integration-test/testng/src/test/java/io/toolisticon/cute/integrationtest/testng/TestNgTest.java @@ -31,7 +31,7 @@ public void warningMessageTest() { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.WARNING, "WARNING!"); @@ -49,9 +49,9 @@ public void successfullFailingCompilationTest_ByErrorMessage() { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { + public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!"); } }) @@ -68,9 +68,9 @@ public void failingCompilationTest_ByErrorMessage() { try { CompileTestBuilder .unitTest() - .defineTest(new UnitTest() { + .defineTest(new UnitTest() { @Override - public void unitTest(ProcessingEnvironment processingEnvironment, Element typeElement) { + public void unitTest(ProcessingEnvironment processingEnvironment, Element element) { processingEnvironment.getMessager().printMessage(Diagnostic.Kind.ERROR, "ERROR!"); } }) diff --git a/pom.xml b/pom.xml index 94dff83..d45071e 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ UTF-8 UTF-8 - 1.6 + 1.7 1.7 1.7 @@ -93,7 +93,7 @@ 2.28.2 - 1.16 + 1.17 2.4 2.5.3 2.18.1 @@ -146,7 +146,7 @@ [3.0.4,) - 1.6 + 1.7 false @@ -442,7 +442,7 @@ org.codehaus.mojo.signature - java16 + java17 1.0 @@ -475,7 +475,7 @@ org.codehaus.mojo animal-sniffer-maven-plugin - 1.16 + ${animal-sniffer-maven-plugin.version} @@ -499,7 +499,7 @@ org.codehaus.mojo.signature - java16 + java17 1.0