Search in sources :

Example 6 with DeviceCapabilities

use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.

the class DeviceCapabilitiesTest method getIotEdgeSucceed.

/* Tests_SRS_CONFIGURATIONINFO_28_002: [The getStatus shall return the stored `status` content.] */
@Test
public void getIotEdgeSucceed() {
    // arrange
    Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().disableHtmlEscaping().create();
    DeviceCapabilities result = gson.fromJson(DEVICECAPABILITIES_SAMPLE, DeviceCapabilities.class);
    // act - assert
    assertEquals(false, result.isIotEdge());
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) Test(org.junit.Test)

Example 7 with DeviceCapabilities

use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.

the class DeviceCapabilitiesTest method setIotEdgeSucceed.

/* Tests_SRS_CONFIGURATIONINFO_28_001: [The setStatus shall replace the `status` by the provided one.] */
@Test
public void setIotEdgeSucceed() {
    // arrange
    Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().disableHtmlEscaping().create();
    DeviceCapabilities result = gson.fromJson(DEVICECAPABILITIES_SAMPLE, DeviceCapabilities.class);
    // act
    result.setIotEdge(true);
    // assert
    assertEquals(true, Deencapsulation.getField(result, "iotEdge"));
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) Test(org.junit.Test)

Example 8 with DeviceCapabilities

use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.

the class ProvisioningServiceClientTests method createdEnrollmentGroupMatchesSentEnrollmentGroup.

@Test
public void createdEnrollmentGroupMatchesSentEnrollmentGroup() throws ProvisioningServiceClientException {
    String groupId = testPrefix + UUID.randomUUID();
    Attestation attestation = new SymmetricKeyAttestation("", "");
    EnrollmentGroup enrollment = new EnrollmentGroup(groupId, attestation);
    enrollment.setAllocationPolicy(AllocationPolicy.CUSTOM);
    CustomAllocationDefinition customAllocationDefinition = new CustomAllocationDefinition();
    customAllocationDefinition.setApiVersion("2018-09-01-preview");
    customAllocationDefinition.setWebhookUrl(customAllocationWebhookUrl);
    enrollment.setCustomAllocationDefinition(customAllocationDefinition);
    ReprovisionPolicy reprovisionPolicy = new ReprovisionPolicy();
    reprovisionPolicy.setUpdateHubAssignment(true);
    reprovisionPolicy.setMigrateDeviceData(true);
    enrollment.setReprovisionPolicy(reprovisionPolicy);
    DeviceCapabilities capabilities = new DeviceCapabilities();
    capabilities.setIotEdge(true);
    enrollment.setCapabilities(capabilities);
    EnrollmentGroup returnedEnrollment = provisioningServiceClient.createOrUpdateEnrollmentGroup(enrollment);
    assertEquals(enrollment.getEnrollmentGroupId(), returnedEnrollment.getEnrollmentGroupId());
    assertEquals(enrollment.getReprovisionPolicy().getMigrateDeviceData(), returnedEnrollment.getReprovisionPolicy().getMigrateDeviceData());
    assertEquals(enrollment.getReprovisionPolicy().getUpdateHubAssignment(), returnedEnrollment.getReprovisionPolicy().getUpdateHubAssignment());
    assertEquals(enrollment.getCapabilities().isIotEdge(), returnedEnrollment.getCapabilities().isIotEdge());
    assertEquals(enrollment.getAttestation().getClass(), returnedEnrollment.getAttestation().getClass());
    assertEquals(enrollment.getAllocationPolicy(), returnedEnrollment.getAllocationPolicy());
    assertEquals(enrollment.getCustomAllocationDefinition().getApiVersion(), returnedEnrollment.getCustomAllocationDefinition().getApiVersion());
}
Also used : DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) Test(org.junit.Test)

Example 9 with DeviceCapabilities

use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities in project azure-iot-sdk-java by Azure.

the class ProvisioningServiceClientTests method createdIndividualEnrollmentMatchesSentIndividualEnrollment.

@Test
public void createdIndividualEnrollmentMatchesSentIndividualEnrollment() throws ProvisioningServiceClientException {
    String registrationId = testPrefix + UUID.randomUUID();
    Attestation attestation = new SymmetricKeyAttestation("", "");
    IndividualEnrollment enrollment = new IndividualEnrollment(registrationId, attestation);
    enrollment.setAllocationPolicy(AllocationPolicy.GEOLATENCY);
    ReprovisionPolicy reprovisionPolicy = new ReprovisionPolicy();
    reprovisionPolicy.setUpdateHubAssignment(true);
    reprovisionPolicy.setMigrateDeviceData(true);
    enrollment.setReprovisionPolicy(reprovisionPolicy);
    DeviceCapabilities capabilities = new DeviceCapabilities();
    capabilities.setIotEdge(true);
    enrollment.setCapabilities(capabilities);
    IndividualEnrollment returnedEnrollment = provisioningServiceClient.createOrUpdateIndividualEnrollment(enrollment);
    assertEquals(enrollment.getRegistrationId(), returnedEnrollment.getRegistrationId());
    assertEquals(enrollment.getReprovisionPolicy().getMigrateDeviceData(), returnedEnrollment.getReprovisionPolicy().getMigrateDeviceData());
    assertEquals(enrollment.getReprovisionPolicy().getUpdateHubAssignment(), returnedEnrollment.getReprovisionPolicy().getUpdateHubAssignment());
    assertEquals(enrollment.getCapabilities().isIotEdge(), returnedEnrollment.getCapabilities().isIotEdge());
    assertEquals(enrollment.getAttestation().getClass(), returnedEnrollment.getAttestation().getClass());
    assertEquals(enrollment.getAllocationPolicy(), returnedEnrollment.getAllocationPolicy());
}
Also used : DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) Test(org.junit.Test)

Example 10 with DeviceCapabilities

use of com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities 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);
}
Also used : DeviceCapabilities(com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) ContinuousIntegrationTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest) StandardTierHubOnlyTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest) Test(org.junit.Test) DeviceProvisioningServiceTest(tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.DeviceProvisioningServiceTest)

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