Search in sources :

Example 1 with MessageStats

use of com.axibase.tsd.api.model.message.MessageStats in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testTagsExpressionNoData.

@Issue("6460")
@Test(description = "Tests that messages are not found for expression that does not match any field.")
public void testTagsExpressionNoData() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY).setTagExpression("false");
    Response response = queryMessageStats(statsQuery);
    List<MessageStats> messageStatsList = response.readEntity(ResponseAsList.ofMessageStats());
    assertEquals(1, messageStatsList.size());
    MessageStats stats = messageStatsList.get(0);
    assertEquals(stats.getData().size(), 0);
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) MessageStats(com.axibase.tsd.api.model.message.MessageStats) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 2 with MessageStats

use of com.axibase.tsd.api.model.message.MessageStats in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testTagsExpressionSelection.

@Issue("6460")
@Test(description = "Tests that messages are found for matching tagExpression field.")
public void testTagsExpressionSelection() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY).setTagExpression("tags.key='value'");
    Response response = queryMessageStats(statsQuery);
    List<MessageStats> messageStatsList = response.readEntity(ResponseAsList.ofMessageStats());
    assertEquals(1, messageStatsList.size());
    MessageStats stats = messageStatsList.get(0);
    BigDecimal value = stats.getData().get(0).getValue();
    // dates count and messages count are equal
    assertEquals(value, BigDecimal.valueOf(DATES.size()));
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) MessageStats(com.axibase.tsd.api.model.message.MessageStats) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 3 with MessageStats

use of com.axibase.tsd.api.model.message.MessageStats in project atsd-api-test by axibase.

the class MessageQueryStatsTest method testTagsExpressionError.

@Issue("6460")
@Test(description = "Tests that warning is returned if executing query with invalid expression. Error in \"lke\"")
public void testTagsExpressionError() {
    MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY).setTagExpression("type lke 'something'");
    Response response = queryMessageStats(statsQuery);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    List<MessageStats> messageStatsList = response.readEntity(ResponseAsList.ofMessageStats());
    assertEquals(1, messageStatsList.size());
    String warning = messageStatsList.get(0).getWarning();
    assertEquals(warning, "IllegalStateException: Syntax error at line 1 position 5: no viable alternative at input 'type lke'");
}
Also used : MessageStatsQuery(com.axibase.tsd.api.model.message.MessageStatsQuery) Response(javax.ws.rs.core.Response) MessageStats(com.axibase.tsd.api.model.message.MessageStats) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

MessageStats (com.axibase.tsd.api.model.message.MessageStats)3 MessageStatsQuery (com.axibase.tsd.api.model.message.MessageStatsQuery)3 Issue (io.qameta.allure.Issue)3 Response (javax.ws.rs.core.Response)3 Test (org.testng.annotations.Test)3 BigDecimal (java.math.BigDecimal)1