Search in sources :

Example 51 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class SeriesQueryGroupExampleTest method testExampleSumGroupAggregation.

@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#group-aggregation")
public void testExampleSumGroupAggregation() throws Exception {
    final Period period = new Period(10, TimeUnit.SECOND);
    SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
    query.setGroup(new Group(GroupType.SUM, period));
    query.setAggregate(new Aggregate(AggregationType.SUM, period));
    List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 15), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 21), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:40.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:50.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) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 52 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class SeriesQueryGroupExampleTest method testExampleSumGroupToAggregation.

@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#group-aggregation")
public void testExampleSumGroupToAggregation() throws Exception {
    SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
    query.setGroup(new Group(GroupType.SUM, new Period(1, TimeUnit.MILLISECOND), 0));
    query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND), 1));
    List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 2), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 2), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 1), Sample.ofDateInteger("2016-06-25T08:00:40.000Z", 1), Sample.ofDateInteger("2016-06-25T08:00:50.000Z", 1));
    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) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 53 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class SeriesQueryMultipleAggregationTest method createSeriesQuery.

private SeriesQuery createSeriesQuery(AggregationType function) {
    SeriesQuery query = new SeriesQuery(TEST_ENTITY, TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:25:00Z");
    Aggregate aggregate = new Aggregate(function, new Period(1000, TimeUnit.SECOND, PeriodAlignment.START_TIME));
    aggregate.setThreshold(new Threshold(300, 1300));
    query.setAggregate(aggregate);
    return query;
}
Also used : 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) Threshold(com.axibase.tsd.api.model.series.query.transformation.aggregate.Threshold)

Example 54 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class ApplyTest method interpolateParamVariants.

@DataProvider(name = "interpolateVariantsProvider")
private static Object[][] interpolateParamVariants() {
    ArrayList<List<String>> params = new ArrayList<>();
    params.add(singletonList(new Period(1, TimeUnit.MINUTE).toString()));
    params.add(enumStringLists(InterpolateFunction.class));
    params.add(enumStringLists(Boundary.class));
    params.add(FillMode.stringValues());
    params.add(enumStringLists(Alignment.class));
    Set<ArrayList<String>> variants = generateSetOfParams(params);
    StringBuilder builder = new StringBuilder();
    int j = 0;
    Object[][] result = new Object[variants.size()][1];
    for (ArrayList<String> variant : variants) {
        builder.setLength(0);
        int variantSize = variant.size();
        for (int i = 0; i < variantSize; i++) {
            String element = variant.get(i);
            if (element == null) {
                continue;
            } else {
                builder.append(String.format("%s, ", element));
            }
        }
        builder.setLength(builder.length() - 2);
        result[j][0] = builder.toString();
        j++;
    }
    return result;
}
Also used : Period(com.axibase.tsd.api.model.Period) Boundary(com.axibase.tsd.api.model.sql.function.interpolate.Boundary) Alignment(com.axibase.tsd.api.model.sql.function.interpolate.Alignment) InterpolateFunction(com.axibase.tsd.api.model.sql.function.interpolate.InterpolateFunction) Collections.singletonList(java.util.Collections.singletonList) DataProvider(org.testng.annotations.DataProvider)

Aggregations

Period (com.axibase.tsd.api.model.Period)54 Test (org.testng.annotations.Test)49 Issue (io.qameta.allure.Issue)47 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)43 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)25 BigDecimal (java.math.BigDecimal)23 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)14 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)8 Response (javax.ws.rs.core.Response)7 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)6 List (java.util.List)6 Property (com.axibase.tsd.api.model.property.Property)5 MessageQuery (com.axibase.tsd.api.model.message.MessageQuery)4 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)4 Message (com.axibase.tsd.api.model.message.Message)3 Series (com.axibase.tsd.api.model.series.Series)3 Metric (com.axibase.tsd.api.model.metric.Metric)2 Threshold (com.axibase.tsd.api.model.series.query.transformation.aggregate.Threshold)1 Interpolate (com.axibase.tsd.api.model.series.query.transformation.interpolate.Interpolate)1 Alignment (com.axibase.tsd.api.model.sql.function.interpolate.Alignment)1