Search in sources :

Example 1 with StorageUnit

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());
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) DownloaderOutputManifestDto(org.finra.herd.model.dto.DownloaderOutputManifestDto) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) Test(org.junit.Test)

Example 2 with StorageUnit

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;
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) StorageUnit(org.finra.herd.model.api.xml.StorageUnit)

Example 3 with StorageUnit

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());
    }
}
Also used : StorageUnit(org.finra.herd.model.api.xml.StorageUnit) File(java.io.File) StorageFile(org.finra.herd.model.api.xml.StorageFile) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 4 with StorageUnit

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);
}
Also used : ArrayList(java.util.ArrayList) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 5 with StorageUnit

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);
}
Also used : StorageUnit(org.finra.herd.model.api.xml.StorageUnit) File(java.io.File) StorageFile(org.finra.herd.model.api.xml.StorageFile) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

StorageUnit (org.finra.herd.model.api.xml.StorageUnit)37 Test (org.junit.Test)29 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)23 Storage (org.finra.herd.model.api.xml.Storage)19 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)15 StorageFile (org.finra.herd.model.api.xml.StorageFile)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 Attribute (org.finra.herd.model.api.xml.Attribute)9 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 BusinessObjectDataInvalidateUnregisteredRequest (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest)4 BusinessObjectDataInvalidateUnregisteredResponse (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse)4 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)4 DownloaderInputManifestDto (org.finra.herd.model.dto.DownloaderInputManifestDto)4 DownloaderOutputManifestDto (org.finra.herd.model.dto.DownloaderOutputManifestDto)4 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)4 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)4 Path (java.nio.file.Path)3 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)3