diff --git a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java index 0b33ccec..f1cf3f96 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java @@ -21,7 +21,6 @@ import java.math.BigDecimal; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Stack; import java.util.UUID; @@ -50,19 +49,7 @@ public abstract class ScenarioTest extends ContextBasedTest { return Optional.of(currentTestMethodProduces.pop()); } - public record Alias>(UUID uuid) { - - @Override - public String toString() { - return Objects.toString(uuid); - } - - public boolean hasUuid() { - return uuid != null; - } - } - - private final static Map> aliases = new HashMap<>(); + private final static Map aliases = new HashMap<>(); private final static Map properties = new HashMap<>(); public final TestReport testReport = new TestReport(aliases); @@ -116,11 +103,9 @@ public abstract class ScenarioTest extends ContextBasedTest { context.define("superuser-alex@hostsharing.net"); putAlias( "Person: Hostsharing eG", - new Alias<>( - personRepo.findPersonByOptionalNameLike("Hostsharing eG") - .stream() + personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream() .map(HsOfficePersonRbacEntity::getUuid) - .reduce(Reducer::toSingleElement).orElseThrow()) + .reduce(Reducer::toSingleElement).orElseThrow() ); } ); @@ -212,7 +197,7 @@ public abstract class ScenarioTest extends ContextBasedTest { return alias; } - static void putAlias(final String name, final Alias value) { + static void putAlias(final String name, final UUID value) { aliases.put(name, value); } @@ -226,7 +211,7 @@ public abstract class ScenarioTest extends ContextBasedTest { static Map knowVariables() { final var map = new LinkedHashMap(); - ScenarioTest.aliases.forEach((key, value) -> map.put(key, value.uuid())); + map.putAll(ScenarioTest.aliases); map.putAll(ScenarioTest.properties); return map; } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java index d4c11c36..a3199da6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.SneakyThrows; import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration; -import net.hostsharing.hsadminng.hs.scenarios.ScenarioTest.Alias; import net.hostsharing.hsadminng.system.SystemProcess; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Order; @@ -19,6 +18,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Map; +import java.util.UUID; import java.util.regex.Pattern; import static java.lang.String.join; @@ -32,7 +32,7 @@ public class TestReport { private static final File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md"); private static final ObjectMapper objectMapper = JsonObjectMapperConfiguration.build(); - private final Map> aliases; + private final Map aliases; private final PrintWriter markdownLog; // records everything for debugging purposes private File markdownReportFile; private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites @@ -44,7 +44,7 @@ public class TestReport { } @SneakyThrows - public TestReport(final Map> aliases) { + public TestReport(final Map aliases) { this.aliases = aliases; this.markdownLog = new PrintWriter(new FileWriter(markdownLogFile)); } @@ -132,8 +132,8 @@ public class TestReport { final var result = new StringBuilder(); for (String line : lines) { - for (Map.Entry> entry : aliases.entrySet()) { - if (entry.getValue().hasUuid() && line.contains(entry.getValue().toString())) { + for (Map.Entry entry : aliases.entrySet()) { + if ( entry.getValue() != null && line.contains(entry.getValue().toString())) { line = line + " // " + entry.getKey(); break; // only add comment for one UUID per row (in our case, there is only one per row) } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java index 095fe8b5..f8b1da80 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java @@ -304,16 +304,12 @@ public abstract class UseCase> { assertThat(alias).as("cannot keep result, no alias found").isNotNull(); final var value = extractor.apply(this); - ScenarioTest.putAlias( - alias, - new ScenarioTest.Alias<>(UUID.fromString(value))); + ScenarioTest.putAlias(alias, UUID.fromString(value)); return this; } public HttpResponse keepAs(final String alias) { - ScenarioTest.putAlias( - nonNullAlias(alias), - new ScenarioTest.Alias<>(locationUuid)); + ScenarioTest.putAlias(nonNullAlias(alias), locationUuid); return this; }