Search in sources :

Example 26 with StringTable

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

the class SqlFunctionMathTest method testRound.

@Issue("3049")
@Test
public void testRound() {
    String sqlQuery = String.format("SELECT ROUND(value) 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))), Collections.singletonList(Double.toString(Math.round(7.567))), Collections.singletonList(Double.toString(Math.round(-1.23))));
    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 27 with StringTable

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

the class SqlFunctionMathTest method testMod.

@Issue("3049")
@Test
public void testMod() {
    String sqlQuery = String.format("SELECT MOD(value,2.11) 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(Mod(2.11, 2.11))), Collections.singletonList(Double.toString(Mod(7.567, 2.11))), Collections.singletonList(Double.toString(Mod(-1.23, 2.11))));
    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 28 with StringTable

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

the class SqlFunctionMathTest method testSqrt.

@Issue("3049")
@Test
public void testSqrt() {
    String sqlQuery = String.format("SELECT SQRT(value) FROM\"%s\" %n WHERE 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.sqrt(2.11))), Collections.singletonList(Double.toString(Math.sqrt(7.567))), Collections.singletonList("NaN"));
    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 29 with StringTable

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

the class SqlFunctionMathTest method testExp.

@Issue("3049")
@Test
public void testExp() {
    String sqlQuery = String.format("SELECT EXP(value) 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.exp(2.11))), Collections.singletonList(Double.toString(Math.exp(7.567))), Collections.singletonList(Double.toString(Math.exp(-1.23))));
    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 30 with StringTable

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

the class SqlTest method assertSqlQueryRows.

public void assertSqlQueryRows(String message, List<List<String>> expectedRows, String sqlQuery) {
    StringTable resultTable = queryTable(sqlQuery);
    // See #5057
    if (expectedRows.size() > 0) {
        for (int timeout = 100; timeout <= 1600 && resultTable.getRows().size() == 0; timeout *= 2) {
            try {
                Thread.sleep(timeout);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            resultTable = queryTable(sqlQuery);
        }
    }
    assertTableRowsExist(String.format("%s%nWrong result of the following SQL query: %n\t%s", message, sqlQuery), expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable)

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