use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testLastDefault.
/**
* #NoTicket
*/
@Test
public void testLastDefault() throws Exception {
final Property property = new Property("query-type8", "query-entity8");
property.addTag("t1", "tv1");
property.addKey("k1", "kv1");
property.setDate(getPreviousDay());
insertPropertyCheck(property);
final Property lastProperty = new Property();
lastProperty.setType(property.getType());
lastProperty.setEntity(property.getEntity());
lastProperty.addTag("t2", "tv2");
lastProperty.setDate(getCurrentDate());
insertPropertyCheck(lastProperty);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
String expected = jacksonMapper.writeValueAsString(Arrays.asList(property, lastProperty));
String given = queryProperty(query).readEntity(String.class);
assertTrue("Both properties should be returned if 'last' field is not specified", compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testEndDateAbsent.
/**
* #NoTicket
*/
@Test
public void testEndDateAbsent() throws Exception {
PropertyQuery query = new PropertyQuery("mock-type", "mock-entity");
query.setStartDate("2016-05-25T05:00:00Z");
Response response = queryProperty(query);
assertEquals("Query should fail if endDate is not specified", BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("Error message mismatch", ErrorTemplate.DATE_FILTER_COMBINATION_REQUIRED, extractErrorMessage(response));
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityTagsTagsAsKeyExactTrue.
/**
* #NoTicket
*/
@Test
public void testEntityTagsTagsAsKeyExactTrue() throws Exception {
final Entity entity = new Entity("query-entity21");
entity.addTag("t1", "tv1");
entity.addTag("t2", "tv2");
EntityMethod.createOrReplaceEntityCheck(entity);
PropertyQuery query = prepareSimplePropertyQuery(ENTITY_TAGS_PROPERTY_TYPE, entity.getName());
query.setKey(entity.getTags());
query.setExactMatch(true);
String given = queryProperty(query).readEntity(String.class);
String emptyJsonList = "[]";
assertTrue("No property should be returned", compareJsonString(emptyJsonList, given));
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testKeyMatchExactFalse.
/**
* #NoTicket
*/
@Test
public void testKeyMatchExactFalse() throws Exception {
final Property property = new Property("query-type11", "query-entity11");
property.addTag("t1", "tv1");
property.addKey("k1", "kv1");
insertPropertyCheck(property);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), "*");
query.setKey(property.getKey());
query.setExactMatch(false);
assertInsertedPropertyReturned(property, query);
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testLimitWithKeyExpression.
@Issue("3110")
@Test
public void testLimitWithKeyExpression() throws Exception {
final int limit = 1;
final Property property = new Property("query-type57-c", "query-entity57-c");
final String tag = "key1";
property.addKey("uniq", tag);
property.addTag("tag_key", "tag_value");
insertPropertyCheck(property);
final Property property2 = new Property();
property2.setType(property.getType());
property2.setEntity(property.getEntity());
property2.addKey("uniq", tag.toUpperCase());
property2.addTag("tag_key2", "tag_value2");
insertPropertyCheck(property2);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
query.setKeyTagExpression("keys.uniq = '" + tag + "'");
query.setLimit(limit);
assertEquals("One property should be received", limit, calculateJsonArraySize(queryProperty(query).readEntity(String.class)));
query.setKeyTagExpression("keys.uniq = '" + tag.toUpperCase() + "'");
assertEquals("One property should be received", limit, calculateJsonArraySize(queryProperty(query).readEntity(String.class)));
}
Aggregations