Search in sources :

Example 91 with Property

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

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

the class PropertyInsertTest method testTagValueBoolean.

@Issue("2416")
@Test
public void testTagValueBoolean() throws Exception {
    final Property storedProperty = new Property("insert-property-t-12", "insert-property-e-12");
    storedProperty.addTag("t1", "true");
    Map<String, Object> property = new HashMap<>();
    property.put("type", storedProperty.getType());
    property.put("entity", storedProperty.getEntity());
    Map<String, Object> tags = new HashMap<>();
    tags.put("t1", true);
    property.put("tags", tags);
    Response response = insertProperty(property);
    assertEquals("Incorrect response status code", OK.getStatusCode(), response.getStatus());
    assertTrue("Fail to get inserted properties", propertyExist(storedProperty));
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) Property(com.axibase.tsd.api.model.property.Property) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 93 with Property

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

the class PropertyInsertTest method testExtraKeyInRoot.

/**
 * #NoTicket - base tests
 */
@Test
public void testExtraKeyInRoot() throws Exception {
    final Property property = new Property("insert-type3", "insert-entity3");
    property.setDate("2014-02-02T00:00:00.000Z");
    property.addTag("t1", "tv1");
    final Map<String, Object> insertObj = new HashMap<>();
    insertObj.put("type", property.getType());
    insertObj.put("entity", property.getEntity());
    insertObj.put("tags", property.getTags());
    insertObj.put("date", property.getDate());
    insertObj.put("extraField", "extraValue");
    Response response = insertProperty(insertObj);
    assertEquals(BAD_REQUEST.getStatusCode(), response.getStatus());
    assertFalse("Inserted property should not exist", propertyExist(property));
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 94 with Property

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

the class PropertyInsertTest method testTagValueSpaces.

@Issue("2416")
@Test
public void testTagValueSpaces() throws Exception {
    Property property = new Property("insert-property-t-8", "insert-property-e-8");
    property.addTag("t1", "   ");
    property.addTag("t2", "tv2");
    property.setDate("2016-06-09T09:50:00.000Z");
    Response response = insertProperty(property);
    Property storedProperty = new Property(property);
    storedProperty.setTags(null);
    storedProperty.addTag("t2", "tv2");
    assertEquals("Incorrect response status code", OK.getStatusCode(), response.getStatus());
    assertTrue("Fail to get inserted properties", propertyExist(storedProperty));
}
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 95 with Property

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

the class PropertyInsertTest method testTagValueEmpty.

@Issue("2416")
@Test
public void testTagValueEmpty() throws Exception {
    Property property = new Property("insert-property-t-41", "insert-property-e-41");
    property.addTag("t1", "tv1");
    property.addTag("t2", "");
    property.setDate("2016-06-09T09:50:00.000Z");
    Response response = insertProperty(property);
    Property storedProperty = new Property(property);
    storedProperty.setTags(null);
    storedProperty.addTag("t1", "tv1");
    assertEquals("Incorrect response status code", OK.getStatusCode(), response.getStatus());
    assertTrue("Fail to get inserted properties", propertyExist(storedProperty));
}
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