Search in sources :

Example 6 with AggregationInterpolate

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));
}
Also used : Response(javax.ws.rs.core.Response) Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 7 with AggregationInterpolate

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));
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 8 with AggregationInterpolate

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));
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 9 with AggregationInterpolate

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));
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 10 with AggregationInterpolate

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;
}
Also used : ArrayList(java.util.ArrayList) Period(com.axibase.tsd.api.model.Period) ArrayList(java.util.ArrayList) List(java.util.List) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) AggregationType(com.axibase.tsd.api.model.series.query.transformation.aggregate.AggregationType)

Aggregations

AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)12 Period (com.axibase.tsd.api.model.Period)8 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)7 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)7 Issue (io.qameta.allure.Issue)7 Test (org.testng.annotations.Test)7 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)5 AggregationType (com.axibase.tsd.api.model.series.query.transformation.aggregate.AggregationType)3 GroupType (com.axibase.tsd.api.model.series.query.transformation.group.GroupType)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Response (javax.ws.rs.core.Response)2 Series (com.axibase.tsd.api.model.series.Series)1 BigDecimal (java.math.BigDecimal)1