Search in sources :

Example 6 with Alert

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)));
}
Also used : Response(javax.ws.rs.core.Response) AlertQuery(com.axibase.tsd.api.model.alert.AlertQuery) Alert(com.axibase.tsd.api.model.alert.Alert) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) AlertTest(com.axibase.tsd.api.method.alert.AlertTest)

Example 7 with Alert

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());
    }
}
Also used : Alert(com.axibase.tsd.api.model.alert.Alert) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 8 with Alert

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());
    }
}
Also used : Alert(com.axibase.tsd.api.model.alert.Alert) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

Alert (com.axibase.tsd.api.model.alert.Alert)8 Issue (io.qameta.allure.Issue)6 Test (org.testng.annotations.Test)6 AlertTest (com.axibase.tsd.api.method.alert.AlertTest)3 AlertQuery (com.axibase.tsd.api.model.alert.AlertQuery)3 Response (javax.ws.rs.core.Response)2 AlertCheck (com.axibase.tsd.api.method.checks.AlertCheck)1 DeletionCheck (com.axibase.tsd.api.method.checks.DeletionCheck)1 AlertDeleteQuery (com.axibase.tsd.api.model.alert.AlertDeleteQuery)1 AlertHistoryQuery (com.axibase.tsd.api.model.alert.AlertHistoryQuery)1 AlertUpdateQuery (com.axibase.tsd.api.model.alert.AlertUpdateQuery)1