use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class MessageQueryStatsTest method testAggregateUnknownRaiseError.
@Issue("2945")
@Test
public void testAggregateUnknownRaiseError() throws Exception {
MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
statsQuery.setAggregate(new Aggregate(AggregationType.SUM));
Response response = queryMessageStats(statsQuery);
assertEquals("Query with unknown aggregate type should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class MessageQueryStatsTest method testAggregateDetail.
@Issue("2945")
@Test(enabled = false)
public void testAggregateDetail() throws Exception {
MessageStatsQuery statsQuery = prepareSimpleMessageStatsQuery(MESSAGE_STATS_ENTITY);
statsQuery.setAggregate(new Aggregate(AggregationType.DETAIL));
List<Series> messageStatsList = queryMessageStatsReturnSeries(statsQuery);
assertEquals("Response should contain only 1 series", 1, messageStatsList.size());
List<Sample> samples = messageStatsList.get(0).getData();
assertEquals("Response should contain only 1 sample", 1, samples.size());
assertEquals("Message count mismatch", new BigDecimal(DATES.size()), samples.get(0).getValue());
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testAggregateLimit.
@Issue("4729")
@Test(description = "test query result with aggregate limit")
public void testAggregateLimit() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setAggregate(new Aggregate(AggregationType.MAX, new Period(5, TimeUnit.SECOND)));
query.setLimit(1);
query.setDirection("ASC");
List<Series> result = querySeriesAsList(query);
Series expectedSeries1 = createSeries(TEST_ENTITY1, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("103.0")));
Series expectedSeries2 = createSeries(TEST_ENTITY2, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("204.0")));
assertEquals(result, Arrays.asList(expectedSeries1, expectedSeries2), "Incorrect query result with aggregate limit");
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testAggregateOrder.
@Issue("4729")
@Test(dataProvider = "provideOrders", description = "test query result with aggregate")
public void testAggregateOrder(Integer order) {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
Aggregate aggregate = new Aggregate(AggregationType.MIN, new Period(10, TimeUnit.SECOND));
if (order != null) {
aggregate.setOrder(order);
}
query.setAggregate(aggregate);
List<Series> result = querySeriesAsList(query);
Series expectedSeries1 = createSeries(TEST_ENTITY1, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("101.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("111.0")));
Series expectedSeries2 = createSeries(TEST_ENTITY2, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("200.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("210.0")));
assertEquals(result, Arrays.asList(expectedSeries1, expectedSeries2), "Incorrect query result with aggregate");
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testDateIntervalFieldEnoughToAggregate.
@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToAggregate() throws Exception {
final BigDecimal VALUE = new BigDecimal("1.0");
Series series = new Series("entity-query-26", "metric-query-26");
series.addSamples(Sample.ofDateDecimal("2014-01-01T00:00:00.000Z", VALUE));
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery query = new SeriesQuery();
query.setEntity(series.getEntity());
query.setMetric(series.getMetric());
Period interval = new Period(99999, TimeUnit.QUARTER);
query.setInterval(interval);
query.setAggregate(new Aggregate(AggregationType.SUM, interval));
List<Series> storedSeries = querySeriesAsList(query);
assertEquals("Response should contain only one series", 1, storedSeries.size());
List<Sample> data = storedSeries.get(0).getData();
assertEquals("Response should contain only one sample", 1, data.size());
assertEquals("Returned value does not match to expected SUM", VALUE, data.get(0).getValue());
}
Aggregations