Search in sources :

Example 36 with Property

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

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

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

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

the class PropertyQueryTest method testKeyTagExpressionAND.

@Issue("2908")
@Test
public void testKeyTagExpressionAND() throws Exception {
    final Property property = new Property("query-type44", "query-entity44");
    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");
    property2.addKey("k2", "kv2");
    insertPropertyCheck(property2);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.setKeyTagExpression("tags.t1 == 'tv1' AND keys.k2 == 'kv2'");
    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 40 with Property

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

the class PropertyQueryTest method testLastTrue.

/**
 * #NoTicket
 */
@Test
public void testLastTrue() throws Exception {
    final Property property = new Property("query-type6", "query-entity6");
    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);
    PropertyQuery query = prepareSimplePropertyQuery(property.getType(), property.getEntity());
    query.setLast(true);
    String expected = jacksonMapper.writeValueAsString(Collections.singletonList(lastProperty));
    String given = queryProperty(query).readEntity(String.class);
    assertTrue("Only last property should be returned if 'last' field is set to 'true'", 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)

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