Search in sources :

Example 11 with DeviceCapabilities

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);
}
Also used : DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities)

Example 12 with DeviceCapabilities

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"));
}
Also used : RegisterManager(com.microsoft.azure.sdk.iot.deps.twin.RegisterManager) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) Test(org.junit.Test)

Example 13 with DeviceCapabilities

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());
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) 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 14 with DeviceCapabilities

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"));
}
Also used : DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) Test(org.junit.Test)

Aggregations

DeviceCapabilities (com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities)14 Test (org.junit.Test)12 Device (com.microsoft.azure.sdk.iot.service.Device)4 Gson (com.google.gson.Gson)3 GsonBuilder (com.google.gson.GsonBuilder)3 ContinuousIntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)2 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)2 RegisterManager (com.microsoft.azure.sdk.iot.deps.twin.RegisterManager)1 DeviceConnectionState (com.microsoft.azure.sdk.iot.service.DeviceConnectionState)1 DeviceStatus (com.microsoft.azure.sdk.iot.service.DeviceStatus)1 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)1 RegistryManager (com.microsoft.azure.sdk.iot.service.RegistryManager)1 SymmetricKey (com.microsoft.azure.sdk.iot.service.auth.SymmetricKey)1 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)1 IOException (java.io.IOException)1 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)1 DeviceProvisioningServiceTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.DeviceProvisioningServiceTest)1 IotHubTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest)1