use of com.axibase.tsd.api.model.extended.CommandSendingResult in project atsd-api-test by axibase.
the class EntityCommandTest method testAddNewEntityTagsMailformedForNewEntity.
@Issue("3111")
@Test
public void testAddNewEntityTagsMailformedForNewEntity() throws Exception {
Entity entity = new Entity("ent-for-test-add-tags-mailformed");
entity.addTag("hello 1", "world");
PlainCommand command = new EntityCommand(entity);
CommandSendingResult expectedResult = new CommandSendingResult(1, 0);
assertEquals(expectedResult, CommandMethod.send(command));
}
use of com.axibase.tsd.api.model.extended.CommandSendingResult 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.extended.CommandSendingResult in project atsd-api-test by axibase.
the class MetricCommandTest method testIncorrectVersioning.
@Issue("3137")
@Test(dataProvider = "incorrectInterpolationFieldProvider")
public void testIncorrectVersioning(String value) throws Exception {
String metricName = metric();
String incorrectCommand = String.format("metric m:%s v:%s", metricName, value);
CommandSendingResult expectedResult = new CommandSendingResult(1, 0);
String assertMessage = String.format("Metric with incorrect versioning field (%s) shouldn't be inserted", value);
assertEquals(assertMessage, expectedResult, CommandMethod.send(incorrectCommand));
}
use of com.axibase.tsd.api.model.extended.CommandSendingResult in project atsd-api-test by axibase.
the class MetricCommandTest method testIncorrectDataType.
@Issue("3137")
@Test(dataProvider = "incorrectDataTypeFieldProvider")
public void testIncorrectDataType(String value) throws Exception {
String metricName = metric();
String incorrectCommand = String.format("metric m:%s p:%s", metricName, value);
CommandSendingResult expectedResult = new CommandSendingResult(1, 0);
String assertMessage = String.format("Metric with incorrect type field (%s) shouldn't be inserted", value);
assertEquals(assertMessage, expectedResult, CommandMethod.send(incorrectCommand));
}
use of com.axibase.tsd.api.model.extended.CommandSendingResult in project atsd-api-test by axibase.
the class LengthTest method testMaxLengthOverflow.
@Issue("2412")
@Test
public void testMaxLengthOverflow() throws Exception {
final Property property = new Property(propertyType(), entity());
property.setDate(Mocks.ISO_TIME);
property.setKey(Collections.EMPTY_MAP);
property.addTag("type", property.getType());
PlainCommand command = new PropertyCommand(property);
Integer currentLength = command.compose().length();
for (int i = 0; currentLength < MAX_LENGTH + 1; i++) {
String tagName = "name" + i;
String textValue = "sda" + i;
currentLength += String.format(" v:%s=%s", tagName, textValue).length();
property.addTag(tagName, textValue);
}
command = new PropertyCommand(property);
CommandSendingResult actualResult = CommandMethod.send(command);
CommandSendingResult expectedResult = new CommandSendingResult(1, 0);
assertTrue("Command length is not greater than max", MAX_LENGTH < currentLength);
assertEquals("Managed to insert command that length is overflow max", expectedResult, actualResult);
}
Aggregations