avoid string concatenation in RestAssured API usage
This commit is contained in:
parent
9aa86a1652
commit
4616bb133d
@ -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)
|
||||||
@ -113,22 +116,23 @@ class PackageControllerAcceptanceTest {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
RestAssured
|
RestAssured
|
||||||
.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")
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"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)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.body("name", is("aaa01"))
|
.body("name", is("aaa01"))
|
||||||
.body("description", equalTo(null));
|
.body("description", equalTo(null));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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")
|
||||||
@ -175,14 +181,16 @@ class PackageControllerAcceptanceTest {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
return RestAssured
|
return RestAssured
|
||||||
.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")
|
||||||
.extract().path("[0].description");
|
.extract().path("[0].description");
|
||||||
// @formatter:om
|
// @formatter:om
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user