}
@Test
public void testCreateGroupTwice() throws Exception {
Group group = new Group(X_TEST_GROUP);
// create the group
Response created =
given()
.header(acceptJson)
.contentType(ContentType.JSON)
.body(group)
.expect()
.statusCode(HttpStatus.SC_CREATED)
.log().ifError()
.when()
.post("/group");
// Determine location from response
// and compare id with the found group below
String location = created.header("Location");
int createdId = Integer.parseInt(location.substring(location.lastIndexOf("/")+1));
try {
Group group2 =
given()
.header(acceptJson)
.contentType(ContentType.JSON)
.body(group)
.expect()
.statusCode(200)
.log().ifError()
.when()
.post("/group")
.as(Group.class);
assert group2 != null;
assert group2.getName().equals(group.getName());
assert group2.getId() == createdId;
}
finally {
// delete the group again
given()