Search in sources :

Example 11 with RawTwinQuery

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

the class RawTwinQueryTest method rawQueryThrowsOnNullQuery.

// Tests_SRS_RAW_QUERY_25_004: [ The method shall throw IllegalArgumentException if the query is null or empty.]
@Test(expected = IllegalArgumentException.class)
public void rawQueryThrowsOnNullQuery() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    // act
    rawTwinQuery.query(null);
}
Also used : RawTwinQuery(com.microsoft.azure.sdk.iot.service.devicetwin.RawTwinQuery) Test(org.junit.Test)

Example 12 with RawTwinQuery

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

the class RawTwinQueryTest method nextRetrievesCorrectly.

// Tests_SRS_RAW_QUERY_25_016: [ The method shall return the next element from the query response.]
@Test
public void nextRetrievesCorrectly() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    final String expectedString = "testJsonAsNext";
    new NonStrictExpectations() {

        {
            Deencapsulation.newInstance(Query.class, new Class[] { String.class, Integer.class, QueryType.class }, anyString, anyInt, QueryType.RAW);
            result = mockedQuery;
            Deencapsulation.invoke(mockedQuery, "hasNext");
            result = true;
            Deencapsulation.invoke(mockedQuery, "next");
            result = expectedString;
        }
    };
    Query testQuery = rawTwinQuery.query(VALID_SQL_QUERY);
    // act
    String result = rawTwinQuery.next(testQuery);
    // assert
    assertEquals(expectedString, result);
}
Also used : RawTwinQuery(com.microsoft.azure.sdk.iot.service.devicetwin.RawTwinQuery) SqlQuery(com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery) Query(com.microsoft.azure.sdk.iot.service.devicetwin.Query) RawTwinQuery(com.microsoft.azure.sdk.iot.service.devicetwin.RawTwinQuery) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) Test(org.junit.Test)

Example 13 with RawTwinQuery

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

the class RawTwinQueryTest method rawQueryThrowsOnZeroPageSize.

@Test(expected = IllegalArgumentException.class)
public void rawQueryThrowsOnZeroPageSize() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    // act
    rawTwinQuery.query(VALID_SQL_QUERY, 0);
}
Also used : RawTwinQuery(com.microsoft.azure.sdk.iot.service.devicetwin.RawTwinQuery) Test(org.junit.Test)

Aggregations

RawTwinQuery (com.microsoft.azure.sdk.iot.service.devicetwin.RawTwinQuery)13 Test (org.junit.Test)13 Query (com.microsoft.azure.sdk.iot.service.devicetwin.Query)8 SqlQuery (com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery)8 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)3 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)2 NoSuchElementException (java.util.NoSuchElementException)1