Search in sources :

Example 46 with Property

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

the class PropertyQueryTest method testLimitWithKeyExpression.

@Issue("3110")
@Test
public void testLimitWithKeyExpression() throws Exception {
    final int limit = 1;
    final Property property = new Property("query-type57-c", "query-entity57-c");
    final String tag = "key1";
    property.addKey("uniq", tag);
    property.addTag("tag_key", "tag_value");
    insertPropertyCheck(property);
    final Property property2 = new Property();
    property2.setType(property.getType());
    property2.setEntity(property.getEntity());
    property2.addKey("uniq", tag.toUpperCase());
    property2.addTag("tag_key2", "tag_value2");
    insertPropertyCheck(property2);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.setKeyTagExpression("keys.uniq = '" + tag + "'");
    query.setLimit(limit);
    assertEquals("One property should be received", limit, calculateJsonArraySize(queryProperty(query).readEntity(String.class)));
    query.setKeyTagExpression("keys.uniq = '" + tag.toUpperCase() + "'");
    assertEquals("One property should be received", limit, 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 47 with Property

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

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

the class PropertyQueryTest method testKeyValueBoolean.

@Issue("2416")
@Test
public void testKeyValueBoolean() throws Exception {
    final Property property = new Property("query-type-67", "query-entity67");
    property.addTag("t1", "v1");
    property.addKey("k1", "true");
    insertPropertyCheck(property);
    Map<String, Object> query = new HashMap<>();
    query.put("type", property.getType());
    query.put("entity", property.getEntity());
    query.put("startDate", MIN_QUERYABLE_DATE);
    query.put("endDate", MAX_QUERYABLE_DATE);
    Map<String, Object> key = new HashMap<>();
    key.put("k1", true);
    query.put("key", key);
    assertStoredPropertyDoesNotMatchToInserted(property, query);
}
Also used : HashMap(java.util.HashMap) Property(com.axibase.tsd.api.model.property.Property) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 49 with Property

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

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

Aggregations

Property (com.axibase.tsd.api.model.property.Property)146 Test (org.testng.annotations.Test)143 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)94 Issue (io.qameta.allure.Issue)84 Response (javax.ws.rs.core.Response)23 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)10 PropertyCommand (com.axibase.tsd.api.model.command.PropertyCommand)10 HashMap (java.util.HashMap)9 Entity (com.axibase.tsd.api.model.entity.Entity)8 List (java.util.List)6 Period (com.axibase.tsd.api.model.Period)5 EntityGroup (com.axibase.tsd.api.model.entitygroup.EntityGroup)1 CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)1 Series (com.axibase.tsd.api.model.series.Series)1 BeforeClass (org.testng.annotations.BeforeClass)1