Search in sources :

Example 11 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.

the class SeriesQueryTest method testGroupInterpolateNoTypeRaiseError.

@Issue("3324")
@Test
public void testGroupInterpolateNoTypeRaiseError() throws Exception {
    SeriesQuery query = new SeriesQuery("mock-entity", "mock-metric", MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    Group group = new Group(GroupType.SUM, new Period(99999, TimeUnit.QUARTER));
    group.setInterpolate(new AggregationInterpolate());
    query.setGroup(group);
    Response response = querySeries(query);
    assertEquals("Query with interpolation but without type should fail", BAD_REQUEST.getStatusCode(), response.getStatus());
    assertEquals("Error message mismatch", INTERPOLATE_TYPE_REQUIRED, extractErrorMessage(response));
}
Also used : Response(javax.ws.rs.core.Response) Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 12 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.

the class SeriesQueryTest method testXTextField.

@Issue("3480")
@Test(dataProvider = "dataTextProvider")
public void testXTextField(String text) throws Exception {
    String entityName = entity();
    String metricName = metric();
    String largeNumber = "10.1";
    Series series = new Series(entityName, metricName);
    Sample sample = Sample.ofDateDecimalText(MIN_STORABLE_DATE, new BigDecimal(largeNumber), text);
    series.addSamples(sample);
    insertSeriesCheck(Collections.singletonList(series));
    SeriesQuery seriesQuery = new SeriesQuery(series);
    List<Series> seriesList = querySeriesAsList(seriesQuery);
    assertEquals("Stored series are incorrect", Collections.singletonList(series), seriesList);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 13 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.

the class SeriesQueryTest method testSameDoubleSeriesQuery.

@Issue("4714")
@Test(description = "test same double series query")
public void testSameDoubleSeriesQuery() {
    SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query.setStartDate("2017-01-01T00:01:00Z");
    query.setEndDate("2017-01-01T00:04:00Z");
    List<Series> result = SeriesMethod.querySeriesAsList(query, query);
    assertEquals("Incorrect query result with two same series requests", Arrays.asList(TEST_SERIES3, TEST_SERIES3), result);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 14 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.

the class SeriesQueryTest method testEndTimeAggregationWithInterpolation.

@Issue("4867")
@Test(description = "test END_TIME period align aggregation with interpolation")
public void testEndTimeAggregationWithInterpolation() {
    SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
    query.setStartDate("2017-01-01T00:00:50Z");
    query.setEndDate("2017-01-01T00:03:30Z");
    Aggregate aggregate = new Aggregate(AggregationType.MAX, new Period(1, TimeUnit.MINUTE, PeriodAlignment.END_TIME));
    aggregate.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
    query.setAggregate(aggregate);
    List<Series> result = SeriesMethod.querySeriesAsList(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:30Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:02:30Z", new BigDecimal("3.0")));
    assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", 1, result.size());
    assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", expectedSeries, result.get(0));
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 15 with SeriesQuery

use of com.axibase.tsd.api.model.series.query.SeriesQuery in project atsd-api-test by axibase.

the class SeriesQueryTest method testSeriesQueryWithTextSample.

@Test
public void testSeriesQueryWithTextSample() throws Exception {
    Series series = Mocks.series();
    series.setSamples(Collections.singleton(Mocks.TEXT_SAMPLE));
    SeriesMethod.insertSeriesCheck(series);
    List<Series> resultSeriesList = SeriesMethod.querySeriesAsList(new SeriesQuery(series));
    String assertMessage = "SeriesList serialized as not expected!";
    assertEquals(assertMessage, Collections.singletonList(series), resultSeriesList);
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Test(org.testng.annotations.Test)

Aggregations

SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)157 Issue (io.qameta.allure.Issue)145 Test (org.testng.annotations.Test)145 Period (com.axibase.tsd.api.model.Period)43 BigDecimal (java.math.BigDecimal)43 Response (javax.ws.rs.core.Response)31 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)26 Series (com.axibase.tsd.api.model.series.Series)23 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)20 Metric (com.axibase.tsd.api.model.metric.Metric)13 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)8 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)8 Sample (com.axibase.tsd.api.model.series.Sample)7 Entity (com.axibase.tsd.api.model.entity.Entity)6 ArrayList (java.util.ArrayList)5 File (java.io.File)4 List (java.util.List)3 HashMap (java.util.HashMap)2 BaseMethod.compareJsonString (com.axibase.tsd.api.method.BaseMethod.compareJsonString)1 SeriesCheck (com.axibase.tsd.api.method.checks.SeriesCheck)1