Compare commits
3 Commits
3fd2b6f693
...
31f5bcc5d8
Author | SHA1 | Date | |
---|---|---|---|
|
31f5bcc5d8 | ||
|
6b30d0f6f9 | ||
|
77cf97ded9 |
@ -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("partnerPersonUuid", "%{Person: Test AG}")
|
.given("partnerPersonTradeName", "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 debugLog = new StringBuilder(); // records everything for debugging purposes
|
private final StringBuilder markdownLog = new StringBuilder(); // records everything for debugging purposes
|
||||||
|
|
||||||
private PrintWriter markdownFile;
|
private PrintWriter markdownReport;
|
||||||
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();
|
||||||
markdownFile = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
|
markdownReport = 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.replace("+", "\\+"));
|
final var outputWithCommentsForUuids = appendUUIDKey(output);
|
||||||
|
|
||||||
// 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 (silent == 0) {
|
if (markdownReport != null && silent == 0) {
|
||||||
markdownFile.print(outputWithCommentsForUuids);
|
markdownReport.print(outputWithCommentsForUuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
// but the debugLog should contain all output, even if silent
|
// but the debugLog should contain all output, even if silent
|
||||||
debugLog.append(outputWithCommentsForUuids);
|
markdownLog.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() {
|
||||||
markdownFile.close();
|
markdownReport.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 + "=> status: " + status + " " +
|
// the response
|
||||||
testReport.printLine(locationUuid != null ? locationUuid.toString() : "");
|
testReport.printLine("=> status: " + status + " " + (locationUuid != null ? locationUuid : ""));
|
||||||
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,6 +7,7 @@ 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> {
|
||||||
|
|
||||||
@ -16,6 +17,13 @@ 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("""
|
||||||
{
|
{
|
||||||
@ -49,7 +57,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": ${partnerPersonUuid},
|
"anchorUuid": ${Person: %{partnerPersonTradeName}},
|
||||||
"holderUuid": ${Person: %{representativeGivenName} %{representativeFamilyName}},
|
"holderUuid": ${Person: %{representativeGivenName} %{representativeFamilyName}},
|
||||||
"contactUuid": ${Contact: %{representativeGivenName} %{representativeFamilyName}}
|
"contactUuid": ${Contact: %{representativeGivenName} %{representativeFamilyName}}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ 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) {
|
||||||
@ -18,6 +21,12 @@ 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