use of com.axibase.tsd.api.model.alert.Alert 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)));
}
use of com.axibase.tsd.api.model.alert.Alert in project atsd-api-test by axibase.
the class AlertQueryAcknowledgedTest method testAcknowledgedFilterTrue.
@Issue("2976")
@Test
public void testAcknowledgedFilterTrue() {
Map<String, Object> alertQuery = new HashMap<>();
alertQuery.put("entities", Arrays.asList(ENTITY_NAME, ENTITY_NAME_ACK));
alertQuery.put("startDate", MIN_QUERYABLE_DATE);
alertQuery.put("endDate", MAX_QUERYABLE_DATE);
alertQuery.put("acknowledged", true);
List<Alert> alertList = queryAlerts(alertQuery).readEntity(ResponseAsList.ofAlerts());
for (Alert alert : alertList) {
assertTrue("Response should not contain acknowledged=false alerts", alert.getAcknowledged());
}
}
use of com.axibase.tsd.api.model.alert.Alert in project atsd-api-test by axibase.
the class AlertQueryAcknowledgedTest method testAcknowledgedFilterFalse.
@Issue("2976")
@Test
public void testAcknowledgedFilterFalse() {
Map<String, Object> alertQuery = new HashMap<>();
alertQuery.put("entities", Arrays.asList(ENTITY_NAME, ENTITY_NAME_ACK));
alertQuery.put("startDate", MIN_QUERYABLE_DATE);
alertQuery.put("endDate", MAX_QUERYABLE_DATE);
alertQuery.put("acknowledged", false);
List<Alert> alertList = queryAlerts(alertQuery).readEntity(ResponseAsList.ofAlerts());
for (Alert alert : alertList) {
assertFalse("Response should not contain acknowledged=true alerts", alert.getAcknowledged());
}
}
Aggregations