Search in sources :

Example 6 with StoragePolicyCreateRequest

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

the class StoragePolicyServiceTest method testCreateStoragePolicyStoragePolicyFilterStorageBucketNameNotConfigured.

@Test
public void testCreateStoragePolicyStoragePolicyFilterStorageBucketNameNotConfigured() {
    // Create and persist the relative database entities.
    storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting();
    // Create an S3 storage without any attributes.
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3, StoragePlatformEntity.S3);
    // Create a storage policy key.
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    // Try to create a storage policy when storage policy filter storage has no S3 bucket name attribute configured.
    StoragePolicyCreateRequest request = storagePolicyServiceTestHelper.createStoragePolicyCreateRequest(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME_3, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED);
    try {
        storagePolicyService.createStoragePolicy(request);
        fail("Should throw an IllegalStateException when storage policy filter storage has no S3 bucket name attribute configured.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Attribute \"%s\" for \"%s\" storage must be configured.", configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), request.getStoragePolicyFilter().getStorageName()), e.getMessage());
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyCreateRequest(org.finra.herd.model.api.xml.StoragePolicyCreateRequest) Test(org.junit.Test)

Example 7 with StoragePolicyCreateRequest

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

the class StoragePolicyServiceTest method testCreateStoragePolicyStoragePolicyFilterStoragePathPrefixValidationNotEnabled.

@Test
public void testCreateStoragePolicyStoragePolicyFilterStoragePathPrefixValidationNotEnabled() {
    // Create and persist the relative database entities.
    storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting();
    // Create an S3 storage with the bucket name configured, but without the S3 path prefix validation option configured.
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3, StoragePlatformEntity.S3, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME);
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    // Try to create a storage policy when storage policy filter storage has no S3 path prefix validation enabled.
    StoragePolicyCreateRequest request = storagePolicyServiceTestHelper.createStoragePolicyCreateRequest(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME_3, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED);
    try {
        storagePolicyService.createStoragePolicy(request);
        fail("Should throw an IllegalStateException when storage policy filter storage has no S3 path prefix validation enabled.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Path prefix validation must be enabled on \"%s\" storage.", request.getStoragePolicyFilter().getStorageName()), e.getMessage());
    }
}
Also used : StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicyCreateRequest(org.finra.herd.model.api.xml.StoragePolicyCreateRequest) Test(org.junit.Test)

Aggregations

StoragePolicyCreateRequest (org.finra.herd.model.api.xml.StoragePolicyCreateRequest)7 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)6 Test (org.junit.Test)6 StoragePolicyFilter (org.finra.herd.model.api.xml.StoragePolicyFilter)2 StoragePolicyRule (org.finra.herd.model.api.xml.StoragePolicyRule)2 StoragePolicyTransition (org.finra.herd.model.api.xml.StoragePolicyTransition)2 ArrayList (java.util.ArrayList)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 Attribute (org.finra.herd.model.api.xml.Attribute)1 StoragePolicy (org.finra.herd.model.api.xml.StoragePolicy)1