Search in sources :

Example 6 with MessageQuery

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

the class MessageSeverityQueryTest method prepareQuery.

@BeforeMethod
public void prepareQuery() {
    messageQuery = new MessageQuery();
    messageQuery.setEntity(message.getEntity());
    messageQuery.setStartDate(MIN_QUERYABLE_DATE);
    messageQuery.setEndDate(MAX_QUERYABLE_DATE);
}
Also used : MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with MessageQuery

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

the class MessageMethod method messageExist.

public static boolean messageExist(final Message message) throws Exception {
    MessageQuery query = new MessageQuery();
    query.setEntity(message.getEntity());
    query.setType(message.getType());
    if (message.getDate() != null) {
        query.setStartDate(message.getDate());
        query.setEndDate(Util.addOneMS(message.getDate()));
    }
    query.setSeverity(message.getSeverity());
    query.setSource(message.getSource());
    Response response = queryMessageResponse(query);
    if (response.getStatus() != OK.getStatusCode() && response.getStatus() != NOT_FOUND.getStatusCode()) {
        throw new IllegalStateException("Fail to execute queryMessageResponse request: " + response.readEntity(String.class));
    }
    final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(message));
    final String given = response.readEntity(String.class);
    return compareJsonString(expected, given);
}
Also used : Response(javax.ws.rs.core.Response) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery)

Example 8 with MessageQuery

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

the class ParserEncodingTest method checkCsvCorrectTextEncoding.

private void checkCsvCorrectTextEncoding(String controlSequence, String entityName, File csvPath, String textEncoding) throws Exception {
    Registry.Entity.checkExists(entityName);
    Response response = binaryCsvUpload(csvPath, PARSER_NAME, textEncoding, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    MessageQuery query = new MessageQuery();
    query.setEntity(entityName);
    query.setStartDate(MIN_QUERYABLE_DATE);
    query.setEndDate(MAX_QUERYABLE_DATE);
    assertMessageQuerySize(query, 1);
    List<Message> messageList = MessageMethod.queryMessage(query);
    assertEquals("Unexpected message body", messageList.get(0).getMessage(), controlSequence);
}
Also used : Response(javax.ws.rs.core.Response) Message(com.axibase.tsd.api.model.message.Message) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery)

Example 9 with MessageQuery

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

the class MessageInsertTest method testTrimmedMessages.

@Issue("2903")
@Test
public void testTrimmedMessages() throws Exception {
    String entityName = "          nurswgvml022    \n    ";
    String messageText = "          NURSWGVML007 ssh: error: connect_to localhost port 8881: failed.     \n     ";
    String type = "      application    \n      ";
    String date = "2017-05-21T00:00:00Z";
    String endDate = "2017-05-21T00:00:01Z";
    Message message = new Message(entityName, type);
    message.setMessage(messageText);
    message.setDate(date);
    MessageQuery messageQuery = new MessageQuery();
    messageQuery.setEntity("nurswgvml022");
    messageQuery.setStartDate(date);
    messageQuery.setEndDate(endDate);
    insertMessageCheck(message, new MessageQuerySizeCheck(messageQuery, 1));
    List<Message> storedMessageList = queryMessageResponse(messageQuery).readEntity(new GenericType<List<Message>>() {
    });
    Message storedMessage = storedMessageList.get(0);
    assertEquals("nurswgvml022", storedMessage.getEntity());
    assertEquals("NURSWGVML007 ssh: error: connect_to localhost port 8881: failed.", storedMessage.getMessage());
    assertEquals("application", storedMessage.getType());
}
Also used : Message(com.axibase.tsd.api.model.message.Message) List(java.util.List) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 10 with MessageQuery

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

the class MessageInsertTest method testTimeRangeMaxTimeSaved.

@Issue("2957")
@Test
public void testTimeRangeMaxTimeSaved() throws Exception {
    Message message = new Message("e-time-range-msg-3");
    message.setMessage("msg-time-range-msg-3");
    message.setDate(MAX_STORABLE_DATE);
    MessageQuery messageQuery = new MessageQuery();
    messageQuery.setEntity(message.getEntity());
    messageQuery.setStartDate(MIN_QUERYABLE_DATE);
    messageQuery.setEndDate(MAX_QUERYABLE_DATE);
    insertMessageCheck(message, new MessageQuerySizeCheck(messageQuery, 1));
    List<Message> storedMessageList = queryMessageResponse(messageQuery).readEntity(new GenericType<List<Message>>() {
    });
    Message msgResponse = storedMessageList.get(0);
    assertEquals("Max storable date failed to save", message.getDate(), msgResponse.getDate());
    assertEquals("Incorrect stored message", message.getMessage(), msgResponse.getMessage());
}
Also used : Message(com.axibase.tsd.api.model.message.Message) List(java.util.List) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

MessageQuery (com.axibase.tsd.api.model.message.MessageQuery)16 Issue (io.qameta.allure.Issue)12 Test (org.testng.annotations.Test)12 Message (com.axibase.tsd.api.model.message.Message)10 List (java.util.List)6 Response (javax.ws.rs.core.Response)5 Period (com.axibase.tsd.api.model.Period)4 Date (java.util.Date)1 GenericType (javax.ws.rs.core.GenericType)1 BeforeMethod (org.testng.annotations.BeforeMethod)1