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);
}
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));
}
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));
}
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));
}
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));
}
Aggregations