DownloaderController extends DataBridgeController { protected DownloaderOutputManifestDto createDownloaderOutputManifestDto(BusinessObjectData businessObjectData, StorageUnit storageUnit, String s3KeyPrefix) { DownloaderOutputManifestDto downloaderOutputManifestDto = new DownloaderOutputManifestDto(); downloaderOutputManifestDto.setNamespace(businessObjectData.getNamespace()); downloaderOutputManifestDto.setBusinessObjectDefinitionName(businessObjectData.getBusinessObjectDefinitionName()); downloaderOutputManifestDto.setBusinessObjectFormatUsage(businessObjectData.getBusinessObjectFormatUsage()); downloaderOutputManifestDto.setBusinessObjectFormatFileType(businessObjectData.getBusinessObjectFormatFileType()); downloaderOutputManifestDto.setBusinessObjectFormatVersion(String.valueOf(businessObjectData.getBusinessObjectFormatVersion())); downloaderOutputManifestDto.setPartitionKey(businessObjectData.getPartitionKey()); downloaderOutputManifestDto.setPartitionValue(businessObjectData.getPartitionValue()); downloaderOutputManifestDto.setSubPartitionValues(businessObjectData.getSubPartitionValues()); downloaderOutputManifestDto.setBusinessObjectDataVersion(String.valueOf(businessObjectData.getVersion())); downloaderOutputManifestDto.setStorageName(storageUnit.getStorage().getName()); List<ManifestFile> manifestFiles = new ArrayList<>(); downloaderOutputManifestDto.setManifestFiles(manifestFiles); if (!CollectionUtils.isEmpty(storageUnit.getStorageFiles())) { for (StorageFile storageFile : storageUnit.getStorageFiles()) { ManifestFile manifestFile = new ManifestFile(); manifestFiles.add(manifestFile); manifestFile.setFileName(storageFile.getFilePath().replace(s3KeyPrefix, "")); manifestFile.setFileSizeBytes(storageFile.getFileSizeBytes()); manifestFile.setRowCount(storageFile.getRowCount()); } } HashMap<String, String> attributes = new HashMap<>(); if (!CollectionUtils.isEmpty(businessObjectData.getAttributes())) { for (Attribute attribute : businessObjectData.getAttributes()) { attributes.put(attribute.getName(), attribute.getValue()); } } downloaderOutputManifestDto.setAttributes(attributes); downloaderOutputManifestDto.setBusinessObjectDataParents(businessObjectData.getBusinessObjectDataParents()); downloaderOutputManifestDto.setBusinessObjectDataChildren(businessObjectData.getBusinessObjectDataChildren()); return downloaderOutputManifestDto; }  @SuppressFBWarnings(value = {"BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"}, justification = "manifestReader.readJsonManifest will always return an DownloaderInputManifestDto object. targetLocalDirectory.list().length will not" + " return a NullPointerException.") void performDownload(RegServerAccessParamsDto regServerAccessParamsDto, File manifestPath,
        S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto);  }
@Test public void testCreateDownloaderOutputManifestDto() { List<String> subPartitionValues = Arrays.asList("subPartitionValue1", "subPartitionValue2", "subPartitionValue3", "subPartitionValue4"); String s3KeyPrefix = "s3KeyPrefix"; StorageUnit storageUnit = new StorageUnit(new Storage("storageName", s3KeyPrefix, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); Attribute attribute = new Attribute("name", "value"); BusinessObjectData businessObjectData = new BusinessObjectData(1234, "businessObjectDefinitionNamespace", "businessObjectDefinitionName", "formatUsage", "formatFileType", 2345, "partitionKey", "partitionValue", subPartitionValues, 3456, true, BusinessObjectDataStatusEntity.VALID, Arrays.asList(storageUnit), Arrays.asList(attribute), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), null); DownloaderOutputManifestDto resultDto = downloaderController.createDownloaderOutputManifestDto(businessObjectData, storageUnit, s3KeyPrefix); assertEquals("businessObjectDefinitionNamespace", resultDto.getNamespace()); assertEquals("businessObjectDefinitionName", resultDto.getBusinessObjectDefinitionName()); assertEquals("formatUsage", resultDto.getBusinessObjectFormatUsage()); assertEquals("formatFileType", resultDto.getBusinessObjectFormatFileType()); assertEquals("2345", resultDto.getBusinessObjectFormatVersion()); assertEquals("partitionKey", resultDto.getPartitionKey()); assertEquals("partitionValue", resultDto.getPartitionValue()); assertEquals(subPartitionValues, resultDto.getSubPartitionValues()); assertEquals("3456", resultDto.getBusinessObjectDataVersion()); assertEquals("storageName", resultDto.getStorageName()); HashMap<String, String> expectedAttributes = new HashMap<>(); expectedAttributes.put(attribute.getName(), attribute.getValue()); assertEquals(expectedAttributes, resultDto.getAttributes()); assertEquals(new ArrayList<>(), resultDto.getBusinessObjectDataParents()); assertEquals(new ArrayList<>(), resultDto.getBusinessObjectDataChildren()); }
@Test public void testCreateDownloaderOutputManifestDtoAssertOutputFilesEmptyWhenStorageFilesNull() { BusinessObjectData businessObjectData = new BusinessObjectData(); StorageUnit storageUnit = new StorageUnit(new Storage("storageName", null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); String s3KeyPrefix = "s3KeyPrefix"; DownloaderOutputManifestDto actual = downloaderController.createDownloaderOutputManifestDto(businessObjectData, storageUnit, s3KeyPrefix); assertEquals(0, actual.getManifestFiles().size()); }
@Test public void testCreateDownloaderOutputManifestDtoAssertOutputAttributesSetWhenBdataAttributesSet() { BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setAttributes(new ArrayList<>()); businessObjectData.getAttributes().add(new Attribute("name", "value")); StorageUnit storageUnit = new StorageUnit(new Storage("storageName", null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); String s3KeyPrefix = "s3KeyPrefix"; DownloaderOutputManifestDto actual = downloaderController.createDownloaderOutputManifestDto(businessObjectData, storageUnit, s3KeyPrefix); assertEquals(1, actual.getAttributes().size()); assertEquals("value", actual.getAttributes().get("name")); }