Search in sources :

Example 1 with StringTable

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

the class SqlFunctionMathTest method testRoundTo2DecimalPlaces.

@Issue("3049")
@Test
public void testRoundTo2DecimalPlaces() {
    String sqlQuery = String.format("SELECT ROUND(value,2) FROM\"%s\" %nWHERE entity = '%s'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Collections.singletonList(Double.toString(Math.round(2.11 * 100) / 100d)), Collections.singletonList(Double.toString(Math.round(7.567 * 100) / 100d)), Collections.singletonList(Double.toString(Math.round(-1.23 * 100) / 100d)));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 2 with StringTable

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

the class SqlPeriodSyntaxTest method testPeriodEmptyOptions.

@Issue("3058")
@Test
public void testPeriodEmptyOptions() {
    String sqlQuery = String.format("SELECT datetime, AVG(value) FROM \"%s\" %n" + "WHERE entity = '%s' %nAND datetime >= '2016-06-19T11:00:00.000Z' AND " + "datetime < '2016-06-19T11:00:11.000Z' %nGROUP BY PERIOD(5 SECOND)", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Arrays.asList("2016-06-19T11:00:00.000Z", "0.0"), Arrays.asList("2016-06-19T11:00:05.000Z", "1.0"), Arrays.asList("2016-06-19T11:00:10.000Z", "2.0"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 3 with StringTable

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

the class SqlPeriodSyntaxTest method testPeriodInterpolateExtendAlignOptions.

@Issue("3058")
@Test
public void testPeriodInterpolateExtendAlignOptions() {
    String sqlQuery = String.format("SELECT datetime, AVG(value) FROM \"%s\" %n" + "WHERE entity = '%s' %nAND datetime >= '2016-06-19T10:59:57.500Z' AND datetime < '2016-06-19T11:00:13.000Z' %n" + "GROUP BY PERIOD(2500 MILLISECOND,LINEAR, EXTEND, START_TIME)", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(// <-EXTENDED BY NEXT
    Arrays.asList("2016-06-19T10:59:57.500Z", "0.0"), Arrays.asList("2016-06-19T11:00:00.000Z", "0.0"), // <-INTERPOLATED BY LINEAR
    Arrays.asList("2016-06-19T11:00:02.500Z", "0.5"), Arrays.asList("2016-06-19T11:00:05.000Z", "1.0"), // <-INTERPOLATED BY LINEAR
    Arrays.asList("2016-06-19T11:00:07.500Z", "1.5"), Arrays.asList("2016-06-19T11:00:10.000Z", "2.0"), // <-EXTENDED BY PREVIOUS
    Arrays.asList("2016-06-19T11:00:12.500Z", "2.0"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 4 with StringTable

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

the class SqlPeriodSyntaxTest method testPeriodExtendAlignInterpolateOptions.

@Issue("3058")
@Test
public void testPeriodExtendAlignInterpolateOptions() {
    String sqlQuery = String.format("SELECT datetime, AVG(value) FROM \"%s\" %nWHERE entity = '%s' %n" + "AND datetime >= '2016-06-19T10:59:57.500Z' AND datetime < '2016-06-19T11:00:13.000Z' %n" + "GROUP BY PERIOD(2500 MILLISECOND, EXTEND, START_TIME, LINEAR)", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(// <-EXTENDED BY NEXT
    Arrays.asList("2016-06-19T10:59:57.500Z", "0.0"), Arrays.asList("2016-06-19T11:00:00.000Z", "0.0"), // <-INTERPOLATED BY LINEAR
    Arrays.asList("2016-06-19T11:00:02.500Z", "0.5"), Arrays.asList("2016-06-19T11:00:05.000Z", "1.0"), // <-INTERPOLATED BY LINEAR
    Arrays.asList("2016-06-19T11:00:07.500Z", "1.5"), Arrays.asList("2016-06-19T11:00:10.000Z", "2.0"), // <-EXTENDED BY PREVIOUS
    Arrays.asList("2016-06-19T11:00:12.500Z", "2.0"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 5 with StringTable

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

the class SqlPeriodSyntaxTest method testPeriodInterpolateOptions.

@Issue("3058")
@Test
public void testPeriodInterpolateOptions() {
    String sqlQuery = String.format("SELECT datetime, AVG(value) FROM \"%s\" %nWHERE entity = '%s' %n" + "AND datetime >= '2016-06-19T11:00:00.500Z' AND datetime < '2016-06-19T11:00:11.000Z' %n" + "GROUP BY PERIOD(2500 MILLISECOND, LINEAR)", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Arrays.asList("2016-06-19T11:00:05.000Z", "1.0"), // <-INTERPOLATED BY LINEAR
    Arrays.asList("2016-06-19T11:00:07.500Z", "1.5"), Arrays.asList("2016-06-19T11:00:10.000Z", "2.0"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Aggregations

StringTable (com.axibase.tsd.api.model.sql.StringTable)277 Test (org.testng.annotations.Test)276 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)275 Issue (io.qameta.allure.Issue)270 List (java.util.List)147 Response (javax.ws.rs.core.Response)49 ArrayList (java.util.ArrayList)23 Series (com.axibase.tsd.api.model.series.Series)4 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 BeforeTest (org.testng.annotations.BeforeTest)1