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());
}
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);
}
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());
}
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());
}
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());
}
Aggregations