use of com.axibase.tsd.api.model.message.Message in project atsd-api-test by axibase.
the class LengthTest method testMaxLengthOverflow.
@Issue("2412")
@Test
public void testMaxLengthOverflow() throws Exception {
final Message message = new Message("e-message-max-len-overflow", "t-message-max-len-overflow");
message.setDate(getCurrentDate());
message.setSeverity(Severity.MAJOR.name());
message.setMessage("");
MessageCommand command = new MessageCommand(message);
Integer currentLength = command.compose().length();
String newMessage = new String(new char[MAX_LENGTH - currentLength + 1]).replace("\0", "m");
message.setMessage(newMessage);
command = new MessageCommand(message);
assertTrue("Command must have overflow length", command.compose().length() > MAX_LENGTH);
CommandSendingResult expectedResult = new CommandSendingResult(1, 0);
String assertMessage = String.format("Result must contain one failed command with length %s", command.compose().length());
assertEquals(assertMessage, expectedResult, CommandMethod.send(command));
}
use of com.axibase.tsd.api.model.message.Message in project atsd-api-test by axibase.
the class MessageInsertTest method testISOTimezoneMinusHourMinute.
@Issue("2850")
@Test
public void testISOTimezoneMinusHourMinute() throws Exception {
String entityName = "message-insert-test-iso-hm";
Message message = new Message(entityName);
message.setMessage("hello");
message.setDate("2017-05-20T22:37:00-01:23");
String date = "2017-05-21T00:00:00.000Z";
final MessageQuery messageQuery = new MessageQuery();
messageQuery.setEntity(entityName);
messageQuery.setStartDate(date);
messageQuery.setInterval(new Period(1, TimeUnit.MILLISECOND));
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());
}
use of com.axibase.tsd.api.model.message.Message in project atsd-api-test by axibase.
the class MessageInsertTest method testMillisecondsUnsupported.
@Issue("2850")
@Test
public void testMillisecondsUnsupported() throws Exception {
Message message = new Message("message-insert-test-milliseconds");
message.setMessage("hello");
message.setDate("1469059200000");
Response response = insertMessageReturnResponse(message);
assertEquals("Incorrect response status code", BAD_REQUEST.getStatusCode(), response.getStatus());
JSONAssert.assertEquals("{\"error\":\"IllegalArgumentException: Failed to parse date 1469059200000\"}", response.readEntity(String.class), true);
}
use of com.axibase.tsd.api.model.message.Message in project atsd-api-test by axibase.
the class MessageInsertTest method testTimeRangeMinSaved.
@Issue("2957")
@Test
public void testTimeRangeMinSaved() throws Exception {
Message message = new Message("e-time-range-msg-1");
message.setMessage("msg-time-range-msg-1");
calendar.setTime(new Date());
calendar.add(Calendar.YEAR, -1);
calendar.add(Calendar.DAY_OF_YEAR, 1);
message.setDate(calendar.getTime());
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("Incorrect stored date", message.getDate(), msgResponse.getDate());
assertEquals("Incorrect stored message", message.getMessage(), msgResponse.getMessage());
}
use of com.axibase.tsd.api.model.message.Message in project atsd-api-test by axibase.
the class MessageInsertTest method testLocalTimeUnsupported.
@Issue("2850")
@Test
public void testLocalTimeUnsupported() throws Exception {
Message message = new Message("message-insert-test-localtime");
message.setMessage("hello");
message.setDate("2017-07-21 00:00:00");
Response response = insertMessageReturnResponse(message);
assertEquals("Incorrect response status code", BAD_REQUEST.getStatusCode(), response.getStatus());
JSONAssert.assertEquals("{\"error\":\"IllegalArgumentException: Failed to parse date 2017-07-21 00:00:00\"}", response.readEntity(String.class), true);
}
Aggregations