use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.
the class AnotherTradeSideTest method addTestCase.
private void addTestCase(boolean isAggregate, String function, String periodStr, String[] requestedSides, List<TestCase> testCases) {
Period period = Period.from(periodStr);
SeriesQuery query = query(isAggregate, function, period, requestedSides);
int seriesCount = expectedSeriesCount(isAggregate, requestedSides);
Set<String> expectedSides = expectedSides(isAggregate, requestedSides);
int expectedSamplesCount = expectedSamplesCount(period);
testCases.add(new TestCase(query, seriesCount, expectedSides, expectedSamplesCount));
}
use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.
the class SeriesQueryTest method testSameDoubleSeriesQueryWithAggregation.
@Issue("4714")
@Test(description = "test same double series query")
public void testSameDoubleSeriesQueryWithAggregation() {
SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query.setStartDate("2017-01-01T00:01:00Z");
query.setEndDate("2017-01-01T00:04:00Z");
query.setAggregate(new Aggregate(AggregationType.SUM, new Period(3, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
List<Series> seriesList = SeriesMethod.querySeriesAsList(query, query);
List<Series> result = new ArrayList<>();
for (Series series : seriesList) {
result.add(pullCheckedFields(series));
}
Series expectedSeries = new Series();
expectedSeries.setEntity(TEST_SERIES3.getEntity());
expectedSeries.setMetric(TEST_SERIES3.getMetric());
expectedSeries.setTags(Mocks.TAGS);
expectedSeries.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:00Z", new BigDecimal("6.0")));
assertEquals("Incorrect query result with two same series requests", Arrays.asList(expectedSeries, expectedSeries), result);
}
use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.
the class SeriesQueryTest method testEndTimeAggregationWithInterpolation.
@Issue("4867")
@Test(description = "test END_TIME period align aggregation with interpolation")
public void testEndTimeAggregationWithInterpolation() {
SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query.setStartDate("2017-01-01T00:00:50Z");
query.setEndDate("2017-01-01T00:03:30Z");
Aggregate aggregate = new Aggregate(AggregationType.MAX, new Period(1, TimeUnit.MINUTE, PeriodAlignment.END_TIME));
aggregate.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
query.setAggregate(aggregate);
List<Series> result = SeriesMethod.querySeriesAsList(query);
Series expectedSeries = new Series();
expectedSeries.setEntity(TEST_SERIES3.getEntity());
expectedSeries.setMetric(TEST_SERIES3.getMetric());
expectedSeries.setTags(Mocks.TAGS);
expectedSeries.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:30Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:02:30Z", new BigDecimal("3.0")));
assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", 1, result.size());
assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", expectedSeries, pullCheckedFields(result.get(0)));
}
use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.
the class SeriesQueryForecastAutoAggregateTest method testOfMatchTimeSpanBetweenSamplesAndPeriodCount.
@Issue("6171")
@Test(dependsOnMethods = "testResponseHaveForecastSeries", description = "Checks that forecast series is regular" + " and time span between samples is correct")
public void testOfMatchTimeSpanBetweenSamplesAndPeriodCount() {
List<Series> seriesList = querySeriesAsList(query);
Series series = seriesList.get(0);
List<Sample> samples = series.getData();
long timeStampPeriodMs = timeStampDifference(samples.get(0), samples.get(1));
for (int i = 2; i < samples.size(); i++) {
long timeSpan = timeStampDifference(samples.get(i - 1), samples.get(i));
if (timeSpan != timeStampPeriodMs) {
throw new AssertionError("Output series is irregular");
}
}
Period period = series.getAggregate().getPeriod();
long countPeriodMs = period.getUnit().toMilliseconds(period.getCount());
assertEquals(timeStampPeriodMs, countPeriodMs, "Count in period of aggregation not match time span between samples");
}
use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testAggregateLimit.
@Issue("4729")
@Test(description = "test query result with aggregate limit")
public void testAggregateLimit() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setAggregate(new Aggregate(AggregationType.MAX, new Period(5, TimeUnit.SECOND)));
query.setLimit(1);
query.setDirection("ASC");
Set<CheckedFields> actualFields = createCheckFields(querySeriesAsList(query));
CheckedFields series1 = new CheckedFields(TEST_ENTITY1, Arrays.asList(Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("103.0"))));
CheckedFields series2 = new CheckedFields(TEST_ENTITY2, Arrays.asList(Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("204.0"))));
Set<CheckedFields> expectedFields = collectCheckFields(series1, series2);
assertEquals(actualFields, expectedFields, "Incorrect query result with aggregate limit");
}
Aggregations