use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method constructorSavesDeviceIdAndAuthType.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_34_051: [This constructor shall save the provided deviceId and authenticationType to itself.]
@Test
public void constructorSavesDeviceIdAndAuthType() {
// arrange
String deviceId = "someDevice";
// act
ExportImportDevice device = new ExportImportDevice(deviceId, AuthenticationType.CERTIFICATE_AUTHORITY);
// assert
assertEquals(AuthenticationType.CERTIFICATE_AUTHORITY, device.getAuthenticationFinal().getAuthenticationType());
assertEquals(deviceId, device.getId());
}
use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method conversionFromDeviceParser.
// Tests_SRS_SERVICE_SDK_JAVA_IMPORT_EXPORT_DEVICE_34_052: [This constructor shall use the properties of the provided parser object to set the new ExportImportDevice's properties.]
@Test
public void conversionFromDeviceParser() {
// arrange
ExportImportDeviceParser parserCA = new ExportImportDeviceParser();
parserCA.setAuthentication(Deencapsulation.newInstance(AuthenticationParser.class));
parserCA.getAuthenticationFinal().setType(AuthenticationTypeParser.CERTIFICATE_AUTHORITY);
parserCA.setStatus("Enabled");
parserCA.setImportMode("Create");
parserCA.setId("deviceCA");
ExportImportDeviceParser parserSelf = new ExportImportDeviceParser();
parserSelf.setAuthentication(Deencapsulation.newInstance(AuthenticationParser.class));
parserSelf.getAuthenticationFinal().setType(AuthenticationTypeParser.SELF_SIGNED);
parserSelf.getAuthenticationFinal().setThumbprint(new X509ThumbprintParser(SAMPLE_THUMBPRINT, SAMPLE_THUMBPRINT));
parserSelf.setId("deviceSelf");
ExportImportDeviceParser parserSAS = new ExportImportDeviceParser();
parserSAS.setAuthentication(Deencapsulation.newInstance(AuthenticationParser.class));
parserSAS.getAuthenticationFinal().setType(AuthenticationTypeParser.SAS);
parserSAS.getAuthenticationFinal().setSymmetricKey(new SymmetricKeyParser(SAMPLE_THUMBPRINT, SAMPLE_THUMBPRINT));
parserSAS.setId("deviceSAS");
// act
ExportImportDevice deviceCA = reflectivelyInvokeExportImportDeviceParserConstructor(parserCA);
ExportImportDevice deviceSelf = reflectivelyInvokeExportImportDeviceParserConstructor(parserSelf);
ExportImportDevice deviceSAS = reflectivelyInvokeExportImportDeviceParserConstructor(parserSAS);
// assert
assertEquals(AuthenticationType.CERTIFICATE_AUTHORITY, deviceCA.getAuthenticationFinal().getAuthenticationType());
assertEquals(AuthenticationType.SELF_SIGNED, deviceSelf.getAuthenticationFinal().getAuthenticationType());
assertEquals(AuthenticationType.SAS, deviceSAS.getAuthenticationFinal().getAuthenticationType());
assertEquals(ImportMode.Create, deviceCA.getImportMode());
assertEquals(DeviceStatus.Enabled, deviceCA.getStatus());
}
use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportTests method export_import_storage_auth_e2e.
private static void export_import_storage_auth_e2e(StorageAuthenticationType storageAuthenticationType) throws Exception {
List<ExportImportDevice> devicesForImport = createListofDevices();
// importing devices - create mode
runImportJob(devicesForImport, ImportMode.CreateOrUpdate, Optional.of(storageAuthenticationType));
List<ExportImportDevice> exportedDevices = runExportJob(Optional.of(storageAuthenticationType));
for (ExportImportDevice importedDevice : devicesForImport) {
if (!exportedDevices.contains(importedDevice)) {
Assert.fail("Exported devices list does not contain device with id: " + importedDevice.getId());
}
}
// importing devices - delete mode
runImportJob(devicesForImport, ImportMode.Delete, Optional.of(storageAuthenticationType));
exportedDevices = runExportJob(Optional.of(storageAuthenticationType));
for (ExportImportDevice importedDevice : devicesForImport) {
if (exportedDevices.contains(importedDevice)) {
Assert.fail("Device with id: " + importedDevice.getId() + " was not deleted by the import job");
}
}
}
Aggregations