Search in sources :

Example 71 with Entity

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));
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 72 with Entity

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));
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 73 with Entity

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));
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Test(org.testng.annotations.Test)

Example 74 with Entity

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);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) Metric(com.axibase.tsd.api.model.metric.Metric) BeforeClass(org.testng.annotations.BeforeClass)

Example 75 with Entity

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);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

Entity (com.axibase.tsd.api.model.entity.Entity)77 Test (org.testng.annotations.Test)60 Issue (io.qameta.allure.Issue)43 Metric (com.axibase.tsd.api.model.metric.Metric)21 Series (com.axibase.tsd.api.model.series.Series)21 BeforeClass (org.testng.annotations.BeforeClass)15 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)12 EntityCommand (com.axibase.tsd.api.model.command.EntityCommand)9 HashMap (java.util.HashMap)9 Property (com.axibase.tsd.api.model.property.Property)8 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)6 EntityCheck (com.axibase.tsd.api.method.checks.EntityCheck)5 Response (javax.ws.rs.core.Response)5 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)4 File (java.io.File)4 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)3 SeriesSearchResultRecord (com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord)3 Sample (com.axibase.tsd.api.model.series.Sample)2 SeriesSearchQuery (com.axibase.tsd.api.model.series.search.SeriesSearchQuery)2 BigDecimal (java.math.BigDecimal)2