use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientComponentTests method getDigitalTwin.
@Test
@StandardTierHubOnlyTest
public void getDigitalTwin() {
// act
BasicDigitalTwin response = this.digitalTwinClient.getDigitalTwin(deviceId, BasicDigitalTwin.class);
ServiceResponseWithHeaders<BasicDigitalTwin, DigitalTwinGetHeaders> responseWithHeaders = this.digitalTwinClient.getDigitalTwinWithResponse(deviceId, BasicDigitalTwin.class);
// assert
assertEquals(response.getMetadata().getModelId(), E2ETestConstants.TEMPERATURE_CONTROLLER_MODEL_ID);
assertEquals(responseWithHeaders.body().getMetadata().getModelId(), E2ETestConstants.TEMPERATURE_CONTROLLER_MODEL_ID);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method getDigitalTwin.
@Test
@StandardTierHubOnlyTest
public void getDigitalTwin() {
// act
BasicDigitalTwin response = digitalTwinClient.getDigitalTwin(deviceId, BasicDigitalTwin.class);
ServiceResponseWithHeaders<BasicDigitalTwin, DigitalTwinGetHeaders> responseWithHeaders = digitalTwinClient.getDigitalTwinWithResponse(deviceId, BasicDigitalTwin.class);
// assert
assertEquals(response.getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
assertEquals(responseWithHeaders.body().getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method digitalTwinConstructorThrowsForNegativeReadTimeout.
@Test(expected = IllegalArgumentException.class)
@StandardTierHubOnlyTest
public void digitalTwinConstructorThrowsForNegativeReadTimeout() {
// arrange
DigitalTwinClientOptions clientOptions = DigitalTwinClientOptions.builder().httpReadTimeout(-1).build();
digitalTwinClient = new DigitalTwinClient(IOTHUB_CONNECTION_STRING, clientOptions);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method getDigitalTwinWithProxy.
@Test
@StandardTierHubOnlyTest
public void getDigitalTwinWithProxy() {
// arrange
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(testProxyHostname, testProxyPort));
ProxyOptions proxyOptions = new ProxyOptions(proxy);
DigitalTwinClientOptions clientOptions = DigitalTwinClientOptions.builder().proxyOptions(proxyOptions).httpReadTimeout(0).build();
digitalTwinClient = new DigitalTwinClient(IOTHUB_CONNECTION_STRING, clientOptions);
// act
BasicDigitalTwin response = digitalTwinClient.getDigitalTwin(deviceId, BasicDigitalTwin.class);
ServiceResponseWithHeaders<BasicDigitalTwin, DigitalTwinGetHeaders> responseWithHeaders = digitalTwinClient.getDigitalTwinWithResponse(deviceId, BasicDigitalTwin.class);
// assert
assertEquals(response.getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
assertEquals(responseWithHeaders.body().getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class DesiredPropertiesTests method testSubscribeToDesiredPropertiesBatch.
// This test is for the startDeviceTwin/startTwin API that takes the TwinPropertiesCallback rather than the TwinPropertyCallback
// This callback should receive the full twin update in one callback, rather than one callback per updated
// desired property
@Test
@StandardTierHubOnlyTest
public void testSubscribeToDesiredPropertiesBatch() throws Exception {
super.setUpNewDeviceAndModule(false);
String expectedKey1 = UUID.randomUUID().toString();
String expectedValue1 = UUID.randomUUID().toString();
String expectedKey2 = UUID.randomUUID().toString();
String expectedValue2 = UUID.randomUUID().toString();
TwinCollection expectedDesiredProperties = new TwinCollection();
expectedDesiredProperties.putFinal(expectedKey1, expectedValue1);
expectedDesiredProperties.putFinal(expectedKey2, expectedValue2);
TwinPropertiesCallback twinPropertiesCallback = new TwinPropertiesCallbackImpl(expectedDesiredProperties);
Success desiredPropertiesCallbackState = new Success();
testInstance.testIdentity.getClient().open();
if (testInstance.testIdentity.getClient() instanceof DeviceClient) {
((DeviceClient) testInstance.testIdentity.getClient()).startDeviceTwin(new DeviceTwinStatusCallBack(), testInstance.deviceUnderTest, twinPropertiesCallback, desiredPropertiesCallbackState);
} else {
((ModuleClient) testInstance.testIdentity.getClient()).startTwin(new DeviceTwinStatusCallBack(), testInstance.deviceUnderTest, twinPropertiesCallback, desiredPropertiesCallbackState);
}
long startTime = System.currentTimeMillis();
while (testInstance.deviceUnderTest.deviceTwinStatus != IotHubStatusCode.OK) {
Thread.sleep(200);
if (System.currentTimeMillis() - startTime > START_TWIN_TIMEOUT_MILLISECONDS) {
fail("Timed out waiting for twin to start");
}
}
DeviceTwinDevice serviceClientTwin;
if (testInstance.clientType == ClientType.DEVICE_CLIENT) {
serviceClientTwin = new DeviceTwinDevice(testInstance.testIdentity.getClient().getConfig().getDeviceId());
} else {
serviceClientTwin = new DeviceTwinDevice(testInstance.testIdentity.getClient().getConfig().getDeviceId(), testInstance.testIdentity.getClient().getConfig().getModuleId());
}
Set<com.microsoft.azure.sdk.iot.service.devicetwin.Pair> desiredProperties = new HashSet<>();
desiredProperties.add(new com.microsoft.azure.sdk.iot.service.devicetwin.Pair(expectedKey1, expectedValue1));
desiredProperties.add(new com.microsoft.azure.sdk.iot.service.devicetwin.Pair(expectedKey2, expectedValue2));
serviceClientTwin.setDesiredProperties(desiredProperties);
testInstance.twinServiceClient.updateTwin(serviceClientTwin);
startTime = System.currentTimeMillis();
while (!desiredPropertiesCallbackState.wasCallbackFired()) {
Thread.sleep(200);
if (System.currentTimeMillis() - startTime > DESIRED_PROPERTIES_PROPAGATION_TIME_MILLISECONDS) {
fail("Timed out waiting for desired properties callback to execute");
}
}
assertTrue("Desired properties callback executed, but with unexpected properties", desiredPropertiesCallbackState.getResult());
}
Aggregations