Search in sources :

Example 16 with Period

use of com.axibase.tsd.api.model.Period 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 17 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class GroupingTest method testCases.

@DataProvider
public Object[][] testCases() {
    Period period = new Period(1, MINUTE);
    Group groupCount = new Group(GroupType.COUNT);
    Group groupCountPerMinute = new Group(GroupType.COUNT, period);
    Group groupSumPerMinute = new Group(GroupType.SUM, period);
    Aggregate aggregateSum = new Aggregate(AggregationType.SUM, period);
    Aggregate aggregateCount = new Aggregate(AggregationType.COUNT, period);
    SeriesQuery[] testCases = { buildQuery(groupCountPerMinute, null, Arrays.asList(Transformation.GROUP)), // buildQuery(groupCount, aggregateSum, Arrays.asList(Transformation.GROUP, Transformation.AGGREGATE)),
    buildQuery(groupCountPerMinute, aggregateSum, Arrays.asList(Transformation.GROUP, Transformation.AGGREGATE)), buildQuery(groupSumPerMinute, aggregateCount, Arrays.asList(Transformation.AGGREGATE, Transformation.GROUP)) };
    return TestUtil.convertTo2DimArray(testCases);
}
Also used : 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) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) DataProvider(org.testng.annotations.DataProvider)

Example 18 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class TradeSideTest method testCases.

@DataProvider
public Object[][] testCases() {
    Period aMinute = new Period(1, MINUTE);
    List<TestCase> testCases = new ArrayList<>();
    addTestCases("2020-12-01T00:00:00Z", "2020-12-02T00:00:00Z", false, null, new int[] { 1, 3, 4, 6 }, new int[] { 2, 5 }, testCases);
    addTestCases("2020-12-01T10:57:00Z", "2020-12-01T10:59:00Z", false, null, null, new int[] { 2 }, testCases);
    addTestCases("2020-12-01T10:59:00Z", "2020-12-01T11:02:00Z", false, null, new int[] { 3, 4 }, null, testCases);
    addTestCases("2020-12-01T00:00:00Z", "2020-12-02T00:00:00Z", true, null, new int[] { 6 }, new int[] { 5 }, testCases);
    addTestCases("2020-12-01T10:57:00Z", "2020-12-01T10:59:00Z", true, null, null, new int[] { 2 }, testCases);
    addTestCases("2020-12-01T10:59:00Z", "2020-12-01T11:02:00Z", true, null, new int[] { 4 }, null, testCases);
    addTestCases("2020-12-01T00:00:00Z", "2020-12-02T00:00:00Z", true, new Period(1, HOUR), new int[] { 3, 6 }, new int[] { 2, 5 }, testCases);
    addTestCases("2020-12-01T00:00:00Z", "2020-12-02T00:00:00Z", true, new Period(5, MINUTE), new int[] { 3, 4, 6 }, new int[] { 2, 5 }, testCases);
    addTestCases("2020-12-01T10:57:00Z", "2020-12-01T10:59:00Z", true, aMinute, null, new int[] { 2 }, testCases);
    addTestCases("2020-12-01T10:59:00Z", "2020-12-01T11:02:00Z", true, aMinute, new int[] { 3, 4 }, null, testCases);
    addTestCases("2020-12-01T11:03:00Z", "2020-12-01T11:06:00Z", false, null, null, null, testCases);
    addTestCases("2020-12-01T11:03:00Z", "2020-12-01T11:06:00Z", true, null, null, null, testCases);
    addTestCases("2020-12-01T11:03:00Z", "2020-12-01T11:06:00Z", false, aMinute, null, null, testCases);
    return TestUtil.convertTo2DimArray(testCases);
}
Also used : ArrayList(java.util.ArrayList) Period(com.axibase.tsd.api.model.Period) DataProvider(org.testng.annotations.DataProvider)

Example 19 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class MessageInsertTest method testISOTimezoneMinusHourMinute.

@Issue("2850")
@Test
public void testISOTimezoneMinusHourMinute() {
    String entityName = "message-insert-test-iso-hm";
    Message message = new Message(entityName);
    message.setMessage("hello");
    message.setDate("2018-05-20T22:37:00-01:23");
    String date = "2018-05-21T00:00:00.000Z";
    final MessageQuery messageQuery = new MessageQuery();
    messageQuery.setEntity(entityName);
    messageQuery.setStartDate(date);
    messageQuery.setInterval(new Period(1, TimeUnit.MILLISECOND));
    insertMessageCheck(message, new MessageQuerySizeCheck(messageQuery, 1));
    List<Message> storedMessageList = queryMessageResponse(messageQuery).readEntity(ResponseAsList.ofMessages());
    Message storedMessage = storedMessageList.get(0);
    assertEquals("Incorrect message entity", message.getEntity(), storedMessage.getEntity());
    assertEquals("Incorrect message text", message.getMessage(), storedMessage.getMessage());
    assertEquals("Incorrect message date", date, storedMessage.getDate());
}
Also used : Message(com.axibase.tsd.api.model.message.Message) Period(com.axibase.tsd.api.model.Period) MessageQuerySizeCheck(com.axibase.tsd.api.method.checks.MessageQuerySizeCheck) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 20 with Period

use of com.axibase.tsd.api.model.Period in project atsd-api-test by axibase.

the class MessageInsertTest method testRfc822TimezoneOffsetSupported.

@Issue("2850")
@Issue("5272")
@Test
public void testRfc822TimezoneOffsetSupported() {
    String entityName = "message-insert-test-rfc+hm";
    Message message = new Message(entityName).setMessage("hello").setDate("2018-07-20T22:50:00-0110");
    String date = "2018-07-21T00:00:00.000Z";
    final MessageQuery messageQuery = new MessageQuery().setEntity(entityName).setStartDate(date).setInterval(new Period(1, TimeUnit.MILLISECOND));
    insertMessageCheck(message, new MessageQuerySizeCheck(messageQuery, 1));
    Message storedMessage = queryMessageResponse(messageQuery).readEntity(ResponseAsList.ofMessages()).get(0);
    assertEquals("Incorrect message entity", message.getEntity(), storedMessage.getEntity());
    assertEquals("Incorrect message text", message.getMessage(), storedMessage.getMessage());
    assertEquals("Incorrect message date", date, storedMessage.getDate());
}
Also used : Message(com.axibase.tsd.api.model.message.Message) Period(com.axibase.tsd.api.model.Period) MessageQuerySizeCheck(com.axibase.tsd.api.method.checks.MessageQuerySizeCheck) MessageQuery(com.axibase.tsd.api.model.message.MessageQuery) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

Period (com.axibase.tsd.api.model.Period)63 Test (org.testng.annotations.Test)48 Issue (io.qameta.allure.Issue)44 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)39 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)30 BigDecimal (java.math.BigDecimal)24 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)16 Series (com.axibase.tsd.api.model.series.Series)14 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)11 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)10 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)7 Property (com.axibase.tsd.api.model.property.Property)6 MessageQuery (com.axibase.tsd.api.model.message.MessageQuery)5 MessageQuerySizeCheck (com.axibase.tsd.api.method.checks.MessageQuerySizeCheck)4 Message (com.axibase.tsd.api.model.message.Message)4 AggregationType (com.axibase.tsd.api.model.series.query.transformation.aggregate.AggregationType)3 ArrayList (java.util.ArrayList)3 Response (javax.ws.rs.core.Response)3 DataProvider (org.testng.annotations.DataProvider)3 Metric (com.axibase.tsd.api.model.metric.Metric)2