assert discoveryDefinitionId !=-1 : "No discovery operation found";
// Now add a condition
try {
AlertNotification notification = new AlertNotification("Resource Operations"); // short-name from server plugin descriptor
notification.getConfig().put("selection-mode", "SELF");
notification.getConfig().put("operation-definition-id", discoveryDefinitionId);
notification.getExtraConfig().put("detailedDiscovery", false);
given()
.header(acceptJson)
.contentType(ContentType.JSON)
.body(notification)
.pathParam("defId", definitionId)
.log().everything()
.expect()
.statusCode(201)
.log().everything()
.when()
.post("/alert/definition/{defId}/notifications");
// Retrieve the definition with the added condition
AlertDefinition updatedDefinition =
given()
.pathParam("id",definitionId)
.queryParam("full",true)
.expect()
.statusCode(200)
.log().everything()
.when()
.get("/alert/definition/{id}")
.as(AlertDefinition.class);
int size = updatedDefinition.getNotifications().size();
assert size ==1 : "Did not find 1 notification, but " + size;
AlertNotification newNotification = updatedDefinition.getNotifications().get(0);
assert newNotification.getExtraConfig().size() == 1;
assert (Boolean) newNotification.getExtraConfig().get("detailedDiscovery") == false;
}
finally {
// delete the definition again
cleanupDefinition(definitionId);