Search in sources :

Example 1 with PropertyQuery

use of com.axibase.tsd.api.model.property.PropertyQuery in project atsd-api-test by axibase.

the class PropertyInsertTest method testISOTimezoneZ.

@Issue("2850")
@Test
public void testISOTimezoneZ() throws Exception {
    Property property = new Property("test1", "property-insert-test-isoz");
    property.addTag("test", "test");
    property.setDate("2016-07-21T00:00:00Z");
    insertProperty(property);
    PropertyQuery propertyQuery = new PropertyQuery();
    propertyQuery.setEntity("property-insert-test-isoz");
    propertyQuery.setStartDate("2016-07-21T00:00:00.000Z");
    propertyQuery.setInterval(new Period(1, TimeUnit.MILLISECOND));
    propertyQuery.setType(property.getType());
    List<Property> storedPropertyList = queryProperty(propertyQuery).readEntity(new GenericType<List<Property>>() {
    });
    Property storedProperty = storedPropertyList.get(0);
    assertEquals("Incorrect property entity", property.getEntity(), storedProperty.getEntity());
    assertEquals("Incorrect property tags", property.getTags(), storedProperty.getTags());
    assertEquals("Incorrect property date", propertyQuery.getStartDate(), storedProperty.getDate());
}
Also used : PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Period(com.axibase.tsd.api.model.Period) List(java.util.List) Property(com.axibase.tsd.api.model.property.Property) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 2 with PropertyQuery

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

Example 3 with PropertyQuery

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

Example 4 with PropertyQuery

use of com.axibase.tsd.api.model.property.PropertyQuery 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 5 with PropertyQuery

use of com.axibase.tsd.api.model.property.PropertyQuery 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)

Aggregations

PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)112 Test (org.testng.annotations.Test)109 Property (com.axibase.tsd.api.model.property.Property)94 Issue (io.qameta.allure.Issue)44 Entity (com.axibase.tsd.api.model.entity.Entity)12 Response (javax.ws.rs.core.Response)11 Period (com.axibase.tsd.api.model.Period)6 List (java.util.List)6 NotCheckedException (com.axibase.tsd.api.util.NotCheckedException)1