extract feaure for obtain
This commit is contained in:
parent
1623e72534
commit
2971f4196d
@ -90,7 +90,9 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
|
|||||||
}
|
}
|
||||||
"""))
|
"""))
|
||||||
.expecting(CREATED).expecting(JSON)
|
.expecting(CREATED).expecting(JSON)
|
||||||
);
|
)
|
||||||
|
.extract("contact.uuid", "Contact: Erbengemeinschaft %{nameOfDeceasedPerson}")
|
||||||
|
.extract("holder.uuid", "Person: Erbengemeinschaft %{nameOfDeceasedPerson}");
|
||||||
|
|
||||||
// Repräsentanten Relation zur Erbengemeinschaft für die zuvor erzeugte Person zur Erbengemeinschaft anlegen
|
// Repräsentanten Relation zur Erbengemeinschaft für die zuvor erzeugte Person zur Erbengemeinschaft anlegen
|
||||||
|
|
||||||
@ -108,17 +110,17 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
|
|||||||
// "If there are more than one, each needs their own contact"
|
// "If there are more than one, each needs their own contact"
|
||||||
// );
|
// );
|
||||||
|
|
||||||
obtain("Representative-Relation: %{subscriberGivenName} %{subscriberFamilyName} for Erbengemeinschaft %{nameOfDeceasedPerson}", () ->
|
obtain("Representative-Relation: %{representativeGivenName} %{representativeFamilyName} for Erbengemeinschaft %{nameOfDeceasedPerson}", () ->
|
||||||
httpPost("/api/hs/office/relations", usingJsonBody("""
|
httpPost("/api/hs/office/relations", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"type": "REPRESENTATIVE",
|
"type": "REPRESENTATIVE",
|
||||||
"anchor.uuid": ${Person: %{partnerPersonTradeName}},
|
"anchor.uuid": ${Person: Erbengemeinschaft %{nameOfDeceasedPerson}},
|
||||||
"holder.uuid": {
|
"holder": {
|
||||||
"personType": "NATURAL_PERSON",
|
"personType": "NATURAL_PERSON",
|
||||||
"givenName": ${representativeGivenName},
|
"givenName": ${representativeGivenName},
|
||||||
"familyName": ${representativeFamilyName}
|
"familyName": ${representativeFamilyName}
|
||||||
},
|
},
|
||||||
"contact.uuid": ${Contact: %{subscriberGivenName} %{subscriberFamilyName}}
|
"contact.uuid": ${Contact: Erbengemeinschaft %{nameOfDeceasedPerson}}
|
||||||
}
|
}
|
||||||
"""))
|
"""))
|
||||||
.expecting(CREATED).expecting(JSON),
|
.expecting(CREATED).expecting(JSON),
|
||||||
@ -137,12 +139,10 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
|
|||||||
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
|
||||||
);
|
);
|
||||||
|
|
||||||
// httpGet("/api/hs/office/debitors/%{partnerNumber}") FIXME
|
|
||||||
|
|
||||||
obtain("Partner: Erbengemeinschaft %{nameOfDeceasedPerson}", () ->
|
obtain("Partner: Erbengemeinschaft %{nameOfDeceasedPerson}", () ->
|
||||||
httpPatch("/api/hs/office/partners/%{Partner: %{partnerNumber}}", usingJsonBody("""
|
httpPatch("/api/hs/office/partners/%{Partner: %{partnerNumber}}", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"partnerRel": ${Partner-Relation: Erbengemeinschaft %{nameOfDeceasedPerson}}
|
"partnerRel.uuid": ${Partner-Relation: Erbengemeinschaft %{nameOfDeceasedPerson}}
|
||||||
}
|
}
|
||||||
"""))
|
"""))
|
||||||
.expecting(HttpStatus.OK)
|
.expecting(HttpStatus.OK)
|
||||||
|
@ -50,13 +50,16 @@ public abstract class ScenarioTest extends ContextBasedTest {
|
|||||||
return Optional.of(currentTestMethodProduces.pop());
|
return Optional.of(currentTestMethodProduces.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
record Alias<T extends UseCase<T>>(Class<T> useCase, UUID uuid) {
|
public record Alias<T extends UseCase<T>>(Class<T> useCase, UUID uuid) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Objects.toString(uuid);
|
return Objects.toString(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasUuid() {
|
||||||
|
return uuid != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Map<String, Alias<?>> aliases = new HashMap<>();
|
private final static Map<String, Alias<?>> aliases = new HashMap<>();
|
||||||
@ -111,7 +114,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
|
|||||||
jpaAttempt.transacted(() ->
|
jpaAttempt.transacted(() ->
|
||||||
{
|
{
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
aliases.put(
|
putAlias(
|
||||||
"Person: Hostsharing eG",
|
"Person: Hostsharing eG",
|
||||||
new Alias<>(
|
new Alias<>(
|
||||||
null,
|
null,
|
||||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration;
|
||||||
|
import net.hostsharing.hsadminng.hs.scenarios.ScenarioTest.Alias;
|
||||||
import net.hostsharing.hsadminng.system.SystemProcess;
|
import net.hostsharing.hsadminng.system.SystemProcess;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
@ -31,7 +32,7 @@ public class TestReport {
|
|||||||
private static final File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md");
|
private static final File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md");
|
||||||
private static final ObjectMapper objectMapper = JsonObjectMapperConfiguration.build();
|
private static final ObjectMapper objectMapper = JsonObjectMapperConfiguration.build();
|
||||||
|
|
||||||
private final Map<String, ?> aliases;
|
private final Map<String, Alias<?>> aliases;
|
||||||
private final PrintWriter markdownLog; // records everything for debugging purposes
|
private final PrintWriter markdownLog; // records everything for debugging purposes
|
||||||
private File markdownReportFile;
|
private File markdownReportFile;
|
||||||
private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites
|
private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites
|
||||||
@ -43,7 +44,7 @@ public class TestReport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public TestReport(final Map<String, ?> aliases) {
|
public TestReport(final Map<String, Alias<?>> aliases) {
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
this.markdownLog = new PrintWriter(new FileWriter(markdownLogFile));
|
this.markdownLog = new PrintWriter(new FileWriter(markdownLogFile));
|
||||||
}
|
}
|
||||||
@ -131,9 +132,8 @@ public class TestReport {
|
|||||||
final var result = new StringBuilder();
|
final var result = new StringBuilder();
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
for (Map.Entry<String, ?> entry : aliases.entrySet()) {
|
for (Map.Entry<String, Alias<?>> entry : aliases.entrySet()) {
|
||||||
final var uuidString = entry.getValue().toString();
|
if (entry.getValue().hasUuid() && line.contains(entry.getValue().toString())) {
|
||||||
if (line.contains(uuidString)) {
|
|
||||||
line = line + " // " + entry.getKey();
|
line = line + " // " + entry.getKey();
|
||||||
break; // only add comment for one UUID per row (in our case, there is only one per row)
|
break; // only add comment for one UUID per row (in our case, there is only one per row)
|
||||||
}
|
}
|
||||||
|
@ -134,8 +134,8 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void obtain(final String alias, final Supplier<HttpResponse> http, final String... extraInfo) {
|
public final HttpResponse obtain(final String alias, final Supplier<HttpResponse> http, final String... extraInfo) {
|
||||||
withTitle(alias, () -> {
|
return withTitle(alias, () -> {
|
||||||
final var response = http.get().keep();
|
final var response = http.get().keep();
|
||||||
Arrays.stream(extraInfo).forEach(testReport::printPara);
|
Arrays.stream(extraInfo).forEach(testReport::printPara);
|
||||||
return response;
|
return response;
|
||||||
@ -396,6 +396,13 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
final var onlyVisibleInGeneratedMarkdownNotInSource = new String(new char[]{'F', 'I', 'X', 'M', 'E'});
|
final var onlyVisibleInGeneratedMarkdownNotInSource = new String(new char[]{'F', 'I', 'X', 'M', 'E'});
|
||||||
return alias == null ? "unknown alias -- " + onlyVisibleInGeneratedMarkdownNotInSource : alias;
|
return alias == null ? "unknown alias -- " + onlyVisibleInGeneratedMarkdownNotInSource : alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HttpResponse extract(final String jsonPath, final String resolvableName) {
|
||||||
|
final var resolvedName = ScenarioTest.resolve(resolvableName, DROP_COMMENTS);
|
||||||
|
final var resolvedJsonPath = getFromBodyAsOptional(jsonPath).givenAsString();
|
||||||
|
ScenarioTest.putProperty(resolvedName, resolvedJsonPath);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected T self() {
|
protected T self() {
|
||||||
|
Loading…
Reference in New Issue
Block a user