From 8dc388fa5a7ca313c7900e526f8a420a94c0a085 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 27 Sep 2024 11:00:33 +0200 Subject: [PATCH] use fetchRealBookingItemFromURI wherever sensible and improve formatting --- ...HsBookingItemControllerAcceptanceTest.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index 91ee81a9..cf43f8cb 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -182,9 +182,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup .extract().header("Location"); // @formatter:on // finally, the new bookingItem can be accessed under the generated UUID - final var newSubjectUuid = UUID.fromString( - location.substring(location.lastIndexOf('/') + 1)); - assertThat(newSubjectUuid).isNotNull(); + assertThat(fetchRealBookingItemFromURI(location)).isNotNull(); } @Test @@ -220,24 +218,24 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup ) .port(port) .when() - .post("http://localhost/api/hs/booking/items") + .post("http://localhost/api/hs/booking/items") .then().log().all().assertThat() - .statusCode(201) - .contentType(ContentType.JSON) - .body("", lenientlyEquals(""" - { - "type": "DOMAIN_SETUP", - "caption": "some new domain-setup booking", - "validFrom": "{today}", - "validTo": null, - "resources": { "domainName": "example.org", "targetUnixUser": "fir01-web" } - } - """ - .replace("{today}", LocalDate.now().toString()) - .replace("{todayPlus1Month}", LocalDate.now().plusMonths(1).toString())) - ) - .header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/booking/items/[^/]*")) - .extract().header("Location"); // @formatter:on + .statusCode(201) + .contentType(ContentType.JSON) + .body("", lenientlyEquals(""" + { + "type": "DOMAIN_SETUP", + "caption": "some new domain-setup booking", + "validFrom": "{today}", + "validTo": null, + "resources": { "domainName": "example.org", "targetUnixUser": "fir01-web" } + } + """ + .replace("{today}", LocalDate.now().toString()) + .replace("{todayPlus1Month}", LocalDate.now().plusMonths(1).toString())) + ) + .header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/booking/items/[^/]*")) + .extract().header("Location"); // @formatter:on // then, the new BookingItem can be accessed under the generated UUID final var newBookingItem = fetchRealBookingItemFromURI(location);