use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.
the class ProvisioningTests method reprovisioningFlow.
// Since this is a helper method, the params can be passed any value.
@SuppressWarnings("SameParameterValue")
protected void reprovisioningFlow(EnrollmentType enrollmentType, AllocationPolicy allocationPolicy, ReprovisionPolicy reprovisionPolicy, CustomAllocationDefinition customAllocationDefinition, List<String> iothubsToStartAt, List<String> iothubsToFinishAt) throws Exception {
DeviceCapabilities capabilities = new DeviceCapabilities();
capabilities.setIotEdge(false);
reprovisioningFlow(enrollmentType, allocationPolicy, reprovisionPolicy, customAllocationDefinition, iothubsToStartAt, iothubsToFinishAt, capabilities);
}
use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.
the class RegisterManagerTest method registerManagerDeserializerSucceed.
/* Codes_SRS_REGISTER_MANAGER_21_007: [The RegisterManager shall provide an empty constructor to make GSON happy.] */
@Test
public void registerManagerDeserializerSucceed() {
// arrange
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().disableHtmlEscaping().create();
RegisterManager result = gson.fromJson(REGISTER_MANAGER_SAMPLE, RegisterManager.class);
// act - assert
assertEquals("validDeviceId", Deencapsulation.getField(result, "deviceId"));
assertEquals("validModuleId", Deencapsulation.getField(result, "moduleId"));
assertEquals("validGenerationId", Deencapsulation.getField(result, "generationId"));
assertEquals(3, Deencapsulation.getField(result, "version"));
assertEquals("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", Deencapsulation.getField(result, "eTag"));
assertEquals("ENABLED", Deencapsulation.getField(result, "status").toString());
assertEquals("validStatusReason", Deencapsulation.getField(result, "statusReason"));
assertEquals("2016-06-01T21:22:41+00:00", Deencapsulation.getField(result, "statusUpdatedTime"));
assertEquals("DISCONNECTED", Deencapsulation.getField(result, "connectionState").toString());
assertEquals("2016-06-01T21:22:41+00:00", Deencapsulation.getField(result, "connectionStateUpdatedTime"));
DeviceCapabilities dc = Deencapsulation.getField(result, "capabilities");
assertEquals(true, Deencapsulation.getField(dc, "iotEdge"));
}
use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.
the class RegistryManagerTests method deviceCreationWithDeviceScope.
@StandardTierHubOnlyTest
@Test
@ContinuousIntegrationTest
public void deviceCreationWithDeviceScope() throws IOException, InterruptedException, IotHubException, URISyntaxException {
// Arrange
this.testInstance = new RegistryManagerTestInstance();
String edge1Id = deviceIdPrefix + UUID.randomUUID().toString();
String edge2Id = deviceIdPrefix + UUID.randomUUID().toString();
String deviceId = this.testInstance.deviceId;
// -Create-//
Device edgeDevice1 = Device.createFromId(edge1Id, DeviceStatus.Enabled, null);
DeviceCapabilities capabilities = new DeviceCapabilities();
capabilities.setIotEdge(true);
edgeDevice1.setCapabilities(capabilities);
edgeDevice1 = Tools.addDeviceWithRetry(this.testInstance.registryManager, edgeDevice1);
Device edgeDevice2 = Device.createFromId(edge2Id, DeviceStatus.Enabled, null);
capabilities.setIotEdge(true);
edgeDevice2.setCapabilities(capabilities);
// set edge1 as parent
edgeDevice2.getParentScopes().add(edgeDevice1.getScope());
edgeDevice2 = Tools.addDeviceWithRetry(this.testInstance.registryManager, edgeDevice2);
Device leafDevice = Device.createFromId(deviceId, DeviceStatus.Enabled, null);
assertNotNull(edgeDevice1.getScope());
leafDevice.setScope(edgeDevice1.getScope());
Tools.addDeviceWithRetry(this.testInstance.registryManager, leafDevice);
// -Read-//
Device deviceRetrieved = this.testInstance.registryManager.getDevice(deviceId);
// -Delete-//
this.testInstance.registryManager.removeDevice(edge1Id);
this.testInstance.registryManager.removeDevice(edge2Id);
this.testInstance.registryManager.removeDevice(deviceId);
// Assert
assertEquals(buildExceptionMessage("Edge parent scope did not match parent's device scope", hostName), edgeDevice2.getParentScopes().get(0), edgeDevice1.getScope());
assertNotEquals(buildExceptionMessage("Child edge device scope should be it's own", hostName), edgeDevice2.getScope(), edgeDevice1.getScope());
assertEquals(buildExceptionMessage("Registered device Id is not correct", hostName), deviceId, leafDevice.getDeviceId());
assertEquals(buildExceptionMessage("Device scopes did not match", hostName), deviceRetrieved.getScope(), edgeDevice1.getScope());
assertEquals(buildExceptionMessage("Device's first parent scope did not match device scope", hostName), deviceRetrieved.getParentScopes().get(0), deviceRetrieved.getScope());
}
use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.
the class IndividualEnrollmentTest method setDeviceCapabilitiesSucceed.
/* SRS_INDIVIDUAL_ENROLLMENT_34_054: [This function shall return the saved capabilities.] */
@Test
public void setDeviceCapabilitiesSucceed() {
// arrange
IndividualEnrollment individualEnrollment = makeStandardEnrollment();
final DeviceCapabilities capabilities = new DeviceCapabilities();
assertNotEquals(capabilities, Deencapsulation.getField(individualEnrollment, "capabilities"));
// act
Deencapsulation.invoke(individualEnrollment, "setCapabilities", new Class[] { DeviceCapabilities.class }, capabilities);
// assert
assertEquals(capabilities, Deencapsulation.getField(individualEnrollment, "capabilities"));
}
Aggregations