Skip to content

Commit 1e4cdf6

Browse files
committed
Code cleanup / Move to Java 7
1 parent 8a7f57a commit 1e4cdf6

25 files changed

+158
-170
lines changed

.github/workflows/default.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest,macos-latest,windows-latest]
16-
java: [ 7, 7.0.181, 8, 8.0.192, 9.0.x, 10, 11.0.x, 11.0.3, 12]
15+
os: [ ubuntu-latest,macos-latest,windows-latest ]
16+
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 ]
1717

1818
steps:
1919
- uses: actions/checkout@v1

cute/src/main/java/io/toolisticon/cute/AbstractUnitTestAnnotationProcessorWithPassIn.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import javax.lang.model.element.ElementKind;
55
import javax.lang.model.element.ExecutableElement;
66
import javax.lang.model.element.TypeElement;
7-
import javax.lang.model.element.VariableElement;
87
import java.lang.annotation.Annotation;
98
import java.util.ArrayList;
109
import java.util.List;
@@ -68,9 +67,7 @@ protected List<Element> getAllSubElements(Element elementToScan) {
6867
result.add(elementToScan);
6968

7069
if (elementToScan.getKind() == ElementKind.CONSTRUCTOR || elementToScan.getKind() == ElementKind.METHOD) {
71-
for (VariableElement parameters : ((ExecutableElement) elementToScan).getParameters()) {
72-
result.add(parameters);
73-
}
70+
result.addAll(((ExecutableElement) elementToScan).getParameters());
7471
}
7572

7673
for (Element enclosedElement : elementToScan.getEnclosedElements()) {

cute/src/main/java/io/toolisticon/cute/CompileTestBuilder.java

+21-22
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public T useModules(String... modules) {
136136
*/
137137
public CompileMessageCheckBuilder<T> expectErrorMessage() {
138138
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
139-
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.ERROR);
139+
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.ERROR);
140140
}
141141

142142
/**
@@ -146,7 +146,7 @@ public CompileMessageCheckBuilder<T> expectErrorMessage() {
146146
*/
147147
public CompileMessageCheckBuilder<T> expectMandatoryWarningMessage() {
148148
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
149-
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.MANDATORY_WARNING);
149+
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.MANDATORY_WARNING);
150150
}
151151

152152
/**
@@ -156,7 +156,7 @@ public CompileMessageCheckBuilder<T> expectMandatoryWarningMessage() {
156156
*/
157157
public CompileMessageCheckBuilder<T> expectWarningMessage() {
158158
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
159-
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.WARNING);
159+
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.WARNING);
160160
}
161161

162162
/**
@@ -166,7 +166,7 @@ public CompileMessageCheckBuilder<T> expectWarningMessage() {
166166
*/
167167
public CompileMessageCheckBuilder<T> expectNoteMessage() {
168168
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
169-
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.NOTE);
169+
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.NOTE);
170170
}
171171

172172
/**
@@ -178,7 +178,7 @@ public CompileMessageCheckBuilder<T> expectNoteMessage() {
178178
public T expectWarningMessageThatContains(String... warningChecks) {
179179
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
180180
if (warningChecks != null) {
181-
nextConfiguration.addWarningMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, warningChecks);
181+
nextConfiguration.addWarningMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, warningChecks);
182182
}
183183
return createNextInstance(nextConfiguration);
184184

@@ -194,7 +194,7 @@ public T expectMandatoryWarningMessageThatContains(String... mandatoryWarningChe
194194

195195
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
196196
if (mandatoryWarningChecks != null) {
197-
nextConfiguration.addMandatoryWarningMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, mandatoryWarningChecks);
197+
nextConfiguration.addMandatoryWarningMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, mandatoryWarningChecks);
198198
}
199199
return createNextInstance(nextConfiguration);
200200

@@ -210,7 +210,7 @@ public T expectErrorMessageThatContains(String... errorChecksToSet) {
210210

211211
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
212212
if (errorChecksToSet != null) {
213-
nextConfiguration.addErrorMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, errorChecksToSet);
213+
nextConfiguration.addErrorMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, errorChecksToSet);
214214
}
215215
return createNextInstance(nextConfiguration);
216216

@@ -226,7 +226,7 @@ public T expectNoteMessageThatContains(String... noteChecksToSet) {
226226

227227
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
228228
if (noteChecksToSet != null) {
229-
nextConfiguration.addNoteMessageCheck(CompileTestConfiguration.ComparisionKind.CONTAINS, noteChecksToSet);
229+
nextConfiguration.addNoteMessageCheck(CompileTestConfiguration.ComparisonKind.CONTAINS, noteChecksToSet);
230230
}
231231
return createNextInstance(nextConfiguration);
232232

@@ -323,7 +323,6 @@ public T expectThatFileObjectExists(
323323
* @param generatedFileObjectMatcher the matcher to use
324324
* @return the next builder instance
325325
*/
326-
@SafeVarargs
327326
public final T expectThatFileObjectExists(
328327
JavaFileManager.Location location,
329328
String packageName,
@@ -351,7 +350,7 @@ public T expectThatFileObjectDoesntExist(
351350
String relativeName) {
352351

353352
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
354-
nextConfiguration.addGeneratedFileObjectCheck(CompileTestConfiguration.FileObjectCheckType.DOESNT_EXIST, location, packageName, relativeName, null);
353+
nextConfiguration.addGeneratedFileObjectCheck(CompileTestConfiguration.FileObjectCheckType.DOESNT_EXIST, location, packageName, relativeName);
355354
return createNextInstance(nextConfiguration);
356355

357356
}
@@ -712,7 +711,7 @@ public <ELEMENT_TYPE extends Element> UnitTestBuilder defineTest(Class<? extends
712711

713712
// remove existing processor
714713
nextConfiguration.getProcessors().clear();
715-
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClass<ELEMENT_TYPE>(customAnnotationType, unitTest));
714+
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClass<>(customAnnotationType, unitTest));
716715

717716
return createNextInstance(nextConfiguration);
718717
}
@@ -768,7 +767,7 @@ public <ELEMENT_TYPE extends Element> UnitTestBuilder defineTestWithPassedInElem
768767

769768
// remove existing processor
770769
nextConfiguration.getProcessors().clear();
771-
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassWithPassIn<ELEMENT_TYPE>(classToScan, annotationToSearch != null ? annotationToSearch : PassIn.class, unitTest));
770+
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassWithPassIn<>(classToScan, annotationToSearch != null ? annotationToSearch : PassIn.class, unitTest));
772771

773772
return createNextInstance(nextConfiguration);
774773
}
@@ -827,7 +826,7 @@ public <PROCESSOR_UNDER_TEST extends Processor, ELEMENT_TYPE extends Element> Un
827826

828827
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
829828

830-
PROCESSOR_UNDER_TEST processorUnderTest = null;
829+
PROCESSOR_UNDER_TEST processorUnderTest;
831830

832831
try {
833832
processorUnderTest = processorUnderTestClass.getDeclaredConstructor().newInstance();
@@ -838,7 +837,7 @@ public <PROCESSOR_UNDER_TEST extends Processor, ELEMENT_TYPE extends Element> Un
838837

839838
// remove existing processor
840839
nextConfiguration.getProcessors().clear();
841-
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassForTestingAnnotationProcessors<PROCESSOR_UNDER_TEST, ELEMENT_TYPE>(processorUnderTest, customAnnotationType, unitTestForTestingAnnotationProcessors));
840+
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassForTestingAnnotationProcessors<>(processorUnderTest, customAnnotationType, unitTestForTestingAnnotationProcessors));
842841

843842
return createNextInstance(nextConfiguration);
844843
}
@@ -888,7 +887,7 @@ public <PROCESSOR_UNDER_TEST extends Processor, ELEMENT_TYPE extends Element> Un
888887

889888
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
890889

891-
PROCESSOR_UNDER_TEST processorUnderTest = null;
890+
PROCESSOR_UNDER_TEST processorUnderTest;
892891

893892
try {
894893
processorUnderTest = processorUnderTestClass.getDeclaredConstructor().newInstance();
@@ -1010,7 +1009,7 @@ public static class CompileMessageCheckBuilder<COMPILETESTBUILDER extends BasicB
10101009
private final COMPILETESTBUILDER compileTestBuilder;
10111010

10121011
private Diagnostic.Kind kind;
1013-
private CompileTestConfiguration.ComparisionKind comparisionKind;
1012+
private CompileTestConfiguration.ComparisonKind comparisonKind;
10141013
private String expectedMessage;
10151014
private Locale locale;
10161015
private String source;
@@ -1067,7 +1066,7 @@ public CompileMessageCheckBuilder<COMPILETESTBUILDER> withLocale(Locale locale)
10671066
/**
10681067
* Do check if compiler message is linked for a specific source
10691068
*
1070-
* @param source
1069+
* @param source the source
10711070
* @return the next immutable builder instance
10721071
*/
10731072
public CompileMessageCheckBuilder<COMPILETESTBUILDER> atSource(String source) {
@@ -1086,10 +1085,10 @@ public CompileMessageCheckBuilder<COMPILETESTBUILDER> atSource(String source) {
10861085
public COMPILETESTBUILDER thatContains(String expectedContainedMessageToken) {
10871086
CompileMessageCheckBuilder<COMPILETESTBUILDER> nextBuilder = createNextBuilder();
10881087

1089-
nextBuilder.comparisionKind = CompileTestConfiguration.ComparisionKind.CONTAINS;
1088+
nextBuilder.comparisonKind = CompileTestConfiguration.ComparisonKind.CONTAINS;
10901089
nextBuilder.expectedMessage = expectedContainedMessageToken;
10911090

1092-
CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisionKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber);
1091+
CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisonKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber);
10931092

10941093
return compileTestBuilder.addCompilerMessageCheck(compilerMessageCheck);
10951094
}
@@ -1103,10 +1102,10 @@ public COMPILETESTBUILDER thatContains(String expectedContainedMessageToken) {
11031102
public COMPILETESTBUILDER thatIsEqualTo(String expectedMessage) {
11041103
CompileMessageCheckBuilder<COMPILETESTBUILDER> nextBuilder = createNextBuilder();
11051104

1106-
nextBuilder.comparisionKind = CompileTestConfiguration.ComparisionKind.EQUALS;
1105+
nextBuilder.comparisonKind = CompileTestConfiguration.ComparisonKind.EQUALS;
11071106
nextBuilder.expectedMessage = expectedMessage;
11081107

1109-
CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisionKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber);
1108+
CompileTestConfiguration.CompilerMessageCheck compilerMessageCheck = new CompileTestConfiguration.CompilerMessageCheck(nextBuilder.kind, nextBuilder.comparisonKind, nextBuilder.expectedMessage, nextBuilder.locale, nextBuilder.source, nextBuilder.lineNumber, nextBuilder.columnNumber);
11101109

11111110
return compileTestBuilder.addCompilerMessageCheck(compilerMessageCheck);
11121111
}
@@ -1122,7 +1121,7 @@ CompileMessageCheckBuilder<COMPILETESTBUILDER> createNextBuilder() {
11221121
CompileMessageCheckBuilder<COMPILETESTBUILDER> nextBuilder = new CompileMessageCheckBuilder<>(this.compileTestBuilder, this.kind);
11231122

11241123
nextBuilder.kind = this.kind;
1125-
nextBuilder.comparisionKind = this.comparisionKind;
1124+
nextBuilder.comparisonKind = this.comparisonKind;
11261125
nextBuilder.expectedMessage = this.expectedMessage;
11271126
nextBuilder.locale = this.locale;
11281127
nextBuilder.source = this.source;

0 commit comments

Comments
 (0)