use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryEntityExpressionTest method testErrorOnBadEntityExpression.
@Issue("3612")
@Test(dataProvider = "errorEntityExpressionProvider")
public static void testErrorOnBadEntityExpression(String expression) throws Exception {
SeriesQuery query = createTestQuery("*");
query.setEntityExpression(expression);
Response response = SeriesMethod.executeQueryRaw(Collections.singletonList(query));
Response.Status.Family statusFamily = response.getStatusInfo().getFamily();
String errMsg = "Wrong result status code, expected 4**, got " + response.getStatus();
errMsg = formatErrorMsg(errMsg, expression);
assertEquals(errMsg, Response.Status.Family.CLIENT_ERROR, statusFamily);
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumInterpolation.
@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#interpolation-1")
public void testExampleSumInterpolation() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
Group group = new Group(GroupType.SUM);
group.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
query.setGroup(group);
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 12), Sample.ofDateInteger("2016-06-25T08:00:05.000Z", 14), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:15.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:45.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:59.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.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method prepareDefaultQuery.
private SeriesQuery prepareDefaultQuery(String startDate, String endDate) {
SeriesQuery seriesQuery = new SeriesQuery();
seriesQuery.setMetric(GROUPED_METRIC);
seriesQuery.setEntities(Arrays.asList(FIRST_ENTITY, SECOND_ENTITY));
seriesQuery.setStartDate(startDate);
seriesQuery.setEndDate(endDate);
return seriesQuery;
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryLimitTest method testLastInsertedEntitySeriesLimit2.
@Issue("3211")
@Test
public void testLastInsertedEntitySeriesLimit2() throws Exception {
final int seriesLimit = 2;
SeriesQuery query = prepareSeriesQueryWithEntityPattern();
query.setEntity(DEFAULT_QUERY_LIMIT_ENTITY_PREFIX + String.valueOf(ENTITY_COUNT - 1));
query.setSeriesLimit(seriesLimit);
Response response = querySeries(query);
assertEquals("Fail to execute series query", OK.getStatusCode(), response.getStatus());
List<Series> seriesList = response.readEntity(new GenericType<List<Series>>() {
});
String message = String.format("%s series should be returned", seriesLimit);
assertEquals(message, seriesLimit, seriesList.size());
assertSampleCountMatch(seriesList, SAMPLES_COUNT);
assertFalse("All series should be for one entity", diffEntityCountGraterThan(seriesList, 1));
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryLimitTest method prepareSeriesQueryWithEntities.
private static SeriesQuery prepareSeriesQueryWithEntities() {
SeriesQuery query = new SeriesQuery();
query.setMetric(DEFAULT_QUERY_LIMIT_METRIC);
query.setEntities(entities);
query.setStartDate(MIN_QUERYABLE_DATE);
query.setEndDate(MAX_QUERYABLE_DATE);
return query;
}
Aggregations