Search in sources :

Example 1 with CommandSendingResult

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));
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) CommandSendingResult(com.axibase.tsd.api.model.extended.CommandSendingResult) EntityCommand(com.axibase.tsd.api.model.command.EntityCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 2 with CommandSendingResult

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));
}
Also used : Message(com.axibase.tsd.api.model.message.Message) CommandSendingResult(com.axibase.tsd.api.model.extended.CommandSendingResult) MessageCommand(com.axibase.tsd.api.model.command.MessageCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 3 with CommandSendingResult

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));
}
Also used : CommandSendingResult(com.axibase.tsd.api.model.extended.CommandSendingResult) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 4 with CommandSendingResult

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));
}
Also used : CommandSendingResult(com.axibase.tsd.api.model.extended.CommandSendingResult) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with CommandSendingResult

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);
}
Also used : PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) CommandSendingResult(com.axibase.tsd.api.model.extended.CommandSendingResult) Property(com.axibase.tsd.api.model.property.Property) PropertyCommand(com.axibase.tsd.api.model.command.PropertyCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)9 Issue (io.qameta.allure.Issue)9 Test (org.testng.annotations.Test)9 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)2 EntityCommand (com.axibase.tsd.api.model.command.EntityCommand)1 MessageCommand (com.axibase.tsd.api.model.command.MessageCommand)1 MetricCommand (com.axibase.tsd.api.model.command.MetricCommand)1 PropertyCommand (com.axibase.tsd.api.model.command.PropertyCommand)1 SeriesCommand (com.axibase.tsd.api.model.command.SeriesCommand)1 Entity (com.axibase.tsd.api.model.entity.Entity)1 Message (com.axibase.tsd.api.model.message.Message)1 Property (com.axibase.tsd.api.model.property.Property)1 Series (com.axibase.tsd.api.model.series.Series)1