Search in sources :

Example 36 with SeriesQuery

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());
}
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 37 with SeriesQuery

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);
}
Also used : Response(javax.ws.rs.core.Response) SeriesMethod.querySeries(com.axibase.tsd.api.method.series.SeriesMethod.querySeries) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) ArrayList(java.util.ArrayList) BaseMethod.compareJsonString(com.axibase.tsd.api.method.BaseMethod.compareJsonString)

Example 38 with SeriesQuery

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));
}
Also used : Response(javax.ws.rs.core.Response) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 39 with SeriesQuery

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));
}
Also used : Response(javax.ws.rs.core.Response) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 40 with SeriesQuery

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));
}
Also used : Response(javax.ws.rs.core.Response) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) Issue(io.qameta.allure.Issue) 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