Search in sources :

Example 11 with PropertyQuery

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

the class PropertyQueryTest method testLastDefault.

/**
 * #NoTicket
 */
@Test
public void testLastDefault() throws Exception {
    final Property property = new Property("query-type8", "query-entity8");
    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("t2", "tv2");
    lastProperty.setDate(getCurrentDate());
    insertPropertyCheck(lastProperty);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    String expected = jacksonMapper.writeValueAsString(Arrays.asList(property, lastProperty));
    String given = queryProperty(query).readEntity(String.class);
    assertTrue("Both properties should be returned if 'last' field is not specified", 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 12 with PropertyQuery

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

the class PropertyQueryTest method testEndDateAbsent.

/**
 * #NoTicket
 */
@Test
public void testEndDateAbsent() throws Exception {
    PropertyQuery query = new PropertyQuery("mock-type", "mock-entity");
    query.setStartDate("2016-05-25T05:00:00Z");
    Response response = queryProperty(query);
    assertEquals("Query should fail if endDate is not specified", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", ErrorTemplate.DATE_FILTER_COMBINATION_REQUIRED, extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Test(org.testng.annotations.Test)

Example 13 with PropertyQuery

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

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

the class PropertyQueryTest method testKeyMatchExactFalse.

/**
 * #NoTicket
 */
@Test
public void testKeyMatchExactFalse() throws Exception {
    final Property property = new Property("query-type11", "query-entity11");
    property.addTag("t1", "tv1");
    property.addKey("k1", "kv1");
    insertPropertyCheck(property);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), "*");
    query.setKey(property.getKey());
    query.setExactMatch(false);
    assertInsertedPropertyReturned(property, query);
}
Also used : PropertyQuery(com.axibase.tsd.api.model.property.PropertyQuery) Property(com.axibase.tsd.api.model.property.Property) Test(org.testng.annotations.Test)

Example 15 with PropertyQuery

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

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