use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testKeyTagExpressionAND.
@Issue("2908")
@Test
public void testKeyTagExpressionAND() throws Exception {
final Property property = new Property("query-type44", "query-entity44");
property.addTag("t1", "tv1");
property.addKey("k1", "kv1");
insertPropertyCheck(property);
final Property property2 = new Property();
property2.setType(property.getType());
property2.setEntity(property.getEntity());
property2.addTag("t1", "tv1");
property2.addKey("k2", "kv2");
insertPropertyCheck(property2);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
query.setKeyTagExpression("tags.t1 == 'tv1' AND keys.k2 == 'kv2'");
String given = queryProperty(query).readEntity(String.class);
String expected = jacksonMapper.writeValueAsString(Collections.singletonList(property2));
assertTrue("Only second property should be returned", compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testLastTrue.
/**
* #NoTicket
*/
@Test
public void testLastTrue() throws Exception {
final Property property = new Property("query-type6", "query-entity6");
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("t1l", "tv1l");
lastProperty.setDate(getCurrentDate());
insertPropertyCheck(lastProperty);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
query.setLast(true);
String expected = jacksonMapper.writeValueAsString(Collections.singletonList(lastProperty));
String given = queryProperty(query).readEntity(String.class);
assertTrue("Only last property should be returned if 'last' field is set to 'true'", compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntitiesWildcardStartChar.
@Issue("2979")
@Test
public void testEntitiesWildcardStartChar() throws Exception {
final Property property = new Property("query-type59", "query-entity59");
property.addTag("t1", "tv1");
insertPropertyCheck(property);
PropertyQuery query = new PropertyQuery();
query.setType(property.getType());
query.setEntities(Collections.singletonList("query-entity*"));
query.setStartDate(MIN_QUERYABLE_DATE);
query.setEndDate(MAX_QUERYABLE_DATE);
assertInsertedPropertyReturned(property, query);
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityFilterAbsent.
/**
* #NoTicket
*/
@Test
public void testEntityFilterAbsent() throws Exception {
PropertyQuery query = new PropertyQuery();
query.setType("mock-type");
query.setStartDate("2016-06-01T12:04:59.191Z");
query.setEndDate("2016-06-01T13:04:59.191Z");
Response response = queryProperty(query);
assertEquals("Query EntityFilter is not specified", BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("Error message mismatch", ErrorTemplate.ENTITY_FILTER_REQUIRED, extractErrorMessage(response));
}
use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.
the class PropertyQueryTest method testKeyTagExpressionUpperKey.
@Issue("2908")
@Test
public void testKeyTagExpressionUpperKey() throws Exception {
final Property property = new Property("query-type54", "query-entity54");
property.addTag("t1", "tv1");
property.addKey("k1", "KV1");
insertPropertyCheck(property);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
query.setKeyTagExpression("upper(keys.k1) == 'KV1'");
assertInsertedPropertyReturned(property, query);
}
Aggregations