Skip to content

Commit

Permalink
Code cleanup / Move to Java 7
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstamann committed Apr 23, 2022
1 parent 8a7f57a commit fde9bba
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 165 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,9 +67,7 @@ protected List<Element> 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()) {
Expand Down
43 changes: 21 additions & 22 deletions cute/src/main/java/io/toolisticon/cute/CompileTestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public T useModules(String... modules) {
*/
public CompileMessageCheckBuilder<T> expectErrorMessage() {
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.ERROR);
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.ERROR);
}

/**
Expand All @@ -146,7 +146,7 @@ public CompileMessageCheckBuilder<T> expectErrorMessage() {
*/
public CompileMessageCheckBuilder<T> expectMandatoryWarningMessage() {
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.MANDATORY_WARNING);
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.MANDATORY_WARNING);
}

/**
Expand All @@ -156,7 +156,7 @@ public CompileMessageCheckBuilder<T> expectMandatoryWarningMessage() {
*/
public CompileMessageCheckBuilder<T> expectWarningMessage() {
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.WARNING);
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.WARNING);
}

/**
Expand All @@ -166,7 +166,7 @@ public CompileMessageCheckBuilder<T> expectWarningMessage() {
*/
public CompileMessageCheckBuilder<T> expectNoteMessage() {
CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);
return new CompileMessageCheckBuilder<T>(createNextInstance(nextConfiguration), Diagnostic.Kind.NOTE);
return new CompileMessageCheckBuilder<>(createNextInstance(nextConfiguration), Diagnostic.Kind.NOTE);
}

/**
Expand All @@ -178,7 +178,7 @@ public CompileMessageCheckBuilder<T> 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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

}
Expand Down Expand Up @@ -712,7 +711,7 @@ public <ELEMENT_TYPE extends Element> UnitTestBuilder defineTest(Class<? extends

// remove existing processor
nextConfiguration.getProcessors().clear();
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClass<ELEMENT_TYPE>(customAnnotationType, unitTest));
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClass<>(customAnnotationType, unitTest));

return createNextInstance(nextConfiguration);
}
Expand Down Expand Up @@ -768,7 +767,7 @@ public <ELEMENT_TYPE extends Element> UnitTestBuilder defineTestWithPassedInElem

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

return createNextInstance(nextConfiguration);
}
Expand Down Expand Up @@ -827,7 +826,7 @@ public <PROCESSOR_UNDER_TEST extends Processor, ELEMENT_TYPE extends Element> Un

CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);

PROCESSOR_UNDER_TEST processorUnderTest = null;
PROCESSOR_UNDER_TEST processorUnderTest;

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

// remove existing processor
nextConfiguration.getProcessors().clear();
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassForTestingAnnotationProcessors<PROCESSOR_UNDER_TEST, ELEMENT_TYPE>(processorUnderTest, customAnnotationType, unitTestForTestingAnnotationProcessors));
nextConfiguration.addProcessors(new UnitTestAnnotationProcessorClassForTestingAnnotationProcessors<>(processorUnderTest, customAnnotationType, unitTestForTestingAnnotationProcessors));

return createNextInstance(nextConfiguration);
}
Expand Down Expand Up @@ -888,7 +887,7 @@ public <PROCESSOR_UNDER_TEST extends Processor, ELEMENT_TYPE extends Element> Un

CompileTestConfiguration nextConfiguration = CompileTestConfiguration.cloneConfiguration(compileTestConfiguration);

PROCESSOR_UNDER_TEST processorUnderTest = null;
PROCESSOR_UNDER_TEST processorUnderTest;

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

private Diagnostic.Kind kind;
private CompileTestConfiguration.ComparisionKind comparisionKind;
private CompileTestConfiguration.ComparisonKind comparisonKind;
private String expectedMessage;
private Locale locale;
private String source;
Expand Down Expand Up @@ -1067,7 +1066,7 @@ public CompileMessageCheckBuilder<COMPILETESTBUILDER> 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<COMPILETESTBUILDER> atSource(String source) {
Expand All @@ -1086,10 +1085,10 @@ public CompileMessageCheckBuilder<COMPILETESTBUILDER> atSource(String source) {
public COMPILETESTBUILDER thatContains(String expectedContainedMessageToken) {
CompileMessageCheckBuilder<COMPILETESTBUILDER> 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);
}
Expand All @@ -1103,10 +1102,10 @@ public COMPILETESTBUILDER thatContains(String expectedContainedMessageToken) {
public COMPILETESTBUILDER thatIsEqualTo(String expectedMessage) {
CompileMessageCheckBuilder<COMPILETESTBUILDER> 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);
}
Expand All @@ -1122,7 +1121,7 @@ CompileMessageCheckBuilder<COMPILETESTBUILDER> createNextBuilder() {
CompileMessageCheckBuilder<COMPILETESTBUILDER> 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;
Expand Down
Loading

0 comments on commit fde9bba

Please sign in to comment.