use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class TwinTagsTests method testAddTagUpdates.
@Test
@StandardTierHubOnlyTest
public void testAddTagUpdates() throws IOException, InterruptedException, IotHubException, GeneralSecurityException, URISyntaxException, ModuleClientException {
addMultipleDevices(MAX_DEVICES);
// Update tag for multiple devices
for (int i = 0; i < MAX_DEVICES; i++) {
Set<Pair> tags = new HashSet<>();
tags.add(new Pair(TAG_KEY + i, TAG_VALUE + i));
testInstance.devicesUnderTest[i].sCDeviceForTwin.setTags(tags);
testInstance.twinServiceClient.updateTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
Thread.sleep(DELAY_BETWEEN_OPERATIONS);
testInstance.devicesUnderTest[i].sCDeviceForTwin.clearTwin();
}
// Read updates on multiple devices
for (int i = 0; i < MAX_DEVICES; i++) {
testInstance.twinServiceClient.getTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
Thread.sleep(DELAY_BETWEEN_OPERATIONS);
for (Pair t : testInstance.devicesUnderTest[i].sCDeviceForTwin.getTags()) {
assertEquals(buildExceptionMessage("unexpected tag key, expected " + TAG_KEY + i + " but was " + t.getKey(), testInstance.testIdentity.getClient()), TAG_KEY + i, t.getKey());
assertEquals(buildExceptionMessage("Unexpected tag value, expected " + TAG_VALUE + i + " but was " + t.getValue(), testInstance.testIdentity.getClient()), TAG_VALUE + i, t.getValue());
}
}
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class TwinTagsTests method testUpdateTagUpdates.
@Test
@StandardTierHubOnlyTest
public void testUpdateTagUpdates() throws IOException, InterruptedException, IotHubException, GeneralSecurityException, URISyntaxException, ModuleClientException {
addMultipleDevices(MAX_DEVICES);
// Add tag for multiple devices
for (int i = 0; i < MAX_DEVICES; i++) {
Set<Pair> tags = new HashSet<>();
tags.add(new Pair(TAG_KEY + i, TAG_VALUE + i));
testInstance.devicesUnderTest[i].sCDeviceForTwin.setTags(tags);
testInstance.twinServiceClient.updateTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
testInstance.devicesUnderTest[i].sCDeviceForTwin.clearTwin();
}
// Update Tags on multiple devices
for (int i = 0; i < MAX_DEVICES; i++) {
testInstance.twinServiceClient.getTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
Set<Pair> tags = testInstance.devicesUnderTest[i].sCDeviceForTwin.getTags();
for (Pair tag : tags) {
tag.setValue(TAG_VALUE_UPDATE + i);
}
testInstance.devicesUnderTest[i].sCDeviceForTwin.setTags(tags);
testInstance.twinServiceClient.updateTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
testInstance.devicesUnderTest[i].sCDeviceForTwin.clearTwin();
}
// Read updates on multiple devices
for (int i = 0; i < MAX_DEVICES; i++) {
testInstance.twinServiceClient.getTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
for (Pair t : testInstance.devicesUnderTest[i].sCDeviceForTwin.getTags()) {
assertEquals(buildExceptionMessage("unexpected tag key, expected " + TAG_KEY + i + " but was " + t.getKey(), testInstance.testIdentity.getClient()), TAG_KEY + i, t.getKey());
assertEquals(buildExceptionMessage("Unexpected tag value, expected " + TAG_VALUE + i + " but was " + t.getValue(), testInstance.testIdentity.getClient()), TAG_VALUE_UPDATE + i, t.getValue());
}
}
// Delete tags
for (int i = 0; i < MAX_DEVICES; i++) {
testInstance.twinServiceClient.getTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
Set<Pair> tags = testInstance.devicesUnderTest[i].sCDeviceForTwin.getTags();
for (Pair tag : tags) {
tag.setValue(null);
}
testInstance.devicesUnderTest[i].sCDeviceForTwin.setTags(tags);
testInstance.twinServiceClient.updateTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
testInstance.devicesUnderTest[i].sCDeviceForTwin.clearTwin();
}
// Verify tags were deleted successfully
for (int i = 0; i < MAX_DEVICES; i++) {
testInstance.twinServiceClient.getTwin(testInstance.devicesUnderTest[i].sCDeviceForTwin);
assertEquals(buildExceptionMessage("Tags were not deleted by being set null", testInstance.testIdentity.getClient()), 0, testInstance.devicesUnderTest[i].sCDeviceForTwin.getTags().size());
}
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class ProvisioningTests method groupEnrollmentReprovisioningCanKeepTwin.
@Test
@StandardTierHubOnlyTest
public void groupEnrollmentReprovisioningCanKeepTwin() throws Exception {
ReprovisionPolicy reprovisionPolicy = new ReprovisionPolicy();
reprovisionPolicy.setMigrateDeviceData(true);
reprovisionPolicy.setUpdateHubAssignment(true);
DeviceCapabilities deviceCapabilities = new DeviceCapabilities();
deviceCapabilities.setIotEdge(true);
reprovisioningFlow(EnrollmentType.GROUP, null, reprovisionPolicy, null, getStartingHubs(), getHubsToReprovisionTo(), deviceCapabilities);
}
use of tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest in project azure-iot-sdk-java by Azure.
the class DigitalTwinClientTests method getMultiplexedDigitalTwinsRegisteredBeforeOpen.
// Open a multiplexed connection with two devices, each with a different model Id. Verify that their reported twin has
// the expected model Ids.
@Test
@StandardTierHubOnlyTest
public void getMultiplexedDigitalTwinsRegisteredBeforeOpen() throws IotHubException, IOException, URISyntaxException, MultiplexingClientException, InterruptedException {
if (protocol == MQTT || protocol == MQTT_WS) {
// multiplexing isn't supported over MQTT, so it can't be tested
return;
}
MultiplexingClient multiplexingClient = new MultiplexingClient(deviceClient.getConfig().getIotHubHostname(), protocol);
List<DeviceClient> multiplexedDeviceClients = new ArrayList<>();
multiplexedDeviceClients.add(createDeviceClient(protocol, E2ETestConstants.THERMOSTAT_MODEL_ID));
multiplexedDeviceClients.add(createDeviceClient(protocol, E2ETestConstants.TEMPERATURE_CONTROLLER_MODEL_ID));
// register the devices before the multiplexing client has been opened
multiplexingClient.registerDeviceClients(multiplexedDeviceClients);
multiplexingClient.open();
// act
String thermostatDeviceId = multiplexedDeviceClients.get(0).getConfig().getDeviceId();
BasicDigitalTwin thermostatResponse = digitalTwinClient.getDigitalTwin(thermostatDeviceId, BasicDigitalTwin.class);
ServiceResponseWithHeaders<BasicDigitalTwin, DigitalTwinGetHeaders> thermostatResponseWithHeaders = digitalTwinClient.getDigitalTwinWithResponse(thermostatDeviceId, BasicDigitalTwin.class);
String temperatureControllerDeviceId = multiplexedDeviceClients.get(1).getConfig().getDeviceId();
BasicDigitalTwin temperatureControllerResponse = digitalTwinClient.getDigitalTwin(temperatureControllerDeviceId, BasicDigitalTwin.class);
ServiceResponseWithHeaders<BasicDigitalTwin, DigitalTwinGetHeaders> temperatureControllerResponseWithHeaders = digitalTwinClient.getDigitalTwinWithResponse(temperatureControllerDeviceId, BasicDigitalTwin.class);
// assert
assertEquals(thermostatResponse.getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
assertEquals(thermostatResponseWithHeaders.body().getMetadata().getModelId(), E2ETestConstants.THERMOSTAT_MODEL_ID);
assertEquals(temperatureControllerResponse.getMetadata().getModelId(), E2ETestConstants.TEMPERATURE_CONTROLLER_MODEL_ID);
assertEquals(temperatureControllerResponseWithHeaders.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 getDigitalTwinWithAzureSasCredential.
@Test
@StandardTierHubOnlyTest
public void getDigitalTwinWithAzureSasCredential() {
if (protocol != MQTT) {
// This test is for the service client, so no need to rerun it for all the different device protocols
return;
}
// arrange
digitalTwinClient = buildDigitalTwinClientWithAzureSasCredential();
// 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);
}
Aggregations