use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testEndTimeAggregation.
@Issue("4867")
@Test(description = "test END_TIME period align aggregation")
public void testEndTimeAggregation() {
SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query.setStartDate("2017-01-01T00:00:50Z");
query.setEndDate("2017-01-01T00:03:30Z");
query.setAggregate(new Aggregate(AggregationType.MAX, new Period(1, TimeUnit.MINUTE, PeriodAlignment.END_TIME)));
List<Series> result = SeriesMethod.querySeriesAsList(query);
Series expectedSeries = new Series();
expectedSeries.setEntity(TEST_SERIES3.getEntity());
expectedSeries.setMetric(TEST_SERIES3.getMetric());
expectedSeries.setTags(Mocks.TAGS);
expectedSeries.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:30Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:02:30Z", new BigDecimal("3.0")));
assertEquals("Incorrect query result with END_TIME period align aggregation", 1, result.size());
assertEquals("Incorrect query result with END_TIME period align aggregation", expectedSeries, result.get(0));
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testAggregateNoPeriodRaiseError.
@Issue("3324")
@Test
public void testAggregateNoPeriodRaiseError() throws Exception {
SeriesQuery query = new SeriesQuery("mock-entity", "mock-metric", MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
query.setAggregate(new Aggregate(AggregationType.SUM));
Response response = querySeries(query);
assertEquals("Aggregate query without period should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("Error message mismatch", String.format(AGGREGATE_NON_DETAIL_REQUIRE_PERIOD, query.getAggregate().getType()), extractErrorMessage(response));
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testDateIntervalFieldEnoughToGroup.
@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToGroup() throws Exception {
Series series = new Series("entity-query-25", "metric-query-25");
series.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 1));
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery query = new SeriesQuery();
query.setEntity(series.getEntity());
query.setMetric(series.getMetric());
query.setInterval(new Period(99999, TimeUnit.QUARTER));
query.setGroup(new Group(GroupType.SUM));
List<Series> storedSeries = querySeriesAsList(query);
final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
final String given = jacksonMapper.writeValueAsString(storedSeries);
assertTrue("Stored series does not match to inserted", compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testDoubleSeriesQueryDifferentAggregation.
@Issue("4714")
@Test(description = "test double series query with different transformation")
public void testDoubleSeriesQueryDifferentAggregation() {
SeriesQuery query1 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query1.setStartDate("2017-01-01T00:01:00Z");
query1.setEndDate("2017-01-01T00:04:00Z");
query1.setAggregate(new Aggregate(AggregationType.MAX, new Period(120, TimeUnit.SECOND, PeriodAlignment.START_TIME)));
SeriesQuery query2 = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query2.setStartDate("2017-01-01T00:01:00Z");
query2.setEndDate("2017-01-01T00:04:00Z");
query2.setAggregate(new Aggregate(AggregationType.AVG, new Period(3, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
List<Series> result = SeriesMethod.querySeriesAsList(query1, query2);
Series expectedSeries1 = new Series();
expectedSeries1.setEntity(TEST_SERIES3.getEntity());
expectedSeries1.setMetric(TEST_SERIES3.getMetric());
expectedSeries1.setTags(Mocks.TAGS);
expectedSeries1.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
Series expectedSeries2 = new Series();
expectedSeries2.setEntity(TEST_SERIES3.getEntity());
expectedSeries2.setMetric(TEST_SERIES3.getMetric());
expectedSeries2.setTags(Mocks.TAGS);
expectedSeries2.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("2.0")));
assertEquals("Incorrect query result with two series requests with different transformation", Sets.newHashSet(expectedSeries1, expectedSeries2), Sets.newHashSet(result));
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testDateFilterRangeIncludesStorableRange.
@Issue("3013")
@Test
public void testDateFilterRangeIncludesStorableRange() throws Exception {
String entityName = "e-query-range-16";
String metricName = "m-query-range-16";
BigDecimal v = new BigDecimal("7");
Series series = new Series(entityName, metricName);
series.addSamples(Sample.ofDateDecimal(MIN_STORABLE_DATE, v));
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery seriesQuery = new SeriesQuery(series.getEntity(), series.getMetric(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
List<Sample> data = querySeriesAsList(seriesQuery).get(0).getData();
assertEquals("Empty data for query interval that contains stored interval", 1, data.size());
assertEquals("Incorrect stored date", MIN_STORABLE_DATE, data.get(0).getRawDate());
assertEquals("Incorrect stored value", v, data.get(0).getValue());
}
Aggregations