use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryTest method testGroupInterpolateNoTypeRaiseError.
@Issue("3324")
@Test
public void testGroupInterpolateNoTypeRaiseError() throws Exception {
SeriesQuery query = new SeriesQuery("mock-entity", "mock-metric", MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
Group group = new Group(GroupType.SUM, new Period(99999, TimeUnit.QUARTER));
group.setInterpolate(new AggregationInterpolate());
query.setGroup(group);
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.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumExtendFalse.
@Issue("2997")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#no-aggregation")
public void testExampleSumExtendFalse() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
Group group = new Group(GroupType.SUM);
final AggregationInterpolate interpolate = new AggregationInterpolate(AggregationInterpolateType.NONE);
interpolate.setExtend(false);
group.setInterpolate(interpolate);
query.setGroup(group);
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 12), Sample.ofDateInteger("2016-06-25T08:00:05.000Z", 3), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 5), Sample.ofDateInteger("2016-06-25T08:00:15.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:45.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:59.000Z", 19));
List<Series> groupedSeries = querySeriesAsList(query);
assertEquals("Response should contain only one series", 1, groupedSeries.size());
List<Sample> givenSamples = groupedSeries.get(0).getData();
final String actual = jacksonMapper.writeValueAsString(givenSamples);
final String expected = jacksonMapper.writeValueAsString(expectedSamples);
assertTrue("Grouped series do not match to expected", compareJsonString(expected, actual));
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumExtendTrue.
@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#extend")
public void testExampleSumExtendTrue() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:01Z", "2016-06-25T08:01:00Z");
Group group = new Group(GroupType.SUM);
final AggregationInterpolate interpolate = new AggregationInterpolate(AggregationInterpolateType.NONE);
interpolate.setExtend(true);
group.setInterpolate(interpolate);
query.setGroup(group);
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:05.000Z", 11), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 13), Sample.ofDateInteger("2016-06-25T08:00:15.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:45.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:59.000Z", 24));
List<Series> groupedSeries = querySeriesAsList(query);
assertEquals("Response should contain only one series", 1, groupedSeries.size());
List<Sample> givenSamples = groupedSeries.get(0).getData();
final String actual = jacksonMapper.writeValueAsString(givenSamples);
final String expected = jacksonMapper.writeValueAsString(expectedSamples);
assertTrue("Grouped series do not match to expected", compareJsonString(expected, actual));
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumExtendNull.
@Issue("2997")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#no-aggregation")
public void testExampleSumExtendNull() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
Group group = new Group(GroupType.SUM);
final AggregationInterpolate interpolate = new AggregationInterpolate(AggregationInterpolateType.NONE);
group.setInterpolate(interpolate);
query.setGroup(group);
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 12), Sample.ofDateInteger("2016-06-25T08:00:05.000Z", 3), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 5), Sample.ofDateInteger("2016-06-25T08:00:15.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:45.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:59.000Z", 19));
List<Series> groupedSeries = querySeriesAsList(query);
assertEquals("Response should contain only one series", 1, groupedSeries.size());
List<Sample> givenSamples = groupedSeries.get(0).getData();
final String actual = jacksonMapper.writeValueAsString(givenSamples);
final String expected = jacksonMapper.writeValueAsString(expectedSamples);
assertTrue("Grouped series do not match to expected", compareJsonString(expected, actual));
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryTransformationWithDifferentForecastTest method generateAggregationSet.
private List<Aggregate> generateAggregationSet() {
List<Aggregate> aggregates = new ArrayList<>();
List<List<AggregationType>> setsAggregationType = Arrays.asList(Arrays.asList(AggregationType.AVG, AggregationType.SUM, AggregationType.FIRST), Arrays.asList(AggregationType.AVG, AggregationType.SUM, AggregationType.FIRST, AggregationType.DETAIL));
Period period = new Period(AGGREGATION_PERIOD_COUNT, TimeUnit.MINUTE, PeriodAlignment.START_TIME);
AggregationInterpolate interp = new AggregationInterpolate(AggregationInterpolateType.LINEAR, true);
for (List<AggregationType> setAggregationType : setsAggregationType) {
aggregates.add(new Aggregate().setPeriod(period).setInterpolate(interp).setTypes(setAggregationType));
}
return aggregates;
}
Aggregations