Compare commits
No commits in common. "31f5bcc5d8005e72cea682d763248c506d4ffb43" and "3fd2b6f69309cd757e9ee482f6ce0b53511ce393" have entirely different histories.
31f5bcc5d8
...
3fd2b6f693
@ -61,7 +61,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
@Produces("Representative: Tracy Trust for Test AG")
|
@Produces("Representative: Tracy Trust for Test AG")
|
||||||
void shouldAddRepresentativeToPartner() {
|
void shouldAddRepresentativeToPartner() {
|
||||||
new AddRepresentativeToPartner(this)
|
new AddRepresentativeToPartner(this)
|
||||||
.given("partnerPersonTradeName", "Test AG")
|
.given("partnerPersonUuid", "%{Person: Test AG}")
|
||||||
.given("representativeFamilyName", "Trust")
|
.given("representativeFamilyName", "Trust")
|
||||||
.given("representativeGivenName", "Tracy")
|
.given("representativeGivenName", "Tracy")
|
||||||
.given("representativePostalAddress", """
|
.given("representativePostalAddress", """
|
||||||
|
@ -16,9 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
public class TestReport {
|
public class TestReport {
|
||||||
|
|
||||||
private final Map<String, ?> aliases;
|
private final Map<String, ?> aliases;
|
||||||
private final StringBuilder markdownLog = new StringBuilder(); // records everything for debugging purposes
|
private final StringBuilder debugLog = new StringBuilder(); // records everything for debugging purposes
|
||||||
|
|
||||||
private PrintWriter markdownReport;
|
private PrintWriter markdownFile;
|
||||||
private int silent; // do not print anything to test-report if >0
|
private int silent; // do not print anything to test-report if >0
|
||||||
|
|
||||||
public TestReport(final Map<String, ?> aliases) {
|
public TestReport(final Map<String, ?> aliases) {
|
||||||
@ -29,22 +29,22 @@ public class TestReport {
|
|||||||
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
|
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
|
||||||
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
|
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
|
||||||
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
|
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
|
||||||
markdownReport = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
|
markdownFile = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
|
||||||
print("## Scenario: " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
|
print("## Scenario: " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void print(final String output) {
|
public void print(final String output) {
|
||||||
|
|
||||||
final var outputWithCommentsForUuids = appendUUIDKey(output);
|
final var outputWithCommentsForUuids = appendUUIDKey(output.replace("+", "\\+"));
|
||||||
|
|
||||||
// for tests executed due to @Requires/@Produces there is no markdownFile yet
|
// for tests executed due to @Requires/@Produces there is no markdownFile yet
|
||||||
if (markdownReport != null && silent == 0) {
|
if (silent == 0) {
|
||||||
markdownReport.print(outputWithCommentsForUuids);
|
markdownFile.print(outputWithCommentsForUuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
// but the debugLog should contain all output, even if silent
|
// but the debugLog should contain all output, even if silent
|
||||||
markdownLog.append(outputWithCommentsForUuids);
|
debugLog.append(outputWithCommentsForUuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printLine(final String output) {
|
public void printLine(final String output) {
|
||||||
@ -56,7 +56,7 @@ public class TestReport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
markdownReport.close();
|
markdownFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String appendUUIDKey(String multilineText) {
|
private String appendUUIDKey(String multilineText) {
|
||||||
|
@ -281,8 +281,8 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
testReport.printLine(httpMethod.name() + " " + uri);
|
testReport.printLine(httpMethod.name() + " " + uri);
|
||||||
testReport.printLine((requestBody != null ? requestBody.trim() : ""));
|
testReport.printLine((requestBody != null ? requestBody.trim() : ""));
|
||||||
|
|
||||||
// the response
|
// the response + "=> status: " + status + " " +
|
||||||
testReport.printLine("=> status: " + status + " " + (locationUuid != null ? locationUuid : ""));
|
testReport.printLine(locationUuid != null ? locationUuid.toString() : "");
|
||||||
if (httpMethod == HttpMethod.GET || status.isError()) {
|
if (httpMethod == HttpMethod.GET || status.isError()) {
|
||||||
final var jsonNode = objectMapper.readTree(response.body());
|
final var jsonNode = objectMapper.readTree(response.body());
|
||||||
final var prettyJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode);
|
final var prettyJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode);
|
||||||
|
@ -7,7 +7,6 @@ import org.springframework.http.HttpStatus;
|
|||||||
|
|
||||||
import static io.restassured.http.ContentType.JSON;
|
import static io.restassured.http.ContentType.JSON;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
|
|
||||||
public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartner> {
|
public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartner> {
|
||||||
|
|
||||||
@ -17,13 +16,6 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
keep("Person: %{partnerPersonTradeName}", () ->
|
|
||||||
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
|
|
||||||
.expecting(OK).expecting(JSON),
|
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].uuid")
|
|
||||||
);
|
|
||||||
|
|
||||||
keep("Person: %{representativeGivenName} %{representativeFamilyName}", () ->
|
keep("Person: %{representativeGivenName} %{representativeFamilyName}", () ->
|
||||||
httpPost("/api/hs/office/persons", usingJsonBody("""
|
httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||||
{
|
{
|
||||||
@ -57,7 +49,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
|
|||||||
return httpPost("/api/hs/office/relations", usingJsonBody("""
|
return httpPost("/api/hs/office/relations", usingJsonBody("""
|
||||||
{
|
{
|
||||||
"type": "REPRESENTATIVE",
|
"type": "REPRESENTATIVE",
|
||||||
"anchorUuid": ${Person: %{partnerPersonTradeName}},
|
"anchorUuid": ${partnerPersonUuid},
|
||||||
"holderUuid": ${Person: %{representativeGivenName} %{representativeFamilyName}},
|
"holderUuid": ${Person: %{representativeGivenName} %{representativeFamilyName}},
|
||||||
"contactUuid": ${Contact: %{representativeGivenName} %{representativeFamilyName}}
|
"contactUuid": ${Contact: %{representativeGivenName} %{representativeFamilyName}}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,6 @@ import net.hostsharing.hsadminng.hs.office.scenarios.UseCase;
|
|||||||
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import static io.restassured.http.ContentType.JSON;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
|
|
||||||
public class CreatePartner extends UseCase<CreatePartner> {
|
public class CreatePartner extends UseCase<CreatePartner> {
|
||||||
|
|
||||||
public CreatePartner(final ScenarioTest testSuite, final String resultAlias) {
|
public CreatePartner(final ScenarioTest testSuite, final String resultAlias) {
|
||||||
@ -21,12 +18,6 @@ public class CreatePartner extends UseCase<CreatePartner> {
|
|||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
keep("Person: Hostsharing eG", () ->
|
|
||||||
httpGet("/api/hs/office/persons?name=Hostsharing+eG")
|
|
||||||
.expecting(OK).expecting(JSON),
|
|
||||||
response -> response.expectArrayElements(1).getFromBody("[0].uuid")
|
|
||||||
);
|
|
||||||
|
|
||||||
keep("Person: %{tradeName}", () ->
|
keep("Person: %{tradeName}", () ->
|
||||||
httpPost("/api/hs/office/persons", usingJsonBody("""
|
httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user