Search in sources :

Example 16 with StorageDirectory

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

the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesStorageDirectoryEndsWithSlash.

@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesStorageDirectoryEndsWithSlash() throws Exception {
    // Create a business object format entity.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
    // Create a business object data status entity.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    // Create and upload to S3 managed storage a set of test files.
    businessObjectDataServiceTestHelper.prepareTestS3Files(testS3KeyPrefix, localTempPath, LOCAL_FILES);
    // Create an S3 storage entity with a bucket name attribute with a value matching to the test S3 managed storage (required for unit test clean up).
    String testBucketName = storageDaoTestHelper.getS3ManagedBucketName();
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), testBucketName);
    // Build a new business object data create request with enabled discovery of storage files and with storage directory ending with a slash.
    String testStorageDirectoryPath = testS3KeyPrefix + "/";
    BusinessObjectDataCreateRequest request = new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BDATA_STATUS, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(testStorageDirectoryPath), NO_STORAGE_FILES, DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION);
    // Create the business object data.
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
    // Verify the results.
    assertEquals(new BusinessObjectData(resultBusinessObjectData.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, Arrays.asList(new StorageUnit(new Storage(STORAGE_NAME, StoragePlatformEntity.S3, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), testBucketName))), new StorageDirectory(testStorageDirectoryPath), businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, SORTED_LOCAL_FILES, false), StorageUnitStatusEntity.ENABLED, NO_STORAGE_UNIT_STATUS_HISTORY, NO_STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, NO_RESTORE_EXPIRATION_ON)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, NO_BUSINESS_OBJECT_DATA_STATUS_HISTORY), resultBusinessObjectData);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) StorageUnitCreateRequest(org.finra.herd.model.api.xml.StorageUnitCreateRequest) Test(org.junit.Test)

Example 17 with StorageDirectory

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

the class StorageUnitHelperTest method testCreateStorageUnitsFromEntities.

@Test
public void testCreateStorageUnitsFromEntities() {
    // Create a business object data storage unit key.
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME);
    Timestamp restoredExpirationOn = new Timestamp(new Date().getTime());
    // Create a storage unit entity.
    StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS);
    storageUnitEntity.setDirectoryPath(STORAGE_DIRECTORY_PATH);
    storageUnitEntity.setStoragePolicyTransitionFailedAttempts(STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS);
    storageUnitEntity.setRestoreExpirationOn(restoredExpirationOn);
    // Call the method under test.
    List<StorageUnit> result = storageUnitHelper.createStorageUnitsFromEntities(Arrays.asList(storageUnitEntity), NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Verify the external calls.
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(Arrays.asList(new StorageUnit(new Storage(STORAGE_NAME, StoragePlatformEntity.S3, null), new StorageDirectory(STORAGE_DIRECTORY_PATH), null, STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS_HISTORY, STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, HerdDateUtils.getXMLGregorianCalendarValue(restoredExpirationOn))), result);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) Storage(org.finra.herd.model.api.xml.Storage) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) Timestamp(java.sql.Timestamp) Date(java.util.Date) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 18 with StorageDirectory

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

the class BusinessObjectDataStorageUnitServiceImplTest method testCreateBusinessObjectDataStorageUnitCreateResponseDirectoryOnlyRegistration.

@Test
public void testCreateBusinessObjectDataStorageUnitCreateResponseDirectoryOnlyRegistration() {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data storage unit key.
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME);
    // Create a storage unit entity.
    StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS);
    storageUnitEntity.setDirectoryPath(STORAGE_DIRECTORY_PATH);
    // Create an expected business object data storage unit response.
    BusinessObjectDataStorageUnitCreateResponse expectedResponse = new BusinessObjectDataStorageUnitCreateResponse(businessObjectDataStorageUnitKey, new StorageDirectory(STORAGE_DIRECTORY_PATH), null);
    // Mock the external calls.
    when(businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData())).thenReturn(businessObjectDataKey);
    when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey);
    // Call the method under test.
    BusinessObjectDataStorageUnitCreateResponse result = businessObjectDataStorageUnitServiceImpl.createBusinessObjectDataStorageUnitCreateResponse(storageUnitEntity);
    // Verify the external calls.
    verify(businessObjectDataHelper).createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData());
    verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(expectedResponse, result);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) BusinessObjectDataStorageUnitCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Aggregations

StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)18 Test (org.junit.Test)12 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)9 StorageUnitCreateRequest (org.finra.herd.model.api.xml.StorageUnitCreateRequest)9 StorageFile (org.finra.herd.model.api.xml.StorageFile)7 BusinessObjectDataStorageUnitCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)6 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)6 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)5 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)5 ArrayList (java.util.ArrayList)4 Attribute (org.finra.herd.model.api.xml.Attribute)4 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)4 BusinessObjectDataStorageUnitCreateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse)4 Storage (org.finra.herd.model.api.xml.Storage)4 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)4 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)3 StorageEntity (org.finra.herd.model.jpa.StorageEntity)3 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)2 StorageFileEntity (org.finra.herd.model.jpa.StorageFileEntity)2 Timestamp (java.sql.Timestamp)1