Search in sources :

Example 16 with Entity

use of com.axibase.tsd.api.model.entity.Entity 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));
}
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 17 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class PropertyQueryTest method testEntityTagsExpressionCaseSensitiveValue.

/**
 * #NoTicket
 */
@Test
public void testEntityTagsExpressionCaseSensitiveValue() throws Exception {
    Entity entity = new Entity("query-entity41");
    entity.addTag("t1", "tv1");
    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 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 18 with Entity

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

Example 19 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class PropertyQueryTest method testEntityTagsEmptyKeyExactFalse.

/**
 * #NoTicket
 */
@Test
public void testEntityTagsEmptyKeyExactFalse() throws Exception {
    final Entity entity = new Entity("query-entity23");
    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(false);
    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 20 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class CSVInsertTest method testEntityNames.

@Issue("1278")
@Test(dataProvider = "entityNameProvider")
public void testEntityNames(String queryName, String expectedName) throws Exception {
    Entity entity = new Entity(queryName);
    Metric metric = new Metric(metric());
    String csvPayload = String.format("time, %s%n0, 0%n", metric.getName());
    Response response = csvInsert(entity.getName(), csvPayload);
    String assertMessage = String.format("Failed to insert entity with name: %s", entity);
    assertEquals(assertMessage, OK.getStatusCode(), response.getStatus());
    entity.setName(expectedName);
    assertEntityExisting(entity);
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) Metric(com.axibase.tsd.api.model.metric.Metric) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

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