use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.
the class SeriesQueryTest method testDateIntervalFieldEnoughToDetail.
@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToDetail() throws Exception {
Series series = new Series("entity-query-24", "metric-query-24");
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));
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));
}
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 SeriesQueryTest method testDateIntervalFieldEnoughToAggregate.
@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToAggregate() throws Exception {
final BigDecimal VALUE = new BigDecimal("1.0");
Series series = new Series("entity-query-26", "metric-query-26");
series.addSamples(Sample.ofDateDecimal("2014-01-01T00:00:00.000Z", VALUE));
insertSeriesCheck(Collections.singletonList(series));
SeriesQuery query = new SeriesQuery();
query.setEntity(series.getEntity());
query.setMetric(series.getMetric());
query.setInterval(new Interval(99999, TimeUnit.QUARTER));
Period period = new Period(99999, TimeUnit.QUARTER, PeriodAlignment.START_TIME);
query.setAggregate(new Aggregate(AggregationType.SUM, period));
List<Series> storedSeries = querySeriesAsList(query);
assertEquals("Response should contain only one series", 1, storedSeries.size());
List<Sample> data = storedSeries.get(0).getData();
assertEquals("Response should contain only one sample", 1, data.size());
assertEquals("Returned value does not match to expected SUM", VALUE, data.get(0).getValue());
}
use of com.axibase.tsd.api.model.series.query.Interval 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 Interval(300, TimeUnit.YEAR));
query.setStartDate(MIN_STORABLE_DATE);
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 SeriesQueryDateFilterTest method testIntervalZeroAndEndRaiseError.
@Issue("3030")
@Test(enabled = false)
public void testIntervalZeroAndEndRaiseError() throws Exception {
SeriesQuery query = new SeriesQuery("mockEntity", "mockMetric");
query.setInterval(new Interval(0, TimeUnit.HOUR));
query.setEndDate(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));
}
Aggregations