use of org.finra.herd.model.api.xml.StorageUnit in project herd by FINRAOS.
the class DownloaderControllerTest method testCreateDownloaderOutputManifestDtoAssertOutputFilesEmptyWhenStorageFilesNull.
@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());
}
use of org.finra.herd.model.api.xml.StorageUnit in project herd by FINRAOS.
the class DownloaderWebClientTest method toBusinessObjectData.
private BusinessObjectData toBusinessObjectData(final UploaderInputManifestDto uploaderInputManifestDto) {
BusinessObjectData businessObjectData = new BusinessObjectData();
businessObjectData.setNamespace(uploaderInputManifestDto.getNamespace());
businessObjectData.setBusinessObjectDefinitionName(uploaderInputManifestDto.getBusinessObjectDefinitionName());
businessObjectData.setBusinessObjectFormatUsage(uploaderInputManifestDto.getBusinessObjectFormatUsage());
businessObjectData.setBusinessObjectFormatFileType(uploaderInputManifestDto.getBusinessObjectFormatFileType());
businessObjectData.setBusinessObjectFormatVersion(Integer.valueOf(uploaderInputManifestDto.getBusinessObjectFormatVersion()));
businessObjectData.setPartitionKey(uploaderInputManifestDto.getPartitionKey());
businessObjectData.setPartitionValue(uploaderInputManifestDto.getPartitionValue());
businessObjectData.setSubPartitionValues(uploaderInputManifestDto.getSubPartitionValues());
businessObjectData.setVersion(TEST_DATA_VERSION_V0);
businessObjectData.setStorageUnits(Arrays.asList(new StorageUnit(new Storage(StorageEntity.MANAGED_STORAGE, null, null), null, null, null, null, null, null)));
return businessObjectData;
}
use of org.finra.herd.model.api.xml.StorageUnit in project herd by FINRAOS.
the class StorageFileHelperTest method testValidateDownloadedS3FilesFileNoExists.
@Test
public void testValidateDownloadedS3FilesFileNoExists() throws IOException {
File targetLocalDirectory = Paths.get(LOCAL_TEMP_PATH.toString(), TEST_S3_KEY_PREFIX).toFile();
createLocalFile(targetLocalDirectory.getPath(), "ACTUAL_FILE", FILE_SIZE_1_KB);
StorageUnit storageUnit = createStorageUnit(TEST_S3_KEY_PREFIX, Arrays.asList("EXPECTED_FILE"), FILE_SIZE_1_KB);
// Try to validate non-existing local files.
try {
storageFileHelper.validateDownloadedS3Files(LOCAL_TEMP_PATH.toString(), TEST_S3_KEY_PREFIX, storageUnit);
fail("Should throw a RuntimeException when actual local files do not exist.");
} catch (RuntimeException e) {
String expectedErrMsg = String.format("Downloaded \"%s\" file doesn't exist.", Paths.get(LOCAL_TEMP_PATH.toString(), storageUnit.getStorageFiles().get(0).getFilePath()).toFile().getPath());
assertEquals(expectedErrMsg, e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageUnit in project herd by FINRAOS.
the class StorageFileHelperTest method testValidateStorageUnitS3Files.
@Test
public void testValidateStorageUnitS3Files() throws IOException {
StorageUnit storageUnit = createStorageUnit(TEST_S3_KEY_PREFIX, LOCAL_FILES, FILE_SIZE_1_KB);
List<String> actualS3Files = new ArrayList<>();
for (String file : LOCAL_FILES) {
actualS3Files.add(String.format("%s/%s", TEST_S3_KEY_PREFIX, file));
}
storageFileHelper.validateStorageUnitS3Files(storageUnit, actualS3Files, TEST_S3_KEY_PREFIX);
}
use of org.finra.herd.model.api.xml.StorageUnit in project herd by FINRAOS.
the class StorageFileHelperTest method testValidateDownloadedS3FilesZeroFiles.
@Test
public void testValidateDownloadedS3FilesZeroFiles() throws IOException {
File targetLocalDirectory = Paths.get(LOCAL_TEMP_PATH.toString(), TEST_S3_KEY_PREFIX).toFile();
// Create an empty target local directory.
assertTrue(targetLocalDirectory.mkdirs());
// Create a storage unit entity without any storage files.
StorageUnit storageUnit = createStorageUnit(TEST_S3_KEY_PREFIX, null, null);
// Validate an empty set of the downloaded S3 files.
storageFileHelper.validateDownloadedS3Files(LOCAL_TEMP_PATH.toString(), TEST_S3_KEY_PREFIX, storageUnit);
}
Aggregations