use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityTagsKeyExpression.
/**
* #NoTicket
*/
@Test
public void testEntityTagsKeyExpression() throws Exception {
final Entity entity = new Entity("query-entity25");
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.setKeyTagExpression("tags.t1 == 'tv1'");
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.entity.Entity in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityTagsKeyTagExpressionCaseInsensitiveName.
/**
* #NoTicket
*/
@Test
public void testEntityTagsKeyTagExpressionCaseInsensitiveName() throws Exception {
Entity entity = new Entity("query-entity42");
entity.addTag("t1", "tv1");
EntityMethod.createOrReplaceEntityCheck(entity);
final Property property = new Property();
property.setType(ENTITY_TAGS_PROPERTY_TYPE);
property.setEntity(entity.getName());
property.setTags(entity.getTags());
PropertyQuery query = prepareSimplePropertyQuery(ENTITY_TAGS_PROPERTY_TYPE, entity.getName());
query.setKeyTagExpression("tags.T1 == 'tv1'");
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.entity.Entity in project atsd-api-test by axibase.
the class PropertyQueryTest method testEntityTagsKeyExpressionNoMatch.
/**
* #NoTicket
*/
@Test
public void testEntityTagsKeyExpressionNoMatch() throws Exception {
final Entity entity = new Entity("query-entity26");
entity.addTag("t1", "tv1");
entity.addTag("t2", "tv2");
EntityMethod.createOrReplaceEntityCheck(entity);
PropertyQuery query = prepareSimplePropertyQuery(ENTITY_TAGS_PROPERTY_TYPE, entity.getName());
query.setKeyTagExpression("tags.t1 == 'v2'");
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.entity.Entity in project atsd-api-test by axibase.
the class SeriesQueryAddMetaTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
Series historySeries = new Series(ENTITY_NAME, METRIC_NAME).setType(SeriesType.HISTORY);
historySeries.addSamples(Sample.ofDateInteger("2017-11-23T10:00:00.000Z", 1));
Series forecastSeries = new Series(ENTITY_NAME, METRIC_NAME).setType(SeriesType.FORECAST);
forecastSeries.addSamples(Sample.ofDateInteger("2017-11-23T10:00:00.000Z", 2));
MetricMethod.createOrReplaceMetricCheck(new Metric(EMPTY_METRIC_NAME));
EntityMethod.createOrReplaceEntityCheck(new Entity(EMPTY_ENTITY_NAME));
insertSeriesCheck(historySeries, forecastSeries);
}
use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.
the class GroupByCaseExpressionTest method prepareData.
@BeforeClass
public static void prepareData() throws Exception {
Entity testEntity1 = new Entity(TEST_ENTITY1_NAME);
testEntity1.setLabel(TEST_ENTITY1_LABEL);
Entity testEntity2 = new Entity(TEST_ENTITY2_NAME);
testEntity2.setLabel(TEST_ENTITY2_LABEL);
Series series1 = new Series(TEST_ENTITY1_NAME, TEST_METRIC_NAME);
series1.addSamples(Sample.ofDateDecimalText("2017-02-09T12:00:00.000Z", DECIMAL_VALUE, TEXT_VALUE_1), Sample.ofDateDecimalText("2017-02-10T12:00:00.000Z", DECIMAL_VALUE, TEXT_VALUE_1));
Series series2 = new Series(TEST_ENTITY2_NAME, TEST_METRIC_NAME);
series2.addSamples(Sample.ofDateDecimalText("2017-02-11T12:00:00.000Z", DECIMAL_VALUE, TEXT_VALUE_2), Sample.ofDateDecimalText("2017-02-12T12:00:00.000Z", DECIMAL_VALUE, TEXT_VALUE_2));
EntityMethod.createOrReplaceEntity(testEntity2);
EntityMethod.createOrReplaceEntity(testEntity1);
SeriesMethod.insertSeriesCheck(series1, series2);
}
Aggregations