use fetchRealBookingItemFromURI wherever sensible and improve formatting

This commit is contained in:
Michael Hoennig 2024-09-27 11:00:33 +02:00
parent 4c0b4a2c1e
commit 8dc388fa5a

View File

@ -182,9 +182,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on
// finally, the new bookingItem can be accessed under the generated UUID // finally, the new bookingItem can be accessed under the generated UUID
final var newSubjectUuid = UUID.fromString( assertThat(fetchRealBookingItemFromURI(location)).isNotNull();
location.substring(location.lastIndexOf('/') + 1));
assertThat(newSubjectUuid).isNotNull();
} }
@Test @Test
@ -220,24 +218,24 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
) )
.port(port) .port(port)
.when() .when()
.post("http://localhost/api/hs/booking/items") .post("http://localhost/api/hs/booking/items")
.then().log().all().assertThat() .then().log().all().assertThat()
.statusCode(201) .statusCode(201)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"type": "DOMAIN_SETUP", "type": "DOMAIN_SETUP",
"caption": "some new domain-setup booking", "caption": "some new domain-setup booking",
"validFrom": "{today}", "validFrom": "{today}",
"validTo": null, "validTo": null,
"resources": { "domainName": "example.org", "targetUnixUser": "fir01-web" } "resources": { "domainName": "example.org", "targetUnixUser": "fir01-web" }
} }
""" """
.replace("{today}", LocalDate.now().toString()) .replace("{today}", LocalDate.now().toString())
.replace("{todayPlus1Month}", LocalDate.now().plusMonths(1).toString())) .replace("{todayPlus1Month}", LocalDate.now().plusMonths(1).toString()))
) )
.header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/booking/items/[^/]*")) .header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/booking/items/[^/]*"))
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on
// then, the new BookingItem can be accessed under the generated UUID // then, the new BookingItem can be accessed under the generated UUID
final var newBookingItem = fetchRealBookingItemFromURI(location); final var newBookingItem = fetchRealBookingItemFromURI(location);