use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testDateFilterRangeIntersectsStorableRangeEnding.
@Issue("3013")
@Test
public void testDateFilterRangeIntersectsStorableRangeEnding() throws Exception {
String entityName = "e-query-range-18";
String metricName = "m-query-range-18";
BigDecimal v = new BigDecimal("7");
Series series = new Series(entityName, metricName);
series.addSamples(Sample.ofDateDecimal(MIN_STORABLE_DATE, v));
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery seriesQuery = new SeriesQuery(series.getEntity(), series.getMetric(), MIN_STORABLE_DATE, MAX_QUERYABLE_DATE);
List<Sample> data = querySeriesAsList(seriesQuery).get(0).getData();
assertEquals("Empty data for query interval that intersects stored interval from right", 1, data.size());
assertEquals("Incorrect stored date", MIN_STORABLE_DATE, data.get(0).getRawDate());
assertEquals("Incorrect stored value", v, data.get(0).getValue());
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesCheck method seriesListIsInserted.
private boolean seriesListIsInserted(final List<Series> seriesList) throws Exception {
List<SeriesQuery> seriesQueryList = new ArrayList<>();
List<Series> transformedSeriesList = new ArrayList<>();
for (final Series series : seriesList) {
seriesQueryList.add(new SeriesQuery(series));
transformedSeriesList.add(series.normalize());
}
Response response = querySeries(seriesQueryList);
String expected = BaseMethod.getJacksonMapper().writeValueAsString(transformedSeriesList);
String actual = response.readEntity(String.class);
return compareJsonString(expected, actual);
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryDateFilterTest method testIntervalZeroAndStartRaiseError.
@Issue("3030")
@Test
public void testIntervalZeroAndStartRaiseError() throws Exception {
SeriesQuery query = new SeriesQuery("mockEntity", "mockMetric");
query.setInterval(new Period(0, TimeUnit.HOUR));
query.setStartDate(MIN_QUERYABLE_DATE);
Response response = querySeries(query);
assertEquals("Response code mismatch", BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals("Error message mismatch", DATE_FILTER_END_GREATER_START_REQUIRED, extractErrorMessage(response));
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryDateFilterTest method testIntervalAndStart.
@Issue("3030")
@Test
public void testIntervalAndStart() throws Exception {
Series series = new Series("datefilter-e-3", "datefilter-m-3");
series.addSamples(DATE_FILTER_DEFAULT_SAMPLE);
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery query = new SeriesQuery(series.getEntity(), series.getMetric());
query.setInterval(new Period(300, TimeUnit.YEAR));
query.setStartDate(MIN_STORABLE_DATE);
Response response = querySeries(query);
assertEquals("Response code mismatch", OK.getStatusCode(), response.getStatus());
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.SeriesQuery 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 Period(40, TimeUnit.YEAR));
Response response = querySeries(query);
assertEquals("Response code mismatch", OK.getStatusCode(), response.getStatus());
final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
final String given = response.readEntity(String.class);
assertTrue("Stored series mismatch", compareJsonString(expected, given));
}
Aggregations