Search in sources :

Example 81 with StringTable

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

the class SqlExampleOrderByMultipleColumnsTest method test.

@Issue("3047")
@Test(description = "Test for alias documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/order-by-value.md")
public void test() {
    String sqlQuery = String.format("SELECT entity, tags.tag, delta(value) FROM \"%s\"%nGROUP BY entity, tags%nORDER BY  tags.tag, DELTA(value) DESC", TEST_METRIC_NAME);
    Response response = queryResponse(sqlQuery);
    StringTable resultTable = response.readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Arrays.asList(TEST_ENTITY3_NAME, "a", "-2.0"), Arrays.asList(TEST_ENTITY1_NAME, "b", "-2.0"), Arrays.asList(TEST_ENTITY2_NAME, "c", "-2.0"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : Response(javax.ws.rs.core.Response) 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 82 with StringTable

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

the class SqlExampleOrderByValueTest method test.

@Issue("3047")
@Test(description = "Test for alias documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/order-by-value.md")
public void test() {
    String sqlQuery = String.format("SELECT entity, AVG(value) FROM \"%s\"%nGROUP BY entity%nORDER BY AVG(value) DESC", TEST_METRIC_NAME);
    Response response = queryResponse(sqlQuery);
    StringTable resultTable = response.readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Arrays.asList(TEST_ENTITY3_NAME, "5.0"), Arrays.asList(TEST_ENTITY2_NAME, "3.0"), Arrays.asList(TEST_ENTITY1_NAME, "1.0"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : Response(javax.ws.rs.core.Response) 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 83 with StringTable

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

the class SqlExampleQuoteEscapingTest method testExample1.

@Issue("3125")
@Test(description = "Test for query all tags documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/select-escape-quote")
public void testExample1() {
    String sqlQuery = String.format("SELECT tags.*  %nFROM \"%s\"  %nWHERE datetime > '2016-07-27T22:40:00.000Z'", TEST_METRIC_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<String> expectedColumnNames = Arrays.asList("tags.double\"quote", "tags.single'quote", "tags.both'quo\"tes");
    List<List<String>> expectedRows = Collections.singletonList(Arrays.asList("tv3", "tv1", "tv2"));
    assertTableColumnsNames(expectedColumnNames, resultTable);
    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 84 with StringTable

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

the class SqlFunctionDateFormatTimeExpressionTest method testValueAsParam.

@Issue("3283")
@Test
public void testValueAsParam() {
    String sqlQuery = String.format("SELECT date_format(value) FROM \"%s\" ORDER BY datetime", TEST_METRIC_NAME);
    Response response = queryResponse(sqlQuery);
    StringTable resultTable = response.readEntity(StringTable.class);
    String[][] expectedRows = { { Util.ISOFormat(1) } };
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : Response(javax.ws.rs.core.Response) StringTable(com.axibase.tsd.api.model.sql.StringTable) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 85 with StringTable

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

the class SqlFunctionDateFormatTimeExpressionTest method testAllOperations.

@Issue("3283")
@Test
public void testAllOperations() {
    String sqlQuery = String.format("SELECT date_format(time + 200/2 - 20*5) FROM \"%s\"", TEST_METRIC_NAME);
    Response response = queryResponse(sqlQuery);
    StringTable resultTable = response.readEntity(StringTable.class);
    String[][] expectedRows = { { "2016-06-03T09:41:00.000Z" } };
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : Response(javax.ws.rs.core.Response) StringTable(com.axibase.tsd.api.model.sql.StringTable) 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