use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.
the class SeriesQueryDateFilterTest method testIntervalOnly.
@Issue("3030")
@Test
public void testIntervalOnly() throws Exception {
Series series = new Series("datefilter-e-1", "datefilter-m-1");
series.addSamples(DATE_FILTER_DEFAULT_SAMPLE);
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery query = new SeriesQuery(series.getEntity(), series.getMetric());
query.setInterval(new Interval(40, TimeUnit.YEAR));
Response response = querySeries(query);
assertSame("Response code mismatch", Response.Status.Family.SUCCESSFUL, Util.responseFamily(response));
final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
final String given = response.readEntity(String.class);
assertTrue("Stored series mismatch", compareJsonString(expected, given));
}
use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.
the class TokenSeriesTest method testQueryMethod.
@Test(description = "Tests series query endpoint with tokens.")
@Issue("6052")
public void testQueryMethod() throws Exception {
String queryURL = "/series/query";
SeriesQuery query = new SeriesQuery(entity, metric).setStartDate(SAMPLE_TIME).setInterval(new Interval(1, TimeUnit.DAY));
String queryToken = TokenRepository.getToken(username, HttpMethod.POST, queryURL);
Response response = querySeries(Collections.singletonList(query), queryToken);
assertTrue(compareJsonString(Util.prettyPrint(Collections.singletonList(series)), response.readEntity(String.class), false));
}
use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.
the class SeriesQueryForecastTimeFilterTest method testData.
@DataProvider(parallel = false)
public Object[][] testData() {
Interval days_2 = new Interval(2, TimeUnit.DAY);
Interval days_3 = new Interval(3, TimeUnit.DAY);
return new Object[][] { { new Horizon().setLength(111), false, false, 10 * 24 * 60, 111 }, // - 24*60: first period (= 1 day) of Holt-Winters reconstructed series is always zero, and not included in response
{ new Horizon().setLength(111), true, false, 11 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setLength(111), true, true, 9 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setLength(2 * 24 * 60), true, true, 9 * 8 * 60 - 24 * 60, 2 * 24 * 60 }, { new Horizon().setInterval(days_2), false, false, 10 * 24 * 60, 2 * 24 * 60 }, // -1: latest timestamp 17:59 is not included because it equals to end time of 2 day interval
{ new Horizon().setInterval(days_2), true, false, 11 * 8 * 60 - 24 * 60, 2 * 8 * 60 - 1 }, { new Horizon().setInterval(days_2), true, true, 9 * 8 * 60 - 24 * 60, 1 * 8 * 60 }, // +1: forecastEndTime implemented "inclusive"
{ new Horizon().setEndDate("2021-04-18T00:00:00Z"), false, false, 10 * 24 * 60, 2 * 24 * 60 + 1 }, { new Horizon().setEndDate("2021-04-18T00:00:00Z"), true, false, 11 * 8 * 60 - 24 * 60, 2 * 8 * 60 }, { new Horizon().setEndDate("2021-04-18T00:00:00Z"), true, true, 9 * 8 * 60 - 24 * 60, 1 * 8 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(111), false, false, 9 * 24 * 60, 111 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(111), true, false, 10 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(111), true, true, 8 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(3 * 24 * 60), true, true, 8 * 8 * 60 - 24 * 60, 3 * 24 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setInterval(days_3), false, false, 9 * 24 * 60, 3 * 24 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setInterval(days_3), true, false, 10 * 8 * 60 - 24 * 60, 3 * 8 * 60 - 1 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setInterval(days_3), true, true, 8 * 8 * 60 - 24 * 60, 2 * 8 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setEndDate("2021-04-18T00:00:00Z"), false, false, 9 * 24 * 60, 3 * 24 * 60 + 1 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setEndDate("2021-04-18T00:00:00Z"), true, false, 10 * 8 * 60 - 24 * 60, 3 * 8 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setEndDate("2021-04-18T00:00:00Z"), true, true, 8 * 8 * 60 - 24 * 60, 2 * 8 * 60 } };
}
use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.
the class SeriesQueryForecastTimeFilterTest method buildForecastSettings.
private Forecast buildForecastSettings() {
HoltWintersSettings hwSettings = new HoltWintersSettings().setAlpha(0.5).setBeta(0.5).setGamma(0.5).setAuto(false).setPeriod(new Period(1, TimeUnit.DAY));
List<SeriesType> include = Arrays.asList(SeriesType.RECONSTRUCTED, SeriesType.FORECAST);
return new Forecast().setHw(hwSettings).setInclude(include).setScoreInterval(new Interval(1, TimeUnit.DAY));
}
use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.
the class SeriesQueryTest method testDateIntervalFieldEnoughToGroup.
@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToGroup() throws Exception {
Series series = new Series("entity-query-25", "metric-query-25");
series.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 1));
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery query = new SeriesQuery();
query.setEntity(series.getEntity());
query.setMetric(series.getMetric());
query.setInterval(new Interval(99999, TimeUnit.QUARTER));
query.setGroup(new Group(GroupType.SUM));
List<Series> storedSeries = querySeriesAsList(query);
final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
final String given = jacksonMapper.writeValueAsString(storedSeries);
assertTrue("Stored series does not match to inserted", compareJsonString(expected, given));
}
Aggregations