Search in sources :

Example 16 with PropertyQuery

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

the class PropertyQueryTest method testExactTruePartialMatch.

/**
 * #NoTicket
 */
@Test
public void testExactTruePartialMatch() throws Exception {
    final Property property = new Property("query-type12", "query-entity12");
    property.addTag("t1", "tv1");
    property.addKey("k1", "kv1");
    property.addKey("k2", "kv2");
    insertPropertyCheck(property);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), "*");
    query.addKey("k1", "kv1");
    query.setExactMatch(true);
    String emptyJsonList = "[]";
    Response response = queryProperty(query);
    assertTrue("Should not receive any properties", compareJsonString(emptyJsonList, response.readEntity(String.class)));
}
Also used : Response(javax.ws.rs.core.Response) PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 17 with PropertyQuery

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

the class PropertyQueryTest method testLastTrueReturnMultipleProperty.

/**
 * #NoTicket
 */
@Test
public void testLastTrueReturnMultipleProperty() throws Exception {
    final Property property = new Property("query-type6.1", "query-entity6.1");
    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);
    final Property lastPropertySecond = new Property();
    lastPropertySecond.setType(property.getType());
    lastPropertySecond.setEntity(property.getEntity());
    lastPropertySecond.addTag("t1l", "tv1l");
    lastPropertySecond.addKey("k2", "kv2");
    lastPropertySecond.setDate(lastProperty.getDate());
    insertPropertyCheck(lastPropertySecond);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.setLast(true);
    String expected = jacksonMapper.writeValueAsString(Arrays.asList(lastProperty, lastPropertySecond));
    String given = queryProperty(query).readEntity(String.class);
    assertTrue("Only two last properties should be in response", 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 18 with PropertyQuery

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

the class PropertyQueryTest method testKeyValueNullExactTrue.

@Issue("2416")
@Test
public void testKeyValueNullExactTrue() throws Exception {
    final Property property = new Property("query-type-61", "query-entity61");
    property.addTag("t1", "v1");
    insertPropertyCheck(property);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.addKey("k1", null);
    query.setExactMatch(true);
    assertStoredPropertyDoesNotMatchToInserted(property, query);
}
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 19 with PropertyQuery

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

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

the class PropertyQueryTest method testKeyValueNullExactFalse.

@Issue("2416")
@Test
public void testKeyValueNullExactFalse() throws Exception {
    final Property property = new Property("query-type-62", "query-entity62");
    property.addTag("t1", "v1");
    insertPropertyCheck(property);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.addKey("k1", null);
    query.setExactMatch(false);
    assertStoredPropertyDoesNotMatchToInserted(property, query);
}
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)

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