Search in sources :

Example 6 with RawTwinQuery

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

the class RawTwinQueryTest method nextThrowsIfNoNewElements.

// Tests_SRS_RAW_QUERY_25_015: [ The method shall check if hasNext returns true and throw NoSuchElementException otherwise ]
@Test(expected = NoSuchElementException.class)
public void nextThrowsIfNoNewElements() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    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 = false;
            Deencapsulation.invoke(mockedQuery, "next");
            result = new NoSuchElementException();
        }
    };
    Query testQuery = rawTwinQuery.query(VALID_SQL_QUERY);
    // act
    String result = rawTwinQuery.next(testQuery);
}
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) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Example 7 with RawTwinQuery

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

the class RawTwinQueryTest method nextThrowsOnNullQuery.

// Tests_SRS_RAW_QUERY_25_018: [ If the input query is null, then this method shall throw IllegalArgumentException ]
@Test(expected = IllegalArgumentException.class)
public void nextThrowsOnNullQuery() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    new NonStrictExpectations() {

        {
            Deencapsulation.newInstance(Query.class, new Class[] { String.class, Integer.class, QueryType.class }, anyString, anyInt, QueryType.RAW);
            result = mockedQuery;
        }
    };
    Query testQuery = rawTwinQuery.query(VALID_SQL_QUERY);
    // act
    rawTwinQuery.next(null);
}
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) Test(org.junit.Test)

Example 8 with RawTwinQuery

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

the class RawTwinQueryTest method hasNextThrowsOnNullQuery.

// Tests_SRS_RAW_QUERY_25_010: [ The method shall throw IllegalArgumentException if query is null ]
@Test(expected = IllegalArgumentException.class)
public void hasNextThrowsOnNullQuery() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    new NonStrictExpectations() {

        {
            Deencapsulation.newInstance(Query.class, new Class[] { String.class, Integer.class, QueryType.class }, anyString, anyInt, QueryType.RAW);
            result = mockedQuery;
        }
    };
    Query testQuery = rawTwinQuery.query(VALID_SQL_QUERY);
    // act
    rawTwinQuery.hasNext(null);
}
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) Test(org.junit.Test)

Example 9 with RawTwinQuery

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

the class RawTwinQueryTest method hasNextThrowsIfQueryHasNextThrows.

@Test(expected = IotHubException.class)
public void hasNextThrowsIfQueryHasNextThrows() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    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 = new IotHubException();
        }
    };
    Query testQuery = rawTwinQuery.query(VALID_SQL_QUERY);
    // act
    boolean result = rawTwinQuery.hasNext(testQuery);
}
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) IotHubException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubException) Test(org.junit.Test)

Example 10 with RawTwinQuery

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

the class RawTwinQueryTest method nextThrowsOnQueryNextThrows.

@Test(expected = IotHubException.class)
public void nextThrowsOnQueryNextThrows() throws IotHubException, IOException {
    // arrange
    RawTwinQuery rawTwinQuery = RawTwinQuery.createFromConnectionString(VALID_CONNECTION_STRING);
    new NonStrictExpectations() {

        {
            Deencapsulation.newInstance(Query.class, new Class[] { String.class, Integer.class, QueryType.class }, anyString, anyInt, QueryType.RAW);
            result = mockedQuery;
            Deencapsulation.invoke(mockedQuery, "next");
            result = new IotHubException();
        }
    };
    Query testQuery = rawTwinQuery.query(VALID_SQL_QUERY);
    // act
    rawTwinQuery.next(testQuery);
}
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) IotHubException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubException) 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