Search in sources :

Example 26 with Message

use of com.axibase.tsd.api.model.message.Message 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 27 with Message

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

the class MessageInsertTest method testXXTimezoneUnsupported.

@Issue("2850")
@Test
public void testXXTimezoneUnsupported() throws Exception {
    Message message = new Message("message-insert-test-xxtimezone");
    message.setMessage("hello");
    message.setDate("2017-07-20T22:50:00-0110");
    Response response = insertMessageReturnResponse(message);
    assertEquals("Incorrect response status code", BAD_REQUEST.getStatusCode(), response.getStatus());
    JSONAssert.assertEquals("{\"error\":\"IllegalArgumentException: Failed to parse date 2017-07-20T22:50:00-0110\"}", response.readEntity(String.class), true);
}
Also used : Response(javax.ws.rs.core.Response) Message(com.axibase.tsd.api.model.message.Message) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 28 with Message

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

Example 29 with Message

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

the class MessageInsertTest method testISOTimezoneZ.

@Issue("2850")
@Test
public void testISOTimezoneZ() throws Exception {
    String entityName = "message-insert-test-isoz";
    Message message = new Message(entityName);
    message.setMessage("hello");
    message.setDate("2017-05-21T00:00:00Z");
    String date = "2017-05-21T00:00:00.000Z";
    MessageQuery messageQuery = new MessageQuery();
    messageQuery.setEntity(entityName);
    messageQuery.setStartDate(date);
    messageQuery.setInterval(new Period(1, TimeUnit.MILLISECOND));
    MessageMethod.insertMessageCheck(message, new MessageQuerySizeCheck(messageQuery, 1));
    GenericType<List<Message>> generic = new GenericType<List<Message>>() {
    };
    List<Message> storedMessageList = queryMessageResponse(messageQuery).readEntity(generic);
    Message storedMessage = storedMessageList.get(0);
    assertEquals("Incorrect message entity", message.getEntity(), storedMessage.getEntity());
    assertEquals("Incorrect message text", message.getMessage(), storedMessage.getMessage());
    assertEquals("Incorrect message date", date, storedMessage.getDate());
}
Also used : GenericType(javax.ws.rs.core.GenericType) Message(com.axibase.tsd.api.model.message.Message) Period(com.axibase.tsd.api.model.Period) List(java.util.List) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 30 with Message

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

the class MessageInsertTest method testISOTimezonePlusHourMinute.

@Issue("2850")
@Test
public void testISOTimezonePlusHourMinute() throws Exception {
    String entityName = "message-insert-test-iso+hm";
    Message message = new Message(entityName);
    message.setMessage("hello");
    message.setDate("2017-05-21T01:23:00+01:23");
    String date = "2017-05-21T00:00:00.000Z";
    MessageQuery messageQuery = new MessageQuery();
    messageQuery.setEntity(entityName);
    messageQuery.setStartDate(date);
    messageQuery.setInterval(new Period(1, TimeUnit.MILLISECOND));
    MessageMethod.insertMessageCheck(message, new MessageQuerySizeCheck(messageQuery, 1));
    List<Message> storedMessageList = queryMessageResponse(messageQuery).readEntity(new GenericType<List<Message>>() {
    });
    Message storedMessage = storedMessageList.get(0);
    assertEquals("Incorrect message entity", message.getEntity(), storedMessage.getEntity());
    assertEquals("Incorrect message text", message.getMessage(), storedMessage.getMessage());
    assertEquals("Incorrect message date", date, storedMessage.getDate());
}
Also used : Message(com.axibase.tsd.api.model.message.Message) Period(com.axibase.tsd.api.model.Period) List(java.util.List) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

Message (com.axibase.tsd.api.model.message.Message)35 Issue (io.qameta.allure.Issue)32 Test (org.testng.annotations.Test)32 MessageCommand (com.axibase.tsd.api.model.command.MessageCommand)14 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)12 MessageQuery (com.axibase.tsd.api.model.message.MessageQuery)10 List (java.util.List)8 Response (javax.ws.rs.core.Response)4 Period (com.axibase.tsd.api.model.Period)3 Date (java.util.Date)2 BeforeClass (org.testng.annotations.BeforeClass)2 CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)1 Severity (com.axibase.tsd.api.model.message.Severity)1 GenericType (javax.ws.rs.core.GenericType)1