Search in sources :

Example 1 with SqlQuery

use of com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery in project azure-iot-sdk-java by Azure.

the class SqlQueryTest method createQueryMultipleSucceeds.

@Test
public void createQueryMultipleSucceeds() throws IOException {
    // act
    SqlQuery sqlQueryTest = SqlQuery.createSqlQuery(VALID_SELECTION, SqlQuery.FromType.DEVICES, VALID_WHERE, VALID_GROUPBY);
    SqlQuery sqlQueryTest_1 = SqlQuery.createSqlQuery(VALID_SELECTION + 1, SqlQuery.FromType.DEVICES, VALID_WHERE + 1, VALID_GROUPBY + 1);
    // assert
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("select"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_SELECTION));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("from"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_FROM.getValue()));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("where"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_WHERE));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("group by"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_GROUPBY));
    assertTrue(sqlQueryTest_1.getQuery().toLowerCase().contains("select"));
    assertTrue(sqlQueryTest_1.getQuery().contains(VALID_SELECTION + 1));
    assertTrue(sqlQueryTest_1.getQuery().toLowerCase().contains("from"));
    assertTrue(sqlQueryTest_1.getQuery().contains(VALID_FROM.getValue()));
    assertTrue(sqlQueryTest_1.getQuery().toLowerCase().contains("where"));
    assertTrue(sqlQueryTest_1.getQuery().contains(VALID_WHERE + 1));
    assertTrue(sqlQueryTest_1.getQuery().toLowerCase().contains("group by"));
    assertTrue(sqlQueryTest_1.getQuery().contains(VALID_GROUPBY + 1));
}
Also used : SqlQuery(com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery) Test(org.junit.Test)

Example 2 with SqlQuery

use of com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery in project azure-iot-sdk-java by Azure.

the class SqlQueryTest method createQuerySelectFromSucceeds.

// Tests_SRS_SQL_QUERY_25_002: [ The constructor shall build the sql query string from the given Input ]
// Tests_SRS_SQL_QUERY_25_005: [ The constructor shall create a new SqlQuery instance and return it ]
// Tests_SRS_SQL_QUERY_25_006: [ The method shall return the sql query string built ]
@Test
public void createQuerySelectFromSucceeds() throws IOException {
    // act
    SqlQuery sqlQueryTest = SqlQuery.createSqlQuery(VALID_SELECTION, SqlQuery.FromType.DEVICES, null, null);
    // assert
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("select"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_SELECTION));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("from"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_FROM.getValue()));
}
Also used : SqlQuery(com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery) Test(org.junit.Test)

Example 3 with SqlQuery

use of com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery in project azure-iot-sdk-java by Azure.

the class SqlQueryTest method createQuerySelectFromWhereSucceeds.

// Tests_SRS_SQL_QUERY_25_003: [ The constructor shall append where to the sql query string only when provided ]
@Test
public void createQuerySelectFromWhereSucceeds() throws IOException {
    // act
    SqlQuery sqlQueryTest = SqlQuery.createSqlQuery(VALID_SELECTION, SqlQuery.FromType.DEVICES, VALID_WHERE, null);
    // assert
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("select"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_SELECTION));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("from"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_FROM.getValue()));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("where"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_WHERE));
    assertFalse(sqlQueryTest.getQuery().toLowerCase().contains("group by"));
    assertFalse(sqlQueryTest.getQuery().contains(VALID_GROUPBY));
}
Also used : SqlQuery(com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery) Test(org.junit.Test)

Example 4 with SqlQuery

use of com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery in project azure-iot-sdk-java by Azure.

the class SqlQueryTest method createQuerySelectFromWhereGroupBySucceeds.

@Test
public void createQuerySelectFromWhereGroupBySucceeds() throws IOException {
    // act
    SqlQuery sqlQueryTest = SqlQuery.createSqlQuery(VALID_SELECTION, SqlQuery.FromType.DEVICES, VALID_WHERE, VALID_GROUPBY);
    // assert
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("select"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_SELECTION));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("from"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_FROM.getValue()));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("where"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_WHERE));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("group by"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_GROUPBY));
}
Also used : SqlQuery(com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery) Test(org.junit.Test)

Example 5 with SqlQuery

use of com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery in project azure-iot-sdk-java by Azure.

the class SqlQueryTest method createQuerySelectFromGroupBySucceeds.

// Tests_SRS_SQL_QUERY_25_004: [ The constructor shall append groupby to the sql query string only when provided ]
@Test
public void createQuerySelectFromGroupBySucceeds() throws IOException {
    // act
    SqlQuery sqlQueryTest = SqlQuery.createSqlQuery(VALID_SELECTION, SqlQuery.FromType.DEVICES, null, VALID_GROUPBY);
    // assert
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("select"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_SELECTION));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("from"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_FROM.getValue()));
    assertFalse(sqlQueryTest.getQuery().toLowerCase().contains("where"));
    assertFalse(sqlQueryTest.getQuery().contains(VALID_WHERE));
    assertTrue(sqlQueryTest.getQuery().toLowerCase().contains("group by"));
    assertTrue(sqlQueryTest.getQuery().contains(VALID_GROUPBY));
}
Also used : SqlQuery(com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery) Test(org.junit.Test)

Aggregations

SqlQuery (com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery)8 Test (org.junit.Test)6 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)3 DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)2 Query (com.microsoft.azure.sdk.iot.service.devicetwin.Query)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Pair (com.microsoft.azure.sdk.iot.service.devicetwin.Pair)1 QueryCollection (com.microsoft.azure.sdk.iot.service.devicetwin.QueryCollection)1 QueryOptions (com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)1 ContinuousIntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)1 IotHubTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest)1 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)1