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);
}
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);
}
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);
}
Aggregations