Search in sources :

Example 26 with PropertyQuery

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

the class PropertyQueryTest method testLimitWithEntityFilter.

@Issue("3110")
@Test
public void testLimitWithEntityFilter() throws Exception {
    final Property property = new Property("query-type57-b", "query-entity57-b-limitentityold");
    property.setDate("2016-07-18T02:35:00.000Z");
    property.addKey("uniq", "key1");
    property.addTag("tag_key", "tag_value");
    insertPropertyCheck(property);
    final Property property2 = new Property(null, "query-entity57-b-limitentity-2");
    property2.setType(property.getType());
    property2.setDate(Util.addOneMS(property.getDate()));
    property2.addKey("uniq", "key2");
    property2.addTag("tag_key2", "tag_value2");
    insertPropertyCheck(property2);
    final Property property3 = new Property(null, "query-entity57-b-limitentity-3");
    property3.setType(property.getType());
    property3.setDate(Util.addOneMS(property.getDate()));
    property3.addKey("uniq", "key3");
    property3.addTag("tag_key2", "tag_value2");
    insertPropertyCheck(property3);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), "query-entity57-b-limitentity-*");
    query.setLimit(2);
    assertEquals("Two property should be received", 2, calculateJsonArraySize(queryProperty(query).readEntity(String.class)));
    query.setEntity("query-entity57-b-limitentityo*");
    query.setLimit(1);
    assertEquals("One property should be received", 1, calculateJsonArraySize(queryProperty(query).readEntity(String.class)));
}
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 27 with PropertyQuery

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

the class PropertyQueryTest method testKeyTagExpressionOR.

@Issue("2908")
@Test
public void testKeyTagExpressionOR() throws Exception {
    final Property property = new Property("query-type43", "query-entity43");
    property.addTag("t1", "tv1");
    property.addKey("k1", "kv1");
    insertPropertyCheck(property);
    final Property property2 = new Property();
    property2.setType(property.getType());
    property2.setEntity(property.getEntity());
    property2.addTag("t1", "tv1");
    insertPropertyCheck(property2);
    final Property property3 = new Property();
    property3.setType(property.getType());
    property3.setEntity(property.getEntity());
    property3.addTag("t3", "tv3");
    property3.addKey("k3", "kv3");
    insertPropertyCheck(property3);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.setKeyTagExpression("tags.t1 == 'tv1' OR keys.k3 == 'kv3'");
    String given = queryProperty(query).readEntity(String.class);
    String expected = jacksonMapper.writeValueAsString(Arrays.asList(property, property2, property3));
    assertTrue("All inserted properties 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 28 with PropertyQuery

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

the class PropertyDeleteTest method testKeyValueNullExactTrue.

@Issue("2416")
@Test
public void testKeyValueNullExactTrue() throws Exception {
    final Property property = new Property("delete-type-22", "delete-entity22");
    property.addTag("t1", "v1");
    insertPropertyCheck(property);
    PropertyQuery deleteQuery = new PropertyQuery();
    deleteQuery.setType(property.getType());
    deleteQuery.setEntity(property.getEntity());
    deleteQuery.addKey("k1", null);
    deleteQuery.setExactMatch(true);
    assertEquals("Fail to execute delete query", OK.getStatusCode(), deleteProperty(deleteQuery).getStatus());
    assertFalse("Property should be deleted", propertyExist(property));
}
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 29 with PropertyQuery

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

the class PropertyDeleteTest method testTypeEntityKey.

@Test
public void testTypeEntityKey() throws Exception {
    final Property property = new Property("delete-type4", "delete-entity4");
    property.addTag("t1", "v1");
    property.addKey("k1", "v1");
    insertPropertyCheck(property);
    PropertyQuery deleteQuery = new PropertyQuery();
    deleteQuery.setType(property.getType());
    deleteQuery.setEntity(property.getEntity());
    deleteQuery.setKey(property.getKey());
    assertEquals("Fail to execute delete query", OK.getStatusCode(), deleteProperty(deleteQuery).getStatus());
    assertFalse("Property should be deleted", propertyExist(property));
}
Also used : PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 30 with PropertyQuery

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

the class PropertyDeleteTest method testExtraKeyPropNoKeyExactTrue.

@Test
public void testExtraKeyPropNoKeyExactTrue() throws Exception {
    final Property property = new Property("delete-type14", "delete-entity14");
    property.addTag("t1", "v1");
    insertPropertyCheck(property);
    PropertyQuery deleteQuery = new PropertyQuery();
    deleteQuery.setType(property.getType());
    deleteQuery.setEntity(property.getEntity());
    deleteQuery.addKey("k2", "kv2");
    deleteQuery.setExactMatch(true);
    assertEquals("Fail to execute delete query", OK.getStatusCode(), deleteProperty(deleteQuery).getStatus());
    assertTrue("Property should remain", propertyExist(property));
}
Also used : PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Property(com.axibase.tsd.api.model.property.Property) 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