Search in sources :

Example 1 with QueryOptions

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

the class QueryOptionsTest method getContinuationTokenSuccess.

// Tests_SRS_QUERYOPTIONS_34_002: [This function shall return the saved continuation token.]
@Test
public void getContinuationTokenSuccess() {
    // arrange
    String expectedContinuationToken = "someToken";
    QueryOptions options = new QueryOptions();
    Deencapsulation.setField(options, "continuationToken", expectedContinuationToken);
    // act
    String actualContinuationToken = options.getContinuationToken();
    // assert
    assertEquals(expectedContinuationToken, actualContinuationToken);
}
Also used : QueryOptions(com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions) Test(org.junit.Test)

Example 2 with QueryOptions

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

the class QueryOptionsTest method getPageSizeSuccess.

// Tests_SRS_QUERYOPTIONS_34_003: [This function shall return the saved page size.]
@Test
public void getPageSizeSuccess() {
    // arrange
    Integer expectedPageSize = 758;
    QueryOptions options = new QueryOptions();
    Deencapsulation.setField(options, "pageSize", expectedPageSize);
    // act
    Integer actualPageSize = options.getPageSize();
    // assert
    assertEquals(expectedPageSize, actualPageSize);
}
Also used : QueryOptions(com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions) Test(org.junit.Test)

Example 3 with QueryOptions

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

the class QueryTwinTests method queryCollectionCanReturnEmptyQueryResults.

@Test
@StandardTierHubOnlyTest
@ContinuousIntegrationTest
public void queryCollectionCanReturnEmptyQueryResults() throws IOException, IotHubException {
    String fullQuery = "select * from devices where deviceId='nonexistantdevice'";
    DeviceTwin twinClient = new DeviceTwin(iotHubConnectionString, DeviceTwinClientOptions.builder().httpReadTimeout(HTTP_READ_TIMEOUT).build());
    QueryCollection twinQuery = twinClient.queryTwinCollection(fullQuery);
    QueryOptions options = new QueryOptions();
    QueryCollectionResponse<DeviceTwinDevice> response = twinClient.next(twinQuery, options);
    assertNull(response.getContinuationToken());
    assertTrue(response.getCollection().isEmpty());
}
Also used : QueryCollection(com.microsoft.azure.sdk.iot.service.devicetwin.QueryCollection) DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) QueryOptions(com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions) DeviceTwin(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) IotHubTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest) IntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) Test(org.junit.Test) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)

Example 4 with QueryOptions

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

the class DeviceTwinTest method getNextDeviceTwinCollectionWithOptionsThrowsForNullQueryCollection.

// Tests_SRS_DEVICETWIN_34_076: [If the provided deviceTwinQueryCollection is null, an IllegalArgumentException shall be thrown.]
@Test(expected = IllegalArgumentException.class)
public void getNextDeviceTwinCollectionWithOptionsThrowsForNullQueryCollection() throws IOException, IotHubException {
    // arrange
    DeviceTwin deviceTwin = new DeviceTwin(STANDARD_CONNECTIONSTRING);
    // act
    deviceTwin.next(null, new QueryOptions());
}
Also used : QueryOptions(com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions) DeviceTwin(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin) Test(org.junit.Test)

Example 5 with QueryOptions

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

the class QueryOptionsTest method setContinuationTokenSuccess.

// Tests_SRS_QUERYOPTIONS_34_006: [This function shall save the provided continuation token string.]
@Test
public void setContinuationTokenSuccess() {
    // arrange
    String expectedContinuationToken = "someToken";
    QueryOptions options = new QueryOptions();
    // act
    options.setContinuationToken(expectedContinuationToken);
    // assert
    String actualContinuationToken = Deencapsulation.getField(options, "continuationToken");
    assertEquals(expectedContinuationToken, actualContinuationToken);
}
Also used : QueryOptions(com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions) Test(org.junit.Test)

Aggregations

QueryOptions (com.microsoft.azure.sdk.iot.service.devicetwin.QueryOptions)8 Test (org.junit.Test)8 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)2 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)2 DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)2 QueryCollection (com.microsoft.azure.sdk.iot.service.devicetwin.QueryCollection)2 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)2 ContinuousIntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)2 IotHubTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest)2 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)2 SqlQuery (com.microsoft.azure.sdk.iot.service.devicetwin.SqlQuery)1 ArrayList (java.util.ArrayList)1