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);
}
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);
}
}
}
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);
}
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());
}
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)));
}
Aggregations