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));
}
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));
}
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;
}
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;
}
Aggregations