use of com.axibase.tsd.api.model.alert.AlertQuery in project atsd-api-test by axibase.
the class TokenAlertTest method testUpdateMethod.
@Test(description = "Tests alert update endpoint with tokens.")
@Issue("6052")
public void testUpdateMethod() throws Exception {
String url = "/alerts/update";
String token = TokenRepository.getToken(username, HttpMethod.POST, url);
String entity = Mocks.entity();
generateAlertForEntity(entity);
AlertQuery query = new AlertQuery().setStartDate(Util.MIN_QUERYABLE_DATE).setEndDate(Util.MAX_QUERYABLE_DATE).setMetrics(Collections.singletonList(RULE_METRIC_NAME)).setEntity(entity);
Alert alert = queryAlerts(query).readEntity(ResponseAsList.ofAlerts()).get(0);
// changing data in retrieved alert
alert.setAcknowledged(!alert.getAcknowledged());
AlertUpdateQuery updateQuery = new AlertUpdateQuery(alert.getId(), alert.getAcknowledged());
updateAlerts(Collections.singletonList(updateQuery), token);
Response response = queryAlerts(query);
assertTrue(compareJsonString(Util.prettyPrint(Collections.singletonList(alert)), response.readEntity(String.class)));
}
use of com.axibase.tsd.api.model.alert.AlertQuery in project atsd-api-test by axibase.
the class TokenAlertTest method testDeleteMethod.
@Test(description = "Tests alert update endpoint with tokens.")
@Issue("6052")
public void testDeleteMethod() throws Exception {
String url = "/alerts/delete";
String token = TokenRepository.getToken(username, HttpMethod.POST, url);
String entity = Mocks.entity();
generateAlertForEntity(entity);
AlertQuery query = new AlertQuery().setStartDate(Util.MIN_QUERYABLE_DATE).setEndDate(Util.MAX_QUERYABLE_DATE).setMetrics(Collections.singletonList(RULE_METRIC_NAME)).setEntity(entity);
Alert alert = queryAlerts(query).readEntity(ResponseAsList.ofAlerts()).get(0);
deleteAlerts(Collections.singletonList(new AlertDeleteQuery(alert.getId())), token);
Checker.check(new DeletionCheck(new AlertCheck(query)));
}
use of com.axibase.tsd.api.model.alert.AlertQuery in project atsd-api-test by axibase.
the class TokenAlertTest method testQueryMethod.
@Test(description = "Tests alert query endpoint with tokens. It first generates alert and retrieves it with basic authorization to then compare it to the alert retrieved by bearer authorization")
@Issue("6052")
public void testQueryMethod() throws Exception {
String url = "/alerts/query";
String token = TokenRepository.getToken(username, HttpMethod.POST, url);
String entity = Mocks.entity();
generateAlertForEntity(entity);
AlertQuery query = new AlertQuery().setStartDate(Util.MIN_QUERYABLE_DATE).setEndDate(Util.MAX_QUERYABLE_DATE).setMetrics(Collections.singletonList(RULE_METRIC_NAME)).setEntity(entity);
// taking alert by basic authorization to be compared
Alert alert = queryAlerts(query).readEntity(ResponseAsList.ofAlerts()).get(0);
Response response = queryAlerts(Collections.singletonList(query), token);
assertTrue(compareJsonString(Util.prettyPrint(Collections.singletonList(alert)), response.readEntity(String.class)));
}
Aggregations