Search in sources :

Example 1 with Storage

use of org.finra.herd.model.api.xml.Storage 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 Storage

use of org.finra.herd.model.api.xml.Storage 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 Storage

use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.

the class MockHttpClientOperationsImpl method buildGetStorageResponse.

/**
 * Builds a Get Storage response.
 *
 * @param response the response.
 * @param uri the URI of the incoming request.
 *
 * @throws JAXBException if a JAXB error occurred.
 */
private void buildGetStorageResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
    Pattern pattern = Pattern.compile("/herd-app/rest/storages/(.*)");
    Matcher matcher = pattern.matcher(uri.getPath());
    if (matcher.find()) {
        Storage storage = getNewStorage(matcher.group(1));
        response.setEntity(getHttpEntity(storage));
    }
}
Also used : Pattern(java.util.regex.Pattern) Storage(org.finra.herd.model.api.xml.Storage) Matcher(java.util.regex.Matcher)

Example 4 with Storage

use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.

the class StorageRestControllerTest method testUpdateStorageAttributes.

@Test
public void testUpdateStorageAttributes() {
    // Create a storage key.
    StorageKey storageKey = new StorageKey(STORAGE_NAME);
    // Create a storage update request.
    StorageAttributesUpdateRequest storageAttributesUpdateRequest = new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes());
    // Create a storage.
    Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, businessObjectDefinitionServiceTestHelper.getNewAttributes());
    // Mock the external calls.
    when(storageService.updateStorageAttributes(storageKey, storageAttributesUpdateRequest)).thenReturn(storage);
    // Call the method under test.
    Storage result = storageRestController.updateStorageAttributes(STORAGE_NAME, storageAttributesUpdateRequest);
    // Verify the external calls.
    verify(storageService).updateStorageAttributes(storageKey, storageAttributesUpdateRequest);
    verifyNoMoreInteractions(storageService);
    // Validate the returned object.
    assertEquals(storage, result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageAttributesUpdateRequest(org.finra.herd.model.api.xml.StorageAttributesUpdateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 5 with Storage

use of org.finra.herd.model.api.xml.Storage in project herd by FINRAOS.

the class StorageRestControllerTest method testGetStorage.

@Test
public void testGetStorage() {
    // Create a storage key.
    StorageKey storageKey = new StorageKey(STORAGE_NAME);
    // Create a storage.
    Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES);
    // Mock the external calls.
    when(storageService.getStorage(storageKey)).thenReturn(storage);
    // Call the method under test.
    Storage result = storageRestController.getStorage(STORAGE_NAME);
    // Verify the external calls.
    verify(storageService).getStorage(storageKey);
    verifyNoMoreInteractions(storageService);
    // Validate the returned object.
    assertEquals(storage, result);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Aggregations

Storage (org.finra.herd.model.api.xml.Storage)38 Test (org.junit.Test)29 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)19 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)17 Attribute (org.finra.herd.model.api.xml.Attribute)10 StorageKey (org.finra.herd.model.api.xml.StorageKey)10 ArrayList (java.util.ArrayList)6 StorageCreateRequest (org.finra.herd.model.api.xml.StorageCreateRequest)6 File (java.io.File)5 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)4 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)4 StorageAttributesUpdateRequest (org.finra.herd.model.api.xml.StorageAttributesUpdateRequest)4 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)4 DownloaderInputManifestDto (org.finra.herd.model.dto.DownloaderInputManifestDto)4 DownloaderOutputManifestDto (org.finra.herd.model.dto.DownloaderOutputManifestDto)4 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)4 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 AwsCredential (org.finra.herd.model.api.xml.AwsCredential)3 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)3