remove Alias wrapper class
This commit is contained in:
parent
9fa5bd96d6
commit
921893a350
@ -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<T extends UseCase<T>>(UUID uuid) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toString(uuid);
|
||||
}
|
||||
|
||||
public boolean hasUuid() {
|
||||
return uuid != null;
|
||||
}
|
||||
}
|
||||
|
||||
private final static Map<String, Alias<?>> aliases = new HashMap<>();
|
||||
private final static Map<String, UUID> aliases = new HashMap<>();
|
||||
|
||||
private final static Map<String, Object> 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<String, Object> knowVariables() {
|
||||
final var map = new LinkedHashMap<String, Object>();
|
||||
ScenarioTest.aliases.forEach((key, value) -> map.put(key, value.uuid()));
|
||||
map.putAll(ScenarioTest.aliases);
|
||||
map.putAll(ScenarioTest.properties);
|
||||
return map;
|
||||
}
|
||||
|
@ -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<String, Alias<?>> aliases;
|
||||
private final Map<String, UUID> 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<String, Alias<?>> aliases) {
|
||||
public TestReport(final Map<String, UUID> 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<String, Alias<?>> entry : aliases.entrySet()) {
|
||||
if (entry.getValue().hasUuid() && line.contains(entry.getValue().toString())) {
|
||||
for (Map.Entry<String, UUID> 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)
|
||||
}
|
||||
|
@ -304,16 +304,12 @@ public abstract class UseCase<T extends 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user