Search in sources :

Example 11 with MessageQuery

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

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

Example 13 with MessageQuery

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

the class MessageQueryTest method buildMessageQuery.

private MessageQuery buildMessageQuery() {
    MessageQuery messageQuery = new MessageQuery();
    messageQuery.setEntity(message.getEntity());
    messageQuery.setInterval(new Period(1, TimeUnit.MILLISECOND));
    return messageQuery;
}
Also used : Period(com.axibase.tsd.api.model.Period) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery)

Example 14 with MessageQuery

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

the class MessageQueryTest method testISOTimezoneMinusHourMinute.

@Issue("2850")
@Test
public void testISOTimezoneMinusHourMinute() throws Exception {
    MessageQuery messageQuery = buildMessageQuery();
    messageQuery.setStartDate("2018-05-20T22:37:00-01:23");
    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", message.getDate(), storedMessage.getDate());
}
Also used : Message(com.axibase.tsd.api.model.message.Message) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 15 with MessageQuery

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

the class MessageQueryTest method testLocalTimeUnsupported.

@Issue("2850")
@Test
public void testLocalTimeUnsupported() throws Exception {
    MessageQuery messageQuery = buildMessageQuery();
    messageQuery.setStartDate("2017-07-21 00:00:00");
    Response response = queryMessageResponse(messageQuery);
    assertEquals("Incorrect response status code", BAD_REQUEST.getStatusCode(), response.getStatus());
    JSONAssert.assertEquals("{\"error\":\"IllegalArgumentException: Wrong startDate syntax: 2017-07-21 00:00:00\"}", response.readEntity(String.class), true);
}
Also used : Response(javax.ws.rs.core.Response) 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