avoid string concatenation in RestAssured API usage

This commit is contained in:
Michael Hoennig 2022-08-11 12:36:30 +02:00
parent 9aa86a1652
commit 4616bb133d

View File

@ -38,8 +38,9 @@ class PackageControllerAcceptanceTest {
.given() .given()
.header("current-user", "mike@hostsharing.net") .header("current-user", "mike@hostsharing.net")
.header("assumed-roles", "customer#aaa.admin") .header("assumed-roles", "customer#aaa.admin")
.port(port)
.when() .when()
.get("http://localhost:" + port + "/api/packages") .get("http://localhost/api/packages")
.then().assertThat() .then().assertThat()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")
@ -59,8 +60,9 @@ class PackageControllerAcceptanceTest {
.given() .given()
.header("current-user", "mike@hostsharing.net") .header("current-user", "mike@hostsharing.net")
.header("assumed-roles", "customer#aaa.admin") .header("assumed-roles", "customer#aaa.admin")
.port(port)
.when() .when()
.get("http://localhost:" + port + "/api/packages?name=aaa01") .get("http://localhost/api/packages?name=aaa01")
.then().assertThat() .then().assertThat()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")
@ -92,8 +94,9 @@ class PackageControllerAcceptanceTest {
"description": "%s" "description": "%s"
} }
""", randomDescription)) """, randomDescription))
.port(port)
.when() .when()
.patch("http://localhost:" + port + "/api/packages/" + getUuidOfPackage("aaa00")) .patch("http://localhost/api/packages/{uuidOfPackage}", getUuidOfPackage("aaa00"))
.then() .then()
.assertThat() .assertThat()
.statusCode(200) .statusCode(200)
@ -121,8 +124,9 @@ class PackageControllerAcceptanceTest {
"description": null "description": null
} }
""") """)
.port(port)
.when() .when()
.patch("http://localhost:" + port + "/api/packages/" + getUuidOfPackage("aaa01")) .patch("http://localhost/api/packages/{uuidOfPackage}", getUuidOfPackage("aaa01"))
.then() .then()
.assertThat() .assertThat()
.statusCode(200) .statusCode(200)
@ -145,8 +149,9 @@ class PackageControllerAcceptanceTest {
.header("assumed-roles", "customer#aaa.admin") .header("assumed-roles", "customer#aaa.admin")
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("{}") .body("{}")
.port(port)
.when() .when()
.patch("http://localhost:" + port + "/api/packages/" + getUuidOfPackage("aaa02")) .patch("http://localhost/api/packages/{uuidOfPackage}", getUuidOfPackage("aaa02"))
.then().assertThat() .then().assertThat()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")
@ -162,8 +167,9 @@ class PackageControllerAcceptanceTest {
.given() .given()
.header("current-user", "mike@hostsharing.net") .header("current-user", "mike@hostsharing.net")
.header("assumed-roles", "customer#aaa.admin") .header("assumed-roles", "customer#aaa.admin")
.port(port)
.when() .when()
.get("http://localhost:" + port + "/api/packages?name=" + packageName) .get("http://localhost/api/packages?name={packageName}", packageName)
.then() .then()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")
@ -177,8 +183,10 @@ class PackageControllerAcceptanceTest {
.given() .given()
.header("current-user", "mike@hostsharing.net") .header("current-user", "mike@hostsharing.net")
.header("assumed-roles", "customer#aaa.admin") .header("assumed-roles", "customer#aaa.admin")
.accept("application/json") //
.port(port)
.when() .when()
.get("http://localhost:" + port + "/api/packages?name=" + packageName) .get("http://localhost/api/packages?name={packageName}", packageName)
.then() .then()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")