Search in sources :

Example 66 with SeriesQuery

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

Example 67 with SeriesQuery

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

Example 68 with SeriesQuery

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;
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery)

Example 69 with 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));
}
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) ArrayList(java.util.ArrayList) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 70 with SeriesQuery

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;
}
Also used : SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery)

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