@Test
public void testNewFullDefinition() throws Exception {
int definitionId = 0;
try {
AlertDefinition alertDefinition = new AlertDefinition();
alertDefinition.setName("-x-test-full-definition");
alertDefinition.setEnabled(false);
alertDefinition.setPriority("HIGH");
AlertNotification notification = new AlertNotification("Direct Emails");
notification.getConfig().put("emailAddress","enoch@root.org");
alertDefinition.getNotifications().add(notification);
AlertCondition condition = new AlertCondition("AVAILABILITY", "AVAIL_GOES_DOWN");
alertDefinition.getConditions().add(condition);
AlertDefinition result =
given()
.contentType(ContentType.JSON)
.header(acceptJson)
.body(alertDefinition)
.log().everything()
.queryParam("resourceId", _platformId)
.expect()
.statusCode(201)
.log().ifError()
.when()
.post("/alert/definitions")
.as(AlertDefinition.class);
assert result != null;
definitionId = result.getId();
assert result.getConditions().size()==1;
assert result.getNotifications().size()==1;
// Now retrieve the condition and notification individually
given()
.header(acceptJson)
.pathParam("id",result.getNotifications().get(0).getId())
.expect()
.statusCode(200)
.body("id",is(result.getNotifications().get(0).getId()))
.body("senderName",is(result.getNotifications().get(0).getSenderName()))
.log().ifError()
.when()
.get("/alert/notification/{id}");
given()
.header(acceptJson)
.pathParam("id",result.getConditions().get(0).getId())
.expect()
.statusCode(200)
.body("id",is(result.getConditions().get(0).getId()))
.body("name",is(result.getConditions().get(0).getName()))
.log().ifError()
.when()
.get("/alert/condition/{id}");