use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class StorageUnitServiceGetS3KeyPrefixTest method testGetS3KeyPrefixNoDataVersionSpecifiedLatestDataVersionExistsCreateNewVersionIsFalse.
@Test
public void testGetS3KeyPrefixNoDataVersionSpecifiedLatestDataVersionExistsCreateNewVersionIsFalse() {
// Create database entities required for testing. Please note that we are passing the flag to create a business object data entity.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForGetS3KeyPrefixTesting(true);
// Get the test partition columns.
List<SchemaColumn> testPartitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns();
String testPartitionKey = testPartitionColumns.get(0).getName();
// Try to get an S3 key prefix for the next business object data with the create new version flag not set to "true".
try {
storageUnitService.getS3KeyPrefix(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, null), testPartitionKey, STORAGE_NAME, false);
} catch (AlreadyExistsException e) {
assertEquals("Initial version of the business object data already exists.", e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class RelationalTableRegistrationHelperServiceTest method testGetRelationalStorageAttributesBusinessObjectFormatAlreadyExists.
@Test
public void testGetRelationalStorageAttributesBusinessObjectFormatAlreadyExists() {
// Create a namespace.
namespaceDaoTestHelper.createNamespaceEntity(BDEF_NAMESPACE);
// Create a business object definition.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, 1, FORMAT_DESCRIPTION, true, PARTITION_KEY, PARTITION_KEY_GROUP);
// Try to a get relational storage attributes when specified business object definition already exists.
try {
relationalTableRegistrationHelperService.getRelationalStorageAttributes(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_TRUE);
fail();
} catch (AlreadyExistsException alreadyExistsException) {
Assert.assertEquals(String.format("Format with file type \"%s\" and usage \"%s\" already exists for business object definition \"%s\".", FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, FORMAT_USAGE_CODE, BDEF_NAME), alreadyExistsException.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class RelationalTableRegistrationHelperServiceTest method testGetRelationalStorageAttributesBusinessObjectDefinitionAlreadyExists.
@Test
public void testGetRelationalStorageAttributesBusinessObjectDefinitionAlreadyExists() {
// Create a namespace.
namespaceDaoTestHelper.createNamespaceEntity(BDEF_NAMESPACE);
// Create a business object definition.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
// Try to a get relational storage attributes when specified business object definition already exists.
try {
relationalTableRegistrationHelperService.getRelationalStorageAttributes(new RelationalTableRegistrationCreateRequest(BDEF_NAMESPACE, BDEF_NAME, BDEF_DISPLAY_NAME, FORMAT_USAGE_CODE, DATA_PROVIDER_NAME, RELATIONAL_SCHEMA_NAME, RELATIONAL_TABLE_NAME, STORAGE_NAME), APPEND_TO_EXISTING_BUSINESS_OBJECT_DEFINTION_FALSE);
fail();
} catch (AlreadyExistsException ex) {
Assert.assertEquals(String.format("Business object definition with name \"%s\" already exists for namespace \"%s\".", BDEF_NAME, BDEF_NAMESPACE), ex.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class StoragePolicyServiceTest method testCreateStoragePolicyAlreadyExists.
@Test
public void testCreateStoragePolicyAlreadyExists() {
// Create a storage policy key.
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Create and persist a storage policy entity.
storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Try to create a storage policy when it already exists.
try {
storagePolicyService.createStoragePolicy(storagePolicyServiceTestHelper.createStoragePolicyCreateRequest(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED));
fail("Should throw an AlreadyExistsException when storage policy already exists.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create storage policy with name \"%s\" because it already exists for namespace \"%s\".", storagePolicyKey.getStoragePolicyName(), storagePolicyKey.getNamespace()), e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class StorageServiceTest method testCreateStorageStorageAlreadyExists.
@Test
public void testCreateStorageStorageAlreadyExists() {
// Create and persist a valid storage.
StorageCreateRequest storageCreateRequest = getNewStorageCreateRequest();
storageService.createStorage(storageCreateRequest);
// Try creating that storage again which is invalid since it already exists.
try {
storageService.createStorage(storageCreateRequest);
fail();
} catch (AlreadyExistsException e) {
assertEquals(String.format("Storage with name \"%s\" already exists.", storageCreateRequest.getName()), e.getMessage());
}
}
Aggregations