Search in sources :

Example 1 with Interval

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

Example 2 with Interval

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

Example 3 with Interval

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());
}
Also used : Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Sample(com.axibase.tsd.api.model.series.Sample) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) BigDecimal(java.math.BigDecimal) Interval(com.axibase.tsd.api.model.series.query.Interval) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 4 with Interval

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));
}
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) Interval(com.axibase.tsd.api.model.series.query.Interval) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with Interval

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

Aggregations

Interval (com.axibase.tsd.api.model.series.query.Interval)12 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)10 Issue (io.qameta.allure.Issue)9 Test (org.testng.annotations.Test)9 Series (com.axibase.tsd.api.model.series.Series)6 Response (javax.ws.rs.core.Response)6 Period (com.axibase.tsd.api.model.Period)2 SeriesTest (com.axibase.tsd.api.method.series.SeriesTest)1 Sample (com.axibase.tsd.api.model.series.Sample)1 SeriesType (com.axibase.tsd.api.model.series.SeriesType)1 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)1 Forecast (com.axibase.tsd.api.model.series.query.transformation.forecast.Forecast)1 HoltWintersSettings (com.axibase.tsd.api.model.series.query.transformation.forecast.HoltWintersSettings)1 Horizon (com.axibase.tsd.api.model.series.query.transformation.forecast.Horizon)1 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)1 BigDecimal (java.math.BigDecimal)1 DataProvider (org.testng.annotations.DataProvider)1