feature/use-case-acceptance-tests #116

Merged
hsh-michaelhoennig merged 49 commits from feature/use-case-acceptance-tests into master 2024-10-30 11:40:46 +01:00
3 changed files with 16 additions and 5 deletions
Showing only changes of commit bc099ada40 - Show all commits

View File

@ -94,7 +94,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Requires("Operations-Contact: Dennis Krause for Test AG") @Requires("Operations-Contact: Dennis Krause for Test AG")
void shouldRemoveOperationsContactFromPartner() { void shouldRemoveOperationsContactFromPartner() {
new RemoveOperationsContactFromPartner(this) new RemoveOperationsContactFromPartner(this)
.given("operationContactRelationUuid", "%{Operations-Contact: Dennis Krause for Test AG}") .given("operationsContactPerson", "Dennis Krause")
.doRun(); .doRun();
} }

View File

@ -68,6 +68,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
@AfterEach @AfterEach
void cleanup() { // final TestInfo testInfo void cleanup() { // final TestInfo testInfo
properties.clear(); properties.clear();
// FIXME: Delete all aliases as well to force HTTP GET queries in each scenario?
testReport.close(); testReport.close();
} }
@ -137,9 +138,10 @@ public abstract class ScenarioTest extends ContextBasedTest {
return aliases.containsKey(alias); return aliases.containsKey(alias);
} }
static UUID uuid(final String name) { static UUID uuid(final String nameWithPlaceholders) {
final UUID alias = ofNullable(knowVariables().get(name)).filter(v -> v instanceof UUID).map(UUID.class::cast).orElse(null); final var resoledName = resolve(nameWithPlaceholders);
assertThat(alias).as("alias '" + name + "' not found in aliases nor in properties [" + final UUID alias = ofNullable(knowVariables().get(resoledName)).filter(v -> v instanceof UUID).map(UUID.class::cast).orElse(null);
assertThat(alias).as("alias '" + resoledName + "' not found in aliases nor in properties [" +
knowVariables().keySet().stream().map(v -> "'" + v + "'").collect(Collectors.joining(", ")) + "]" knowVariables().keySet().stream().map(v -> "'" + v + "'").collect(Collectors.joining(", ")) + "]"
).isNotNull(); ).isNotNull();
return alias; return alias;

View File

@ -3,7 +3,9 @@ package net.hostsharing.hsadminng.hs.office.scenarios.subscription;
import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; 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 static io.restassured.http.ContentType.JSON;
import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.http.HttpStatus.OK;
public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperationsContactFromPartner> { public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperationsContactFromPartner> {
@ -14,7 +16,14 @@ public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperations
@Override @Override
protected HttpResponse run() { protected HttpResponse run() {
return httpDelete("/api/hs/office/relations/" + uuid("operationContactRelationUuid")) keep("Operations-Contact: %{operationsContactPerson}", () ->
httpGet("/api/hs/office/relations?relationType=OPERATIONS&name=" + uriEncoded("%{operationsContactPerson}"))
.expecting(OK).expecting(JSON),
response -> response.expectArrayElements(1).getFromBody("[0].uuid"),
"In production data this query could result in multiple outputs. In that case, you have to find out which is the right one."
);
return httpDelete("/api/hs/office/relations/" + uuid("Operations-Contact: %{operationsContactPerson}"))
.expecting(NO_CONTENT); .expecting(NO_CONTENT);
} }
} }