// CREATE
Policy policy = new Policy();
policy.setId(id);
Context context = new Context();
context.setId("anid");
context.setStatus(Status.ACTIVE);
policy.getContexts().add(context);
BasicResponse response = given()
.contentType("application/xml")
.body(policy, ObjectMapper.JAXB)
.expect()
.statusCode(200)
.rootPath("response")
.body("status", equalTo("SUCCESS"))
.log().ifError()
.when()
.post("")
.andReturn()
.as(BasicResponse.class, ObjectMapper.JAXB);
assertNotNull(response);
assertEquals("SUCCESS", response.getStatus());
if (id != null)
{
assertEquals(id, response.getId());
}
else
{
assertNotNull(response.getId());
id = response.getId();
}
// UPDATE
context = new Context();
context.setId("anotherid");
context.setStatus(Status.ACTIVE);
policy.getContexts().add(context);
response = given()
.contentType("application/xml")
.body(policy, ObjectMapper.JAXB)