use of com.axibase.tsd.api.model.property.Property in project atsd-api-test by axibase.
the class PropertyQueryTest method testKeyTagExpressionKeyNotEmpty.
@Issue("2908")
@Test
public void testKeyTagExpressionKeyNotEmpty() throws Exception {
final Property property = new Property("query-type49", "query-entity49");
property.addTag("t1", "tv1");
insertPropertyCheck(property);
final Property property2 = new Property();
property2.setType(property.getType());
property2.setEntity(property.getEntity());
property2.addTag("t2", "tv2");
property2.addKey("k2", "tv2");
insertPropertyCheck(property2);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
query.setKeyTagExpression("keys.k2 != ''");
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.Property in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityWildcardExactFalse.
/**
* #NoTicket
*/
@Test
public void testEntityWildcardExactFalse() throws Exception {
final Property property = new Property("query-type18", "query-entity18");
property.addTag("t1", "tv1");
insertPropertyCheck(property);
final Property secondProperty = new Property(null, "query-entity18-2");
secondProperty.setType(property.getType());
secondProperty.addTag("t2", "tv2");
secondProperty.addKey("k2", "kv2");
insertPropertyCheck(secondProperty);
PropertyQuery query = prepareSimplePropertyQuery(property.getType(), "*");
query.setExactMatch(false);
String expected = jacksonMapper.writeValueAsString(Arrays.asList(property, secondProperty));
String given = queryProperty(query).readEntity(String.class);
assertTrue("Stored series do not match to inserted", compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.property.Property in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityTagsEmptyKeyExactTrue.
/**
* #NoTicket
*/
@Test
public void testEntityTagsEmptyKeyExactTrue() throws Exception {
final Entity entity = new Entity("query-entity24");
entity.addTag("t1", "tv1");
entity.addTag("t2", "tv2");
final Property property = new Property();
property.setType(ENTITY_TAGS_PROPERTY_TYPE);
property.setEntity(entity.getName());
property.setTags(entity.getTags());
EntityMethod.createOrReplaceEntityCheck(entity);
PropertyQuery query = prepareSimplePropertyQuery(ENTITY_TAGS_PROPERTY_TYPE, entity.getName());
query.setExactMatch(true);
String given = queryProperty(query).readEntity(String.class);
String expected = jacksonMapper.writeValueAsString(Collections.singletonList(property));
assertTrue(String.format("Property with type %s for inserted entity should be returned", ENTITY_TAGS_PROPERTY_TYPE), compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.property.Property 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.Property 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));
}
Aggregations