use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate 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.transformation.aggregate.Aggregate 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.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testAggregateInterpolateNoTypeRaiseError.
@Issue("3324")
@Test
public void testAggregateInterpolateNoTypeRaiseError() throws Exception {
SeriesQuery query = new SeriesQuery("mock-entity", "mock-metric", MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
Aggregate aggregate = new Aggregate(AggregationType.SUM, new Period(99999, TimeUnit.QUARTER));
aggregate.setInterpolate(new AggregationInterpolate());
query.setAggregate(aggregate);
Response response = querySeries(query);
assertEquals("Query with interpolation but without type should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("Error message mismatch", INTERPOLATE_TYPE_REQUIRED, extractErrorMessage(response));
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testDoubleSeriesQueryDifferentAggregationPeriod.
@Issue("4714")
@Test(description = "test double series query with different transformation period")
public void testDoubleSeriesQueryDifferentAggregationPeriod() {
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(2, TimeUnit.MINUTE, 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.MAX, new Period(60, TimeUnit.SECOND, 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("1.0")), Sample.ofDateDecimal("2017-01-01T00:02: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")), Sample.ofDateDecimal("2017-01-01T00:03:00Z", new BigDecimal("3.0")));
assertEquals("Incorrect query result with two series requests with different transformation period", Sets.newHashSet(expectedSeries1, expectedSeries2), Sets.newHashSet(result));
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testDefaultOrderRateAggregate.
@Issue("4729")
@Test(description = "test query result with default Group/Aggregate order")
public void testDefaultOrderRateAggregate() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setRate(new Rate(new Period(5, TimeUnit.SECOND)));
query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND)));
List<Series> result = querySeriesAsList(query);
Series expectedSeries1 = createSeries(TEST_ENTITY1, Sample.ofDateInteger("2017-01-01T00:00:00.000Z", 4), Sample.ofDateInteger("2017-01-01T00:00:10.000Z", 5));
Series expectedSeries2 = createSeries(TEST_ENTITY2, Sample.ofDateInteger("2017-01-01T00:00:00.000Z", 4), Sample.ofDateInteger("2017-01-01T00:00:10.000Z", 5));
assertEquals(result, Arrays.asList(expectedSeries1, expectedSeries2), "Incorrect query result with default Rate/Aggregate order");
}
Aggregations