Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Jun 18, 2024
1 parent 4f7c37e commit a3ceba9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.firemage.autograder.core.compiler;

import java.util.Arrays;
import java.util.Comparator;

public enum JavaVersion {
JAVA_7("7", 7),
Expand All @@ -13,7 +14,8 @@ public enum JavaVersion {
JAVA_14("14", 14),
JAVA_15("15", 15),
JAVA_16("16", 16),
JAVA_17("17", 17);
JAVA_17("17", 17),
JAVA_21("21", 21);

private final String versionString;
private final int versionNumber;
Expand All @@ -30,6 +32,10 @@ public static JavaVersion fromString(String s) {
.orElseThrow(() -> new IllegalArgumentException("Unknown java version"));
}

public static JavaVersion latest() {
return Arrays.stream(JavaVersion.values()).max(Comparator.comparingInt(JavaVersion::getVersionNumber)).orElseThrow();
}

public static boolean isValidJavaVersion(String s) {
return Arrays.stream(JavaVersion.class.getEnumConstants())
.anyMatch(v -> v.getVersionString().equals(s));
Expand Down
2 changes: 0 additions & 2 deletions autograder-core/src/main/resources/strings.en.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
status-compiling = Compiling
status-spotbugs = Running SpotBugs
status-pmd = Running PMD
status-cpd = Running Copy/Paste-Detection
status-error-prone = Running error-prone
status-model = Building the code model
status-integrated = Running integrated analysis
# Linters
linter-cpd = Copy/Paste-Detection
linter-spotbugs = SpotBugs
linter-pmd = PMD
linter-integrated = Integrated Analysis
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.firemage.autograder.core;

import de.firemage.autograder.core.compiler.JavaVersion;
import de.firemage.autograder.core.integrated.SpoonUtil;
import fluent.bundle.FluentBundle;
import fluent.bundle.FluentResource;
Expand Down Expand Up @@ -63,10 +64,8 @@ class TestLocalizedStrings {
"status-compiling",
"status-spotbugs",
"status-pmd",
"status-cpd",
"status-model",
"status-integrated",
"linter-cpd",
"linter-spotbugs",
"linter-pmd",
"linter-integrated",
Expand Down Expand Up @@ -185,7 +184,7 @@ static void readChecksAndResources() {

SpoonAPI launcher = new Launcher();
launcher.addInputResource(path.toString());
launcher.getEnvironment().setComplianceLevel(17);
launcher.getEnvironment().setComplianceLevel(JavaVersion.latest().getVersionNumber());

launcher.buildModel();
CtModel ctModel = launcher.getModel();
Expand Down

0 comments on commit a3ceba9

Please sign in to comment.