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