Search in sources :

Example 1 with Group

use of com.axibase.tsd.api.model.series.query.transformation.group.Group 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 2 with Group

use of com.axibase.tsd.api.model.series.query.transformation.group.Group in project atsd-api-test by axibase.

the class SeriesQueryAggregateGroupOrderRateTest method testDefaultOrderGroupAggregate.

@Issue("4729")
@Test(description = "test query result with default Group/Aggregate order")
public void testDefaultOrderGroupAggregate() {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND)));
    query.setGroup(new Group(GroupType.MAX, new Period(5, TimeUnit.SECOND)));
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("2.0")));
    assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with default Group/Aggregate order");
}
Also used : 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) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 3 with Group

use of com.axibase.tsd.api.model.series.query.transformation.group.Group in project atsd-api-test by axibase.

the class SeriesQueryGroupExampleTest method testExampleSumInterpolation.

@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#interpolation-1")
public void testExampleSumInterpolation() throws Exception {
    SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
    Group group = new Group(GroupType.SUM);
    group.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
    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", 14), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 16), 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 4 with Group

use of com.axibase.tsd.api.model.series.query.transformation.group.Group in project atsd-api-test by axibase.

the class SeriesQueryAggregateGroupOrderRateTest method testGroupOrder.

@Issue("4729")
@Test(dataProvider = "provideOrders", description = "test query result with group")
public void testGroupOrder(Integer order) {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    Group group = new Group(GroupType.MAX, new Period(5, TimeUnit.SECOND));
    if (order != null) {
        group.setOrder(order);
    }
    query.setGroup(group);
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("204.0")), Sample.ofDateDecimal("2017-01-01T00:00:05.000Z", new BigDecimal("208.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("214.0")), Sample.ofDateDecimal("2017-01-01T00:00:15.000Z", new BigDecimal("218.0")));
    assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with group");
}
Also used : 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) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with Group

use of com.axibase.tsd.api.model.series.query.transformation.group.Group in project atsd-api-test by axibase.

the class SeriesQueryAggregateGroupOrderRateTest method testGroupLimit.

@Issue("4729")
@Test(description = "test query result with group limit")
public void testGroupLimit() {
    SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
    query.setGroup(new Group(GroupType.COUNT, new Period(10, TimeUnit.SECOND)));
    query.setLimit(1);
    query.setDirection("ASC");
    List<Series> result = querySeriesAsList(query);
    Series expectedSeries = createSeries("*", Sample.ofDateInteger("2017-01-01T00:00:00.000Z", 2));
    assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with group limit");
}
Also used : 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) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)20 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)20 Issue (io.qameta.allure.Issue)20 Test (org.testng.annotations.Test)19 Period (com.axibase.tsd.api.model.Period)14 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)7 BigDecimal (java.math.BigDecimal)6 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)5 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)4 Response (javax.ws.rs.core.Response)1