Search in sources :

Example 6 with PropertyCommand

use of com.axibase.tsd.api.model.command.PropertyCommand in project atsd-api-test by axibase.

the class LengthTest method testMaxLength.

@Issue("2412")
@Test
public void testMaxLength() 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; i++) {
        String tagName = "name" + property.getEntity() + i;
        String textValue = "sda" + property.getEntity() + i;
        String addedTag = String.format(" v:%s=%s", tagName, textValue);
        currentLength += addedTag.length();
        if (currentLength <= MAX_LENGTH) {
            property.addTag(tagName, textValue);
        } else {
            currentLength -= addedTag.length();
            break;
        }
    }
    while (currentLength != MAX_LENGTH) {
        property.setType(property.getType().concat("+"));
        currentLength++;
    }
    command = new PropertyCommand(property);
    assertEquals("Command length is not maximal", MAX_LENGTH, command.compose().length());
    CommandMethod.send(command);
    assertPropertyExisting("Inserted property can not be received", property);
}
Also used : PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) 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)

Example 7 with PropertyCommand

use of com.axibase.tsd.api.model.command.PropertyCommand in project atsd-api-test by axibase.

the class BackslashCharEscapeTest method testEntity.

@Issue("2854")
@Test
public void testEntity() throws Exception {
    Property property = new Property("property-command-test-t6", "property-command-test\\-e6");
    property.setTags(DEFAULT_PROPERTY_TAGS);
    property.setDate(getCurrentDate());
    PlainCommand command = new PropertyCommand(property);
    CommandMethod.send(command);
    assertPropertyExisting("Inserted property can not be received", property);
}
Also used : PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) 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)

Example 8 with PropertyCommand

use of com.axibase.tsd.api.model.command.PropertyCommand in project atsd-api-test by axibase.

the class DoubleBackslashCharEscapeTest method testEntity.

@Issue("2854")
@Test
public void testEntity() throws Exception {
    Property property = new Property("property-command-test-t8", "property-command-test\\\\-e8");
    property.setTags(DEFAULT_PROPERTY_TAGS);
    property.setDate(getCurrentDate());
    PlainCommand command = new PropertyCommand(property);
    CommandMethod.send(command);
    assertPropertyExisting("Inserted property can not be received", property);
}
Also used : PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) 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)

Example 9 with PropertyCommand

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

Example 10 with PropertyCommand

use of com.axibase.tsd.api.model.command.PropertyCommand in project atsd-api-test by axibase.

the class EqualCharEscapeTest method testEntity.

@Issue("2854")
@Test
public void testEntity() throws Exception {
    Property property = new Property("property-command-test-t4", "property-command-test=-e4");
    property.setTags(DEFAULT_PROPERTY_TAGS);
    property.setDate(getCurrentDate());
    PlainCommand command = new PropertyCommand(property);
    CommandMethod.send(command);
    assertPropertyExisting("Inserted property can not be received", property);
}
Also used : PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) 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

PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)10 PropertyCommand (com.axibase.tsd.api.model.command.PropertyCommand)10 Property (com.axibase.tsd.api.model.property.Property)10 Issue (io.qameta.allure.Issue)10 Test (org.testng.annotations.Test)10 CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)1