Search in sources :

Example 1 with AlertQuery

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

Example 2 with AlertQuery

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

Example 3 with AlertQuery

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)));
}
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)

Aggregations

AlertTest (com.axibase.tsd.api.method.alert.AlertTest)3 Alert (com.axibase.tsd.api.model.alert.Alert)3 AlertQuery (com.axibase.tsd.api.model.alert.AlertQuery)3 Issue (io.qameta.allure.Issue)3 Test (org.testng.annotations.Test)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 AlertUpdateQuery (com.axibase.tsd.api.model.alert.AlertUpdateQuery)1