Search in sources :

Example 1 with SeriesSearchQuery

use of com.axibase.tsd.api.model.series.search.SeriesSearchQuery in project atsd-api-test by axibase.

the class SeriesSearchTest method testLimitOffset.

@Issue("4404")
@Test(description = "Test limit and offset options are working")
public void testLimitOffset() {
    SeriesSearchQuery query = new SeriesSearchQuery("sst_*");
    query.addEntityFields(entityFields);
    query.addEntityTags("*");
    query.addMetricFields(metricFields);
    query.addMetricTags("*");
    query.setLimit(2);
    query.setOffset(1);
    Set<SeriesSearchResultRecord> result = Sets.newHashSet(Arrays.asList(resultRecord2, resultRecord3));
    checkQueryWithoutRelevance(query, result);
}
Also used : SeriesSearchResultRecord(com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord) SeriesSearchQuery(com.axibase.tsd.api.model.series.search.SeriesSearchQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with SeriesSearchQuery

use of com.axibase.tsd.api.model.series.search.SeriesSearchQuery in project atsd-api-test by axibase.

the class SeriesSearchTest method testDatePrecision.

@Issue("4666")
@Test(description = "Test createdDate and lastInsertDate fields format")
public void testDatePrecision() throws IOException {
    SeriesSearchQuery query = new SeriesSearchQuery("sst_22*");
    query.addEntityFields("createdDate,lastInsertDate");
    query.addMetricFields("createdDate,lastInsertDate");
    Response response = SeriesMethod.searchRawSeries(query);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode resultNode = mapper.readTree(response.readEntity(String.class));
    SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss.SSS'Z'");
    List<JsonNode> dateNodes = new ArrayList<>();
    dateNodes.addAll(resultNode.findValues("createdDate"));
    dateNodes.addAll(resultNode.findValues("lastInsertDate"));
    assertEquals(dateNodes.size(), 4, "Incorrect fields count");
    for (JsonNode node : dateNodes) {
        try {
            dateFormat.parse(node.asText());
        } catch (ParseException e) {
            fail("Incorrect date format", e);
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) SeriesSearchQuery(com.axibase.tsd.api.model.series.search.SeriesSearchQuery) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with SeriesSearchQuery

use of com.axibase.tsd.api.model.series.search.SeriesSearchQuery in project atsd-api-test by axibase.

the class SeriesSearchTest method testAllFields.

@Issue("4404")
@Test(description = "Test all fields returned")
public void testAllFields() {
    Entity expectedEntity = EntityMethod.getEntity(resultRecord4.getEntity().getName());
    Metric expectedMetric = MetricMethod.getMetric(resultRecord4.getMetric().getName());
    SeriesSearchQuery query = new SeriesSearchQuery("sst_22*");
    query.addEntityFields("*");
    query.addEntityTags("*");
    query.addMetricFields("*");
    query.addMetricTags("*");
    SeriesSearchResult result = SeriesMethod.searchSeries(query);
    SeriesSearchResultRecord[] resultRecords = result.getData();
    assertTrue(resultRecords != null && resultRecords.length == 1, "Incorrect series count");
    SeriesSearchResultRecord resultRecord = resultRecords[0];
    Entity resultEntity = resultRecord.getEntity();
    Metric resultMetric = resultRecord.getMetric();
    assertEquals(resultEntity, expectedEntity);
    assertEquals(resultMetric, expectedMetric);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) SeriesSearchResultRecord(com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord) SeriesSearchQuery(com.axibase.tsd.api.model.series.search.SeriesSearchQuery) Metric(com.axibase.tsd.api.model.metric.Metric) SeriesSearchResult(com.axibase.tsd.api.model.series.search.SeriesSearchResult) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with SeriesSearchQuery

use of com.axibase.tsd.api.model.series.search.SeriesSearchQuery in project atsd-api-test by axibase.

the class SeriesSearchTest method testQuery.

private void testQuery(Filter<SeriesSearchResultRecord> filter) {
    SeriesSearchQuery query = new SeriesSearchQuery(filter.getExpression());
    query.addEntityFields(entityFields);
    query.addEntityTags("*");
    query.addMetricFields(metricFields);
    query.addMetricTags("*");
    checkQueryWithoutRelevance(query, filter.getExpectedResultSet());
}
Also used : SeriesSearchQuery(com.axibase.tsd.api.model.series.search.SeriesSearchQuery)

Example 5 with SeriesSearchQuery

use of com.axibase.tsd.api.model.series.search.SeriesSearchQuery in project atsd-api-test by axibase.

the class SeriesSearchTest method testFieldsTags.

@Issue("4404")
@Test(description = "Test explicitly requested fields and tags are returned")
public void testFieldsTags() {
    SeriesSearchQuery query = new SeriesSearchQuery("sst_1*");
    query.addEntityFields("interpolate", "timezone");
    query.addEntityTags("sst_11_entity_tag");
    query.addMetricFields("datatype", "timeprecision");
    query.addMetricTags("sst_11_metric_tag");
    Entity entity1 = new Entity().setName(resultRecord1.getEntity().getName()).setLabel(resultRecord1.getEntity().getLabel()).setInterpolationMode(resultRecord1.getEntity().getInterpolationMode()).setTimeZoneID(resultRecord1.getEntity().getTimeZoneID());
    Metric metirc1 = new Metric().setName(resultRecord1.getMetric().getName()).setLabel(resultRecord1.getMetric().getLabel()).setDataType(resultRecord1.getMetric().getDataType()).setTimePrecision(resultRecord1.getMetric().getTimePrecision());
    SeriesSearchResultRecord expectedResult1 = new SeriesSearchResultRecord(entity1, metirc1, resultRecord1.getSeriesTags(), 1.0);
    Entity entity2 = new Entity().setName(resultRecord3.getEntity().getName()).setLabel(resultRecord3.getEntity().getLabel()).setInterpolationMode(resultRecord3.getEntity().getInterpolationMode()).setTimeZoneID(resultRecord3.getEntity().getTimeZoneID()).setTags(resultRecord3.getEntity().getTags());
    Metric metirc2 = new Metric().setName(resultRecord3.getMetric().getName()).setLabel(resultRecord3.getMetric().getLabel()).setDataType(resultRecord3.getMetric().getDataType()).setTimePrecision(resultRecord3.getMetric().getTimePrecision()).setTags(resultRecord3.getMetric().getTags());
    SeriesSearchResultRecord expectedResult3 = new SeriesSearchResultRecord(entity2, metirc2, resultRecord3.getSeriesTags(), 1.0);
    SeriesSearchResultRecord[] expectedResult = { expectedResult1, expectedResult3 };
    checkQueryWithoutRelevance(query, Sets.newHashSet(Arrays.asList(expectedResult)));
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) SeriesSearchResultRecord(com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord) SeriesSearchQuery(com.axibase.tsd.api.model.series.search.SeriesSearchQuery) Metric(com.axibase.tsd.api.model.metric.Metric) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

SeriesSearchQuery (com.axibase.tsd.api.model.series.search.SeriesSearchQuery)5 Issue (io.qameta.allure.Issue)4 BeforeTest (org.testng.annotations.BeforeTest)4 Test (org.testng.annotations.Test)4 SeriesSearchResultRecord (com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord)3 Entity (com.axibase.tsd.api.model.entity.Entity)2 Metric (com.axibase.tsd.api.model.metric.Metric)2 SeriesSearchResult (com.axibase.tsd.api.model.series.search.SeriesSearchResult)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Response (javax.ws.rs.core.Response)1