Search in sources :

Example 21 with Property

use of com.axibase.tsd.api.model.property.Property in project atsd-api-test by axibase.

the class DoubleBackslashCharEscapeTest method testType.

@Issue("2854")
@Test
public void testType() throws Exception {
    Property property = new Property("property-command-test\\\\-t7", "property-command-test-e7");
    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 22 with Property

use of com.axibase.tsd.api.model.property.Property 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 23 with Property

use of com.axibase.tsd.api.model.property.Property in project atsd-api-test by axibase.

the class PropertyInsertTest method testMultipleInsertSameTypeEntityKey.

/**
 * #NoTicket - base tests
 */
@Test
public void testMultipleInsertSameTypeEntityKey() throws Exception {
    final long firstTime = System.currentTimeMillis() - 5;
    final long secondTime = System.currentTimeMillis();
    final Property property = new Property("insert-type2", "insert-entity2");
    property.addTag("t1", "v1");
    property.addKey("k1", "v1");
    property.setDate(firstTime);
    final Property updatedProperty = new Property();
    updatedProperty.setType(property.getType());
    updatedProperty.setEntity(property.getEntity());
    updatedProperty.setKey(property.getKey());
    updatedProperty.setTags(new HashMap<String, String>() {

        {
            put("nt1", "ntv1");
        }
    });
    updatedProperty.setDate(secondTime);
    assertEquals(OK.getStatusCode(), insertProperty(property, updatedProperty).getStatus());
    assertTrue("Updated property should exist", propertyExist(updatedProperty, true));
    assertFalse("Old property should not exist", propertyExist(property, true));
}
Also used : Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 24 with Property

use of com.axibase.tsd.api.model.property.Property in project atsd-api-test by axibase.

the class PropertyInsertTest method testTimeRangeMinSaved.

@Issue("2957")
@Test
public void testTimeRangeMinSaved() throws Exception {
    Property property = new Property("t-time-range-p-1", "e-time-range--1");
    property.addTag("ttr-t", "ttr-v");
    property.setDate(MIN_STORABLE_DATE);
    Response response = insertProperty(property);
    assertEquals("Failed to insert property", response.getStatus(), OK.getStatusCode());
    assertTrue(propertyExist(property));
}
Also used : Response(javax.ws.rs.core.Response) Property(com.axibase.tsd.api.model.property.Property) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 25 with Property

use of com.axibase.tsd.api.model.property.Property in project atsd-api-test by axibase.

the class PropertyInsertTest method testMillisecondsUnsupported.

@Issue("2850")
@Test
public void testMillisecondsUnsupported() throws Exception {
    String entityName = "property-insert-test-milliseconds";
    String type = "test6";
    Property property = new Property(type, entityName);
    property.addTag("test", "test");
    property.setDate("1465502400000");
    Response response = insertProperty(property);
    assertEquals("Incorrect response status code", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", DATE_FILTER_INVALID_FORMAT, extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) Property(com.axibase.tsd.api.model.property.Property) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

Property (com.axibase.tsd.api.model.property.Property)146 Test (org.testng.annotations.Test)143 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)94 Issue (io.qameta.allure.Issue)84 Response (javax.ws.rs.core.Response)23 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)10 PropertyCommand (com.axibase.tsd.api.model.command.PropertyCommand)10 HashMap (java.util.HashMap)9 Entity (com.axibase.tsd.api.model.entity.Entity)8 List (java.util.List)6 Period (com.axibase.tsd.api.model.Period)5 EntityGroup (com.axibase.tsd.api.model.entitygroup.EntityGroup)1 CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)1 Series (com.axibase.tsd.api.model.series.Series)1 BeforeClass (org.testng.annotations.BeforeClass)1