Search in sources :

Example 41 with Device

use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.

the class DeviceTest method conversionToDeviceParserWithSASAuthentication.

// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_34_018: [This method shall return a new instance of a DeviceParser object that is populated using the properties of this.]
@Test
public void conversionToDeviceParserWithSASAuthentication() {
    // arrange
    Device deviceSAS = Device.createDevice("deviceSAS", AuthenticationType.SAS);
    // act
    DeviceParser parserSAS = reflectivelyInvokeToDeviceParser(deviceSAS);
    // assert
    assertEquals(AuthenticationTypeParser.SAS, parserSAS.getAuthenticationParser().getType());
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) Test(org.junit.Test)

Example 42 with Device

use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.

the class DeviceTest method getScopeGetsScope.

@Test
public void getScopeGetsScope() {
    // arrange
    String scope = "scope";
    Device device = Device.createDevice("device", AuthenticationType.SAS);
    Deencapsulation.setField(device, "scope", scope);
    // act
    String actualScope = device.getScope();
    // assert
    assertEquals(scope, actualScope);
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) Test(org.junit.Test)

Example 43 with Device

use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.

the class DeviceTest method conversionToDeviceParserWithSelfSignedAuthentication.

// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_34_018: [This method shall return a new instance of a DeviceParser object that is populated using the properties of this.]
@Test
public void conversionToDeviceParserWithSelfSignedAuthentication() {
    // arrange
    Device deviceSelf = Device.createDevice("deviceSelf", AuthenticationType.SELF_SIGNED);
    // act
    DeviceParser parserSelf = reflectivelyInvokeToDeviceParser(deviceSelf);
    // assert
    assertEquals(AuthenticationTypeParser.SELF_SIGNED, parserSelf.getAuthenticationParser().getType());
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) Test(org.junit.Test)

Example 44 with Device

use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.

the class DeviceTest method conversionFromDeviceParserWithSelfSignedAuthentication.

// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_34_014: [This constructor shall create a new Device object using the values within the provided parser.]
@Test
public void conversionFromDeviceParserWithSelfSignedAuthentication() {
    // arrange
    DeviceParser parserSelf = new DeviceParser();
    parserSelf.setAuthenticationParser(Deencapsulation.newInstance(AuthenticationParser.class));
    parserSelf.getAuthenticationParser().setType(AuthenticationTypeParser.SELF_SIGNED);
    parserSelf.getAuthenticationParser().setThumbprint(new X509ThumbprintParser(SAMPLE_THUMBPRINT, SAMPLE_THUMBPRINT));
    parserSelf.setDeviceId("deviceSelf");
    // act
    Device deviceSelf = reflectivelyInvokeDeviceParserConstructor(parserSelf);
    // assert
    assertNull(deviceSelf.getSymmetricKey());
    assertNotNull(deviceSelf.getPrimaryThumbprint());
    assertNotNull(deviceSelf.getSecondaryThumbprint());
    assertEquals(AuthenticationType.SELF_SIGNED, deviceSelf.getAuthenticationType());
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) Test(org.junit.Test)

Example 45 with Device

use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.

the class DeviceTest method conversionFromDeviceParserWithCertificateAuthorityAuthentication.

// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_34_014: [This constructor shall create a new Device object using the values within the provided parser.]
@Test
public void conversionFromDeviceParserWithCertificateAuthorityAuthentication() {
    // arrange
    DeviceParser parserCA = new DeviceParser();
    parserCA.setAuthenticationParser(Deencapsulation.newInstance(AuthenticationParser.class));
    parserCA.getAuthenticationParser().setType(AuthenticationTypeParser.CERTIFICATE_AUTHORITY);
    parserCA.setDeviceId("deviceCA");
    // act
    Device deviceCA = reflectivelyInvokeDeviceParserConstructor(parserCA);
    // assert
    assertNull(deviceCA.getPrimaryThumbprint());
    assertNull(deviceCA.getSecondaryThumbprint());
    assertNull(deviceCA.getSymmetricKey());
    assertEquals(AuthenticationType.CERTIFICATE_AUTHORITY, deviceCA.getAuthenticationType());
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) Test(org.junit.Test)

Aggregations

Device (com.microsoft.azure.sdk.iot.service.Device)68 Test (org.junit.Test)46 IntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.IntegrationTest)21 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)19 RegistryManager (com.microsoft.azure.sdk.iot.service.RegistryManager)17 DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)15 StandardTierHubOnlyTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.StandardTierHubOnlyTest)13 DeviceClient (com.microsoft.azure.sdk.iot.device.DeviceClient)12 IOException (java.io.IOException)11 ContinuousIntegrationTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.ContinuousIntegrationTest)11 IotHubTest (tests.integration.com.microsoft.azure.sdk.iot.helpers.annotations.IotHubTest)11 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)10 ArrayList (java.util.ArrayList)10 SymmetricKey (com.microsoft.azure.sdk.iot.service.auth.SymmetricKey)7 RegistryManagerOptions (com.microsoft.azure.sdk.iot.service.RegistryManagerOptions)5 AzureSasCredential (com.azure.core.credential.AzureSasCredential)4 DeviceCapabilities (com.microsoft.azure.sdk.iot.deps.twin.DeviceCapabilities)4 ClientOptions (com.microsoft.azure.sdk.iot.device.ClientOptions)4 DeviceStatus (com.microsoft.azure.sdk.iot.service.DeviceStatus)4 Module (com.microsoft.azure.sdk.iot.service.Module)4