Search in sources :

Example 1 with AlertUpdateQuery

use of com.axibase.tsd.api.model.alert.AlertUpdateQuery 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)

Aggregations

AlertTest (com.axibase.tsd.api.method.alert.AlertTest)1 Alert (com.axibase.tsd.api.model.alert.Alert)1 AlertQuery (com.axibase.tsd.api.model.alert.AlertQuery)1 AlertUpdateQuery (com.axibase.tsd.api.model.alert.AlertUpdateQuery)1 Issue (io.qameta.allure.Issue)1 Response (javax.ws.rs.core.Response)1 Test (org.testng.annotations.Test)1