use of com.axibase.tsd.api.model.series.query.SeriesQuery 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 Period(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.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testExactMatchIgnoresReservedVersioningTags.
@Issue("3770")
@Test
public void testExactMatchIgnoresReservedVersioningTags() throws Exception {
String metricName = metric();
Metric metric = new Metric(metricName);
metric.setVersioned(true);
final int insertedVersionsCount = 3;
Series series = new Series(entity(), metricName);
MetricMethod.createOrReplaceMetricCheck(metric);
for (int i = 0; i < insertedVersionsCount; i++) {
series.setSamples(Collections.singleton(Sample.ofDateInteger(Mocks.ISO_TIME, i)));
SeriesMethod.insertSeriesCheck(Collections.singletonList(series));
}
SeriesQuery query = new SeriesQuery(series);
query.setVersioned(true);
query.setExactMatch(true);
List<Series> receivedSeries = querySeriesAsList(query);
int receivedVersionsCount = receivedSeries.get(0).getData().size();
assertEquals("Number of received versions mismatched", insertedVersionsCount, receivedVersionsCount);
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testLastSeriesWithText.
@Issue("3860")
@Test
public void testLastSeriesWithText() throws Exception {
Series series = Mocks.series();
series.setSamples(Collections.singleton(Mocks.TEXT_SAMPLE));
SeriesMethod.insertSeriesCheck(series);
SeriesQuery query = new SeriesQuery(series);
query.setLimit(1);
List<Series> resultSeriesList = SeriesMethod.querySeriesAsList(query);
assertEquals("Response doesn't match the expected", Collections.singletonList(series), resultSeriesList);
}
use of com.axibase.tsd.api.model.series.query.SeriesQuery 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> result = SeriesMethod.querySeriesAsList(query, 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: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.series.query.SeriesQuery in project atsd-api-test by axibase.
the class SeriesQueryTest method testXTextFieldLastVersion.
@Issue("3480")
@Test
public void testXTextFieldLastVersion() throws Exception {
String entityName = "e-text-overwritten-versioning-1";
String metricName = "m-text-overwritten-versioning-1";
Series series = new Series(entityName, metricName);
Metric metric = new Metric(metricName);
metric.setVersioned(true);
MetricMethod.createOrReplaceMetricCheck(metric);
String[] data = new String[] { "1", "2" };
for (String x : data) {
Sample sample = Sample.ofDateIntegerText("2016-10-11T13:00:00.000Z", 1, x);
series.setSamples(Collections.singleton(sample));
insertSeriesCheck(Collections.singletonList(series));
}
SeriesQuery seriesQuery = new SeriesQuery(series);
List<Series> seriesList = querySeriesAsList(seriesQuery);
assertFalse("No series", seriesList.isEmpty());
assertFalse("No series data", seriesList.get(0).getData().isEmpty());
String received = seriesList.get(0).getData().get(0).getText();
assertEquals("Last version of text field incorrect", data[data.length - 1], received);
}
Aggregations