use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionEmrClusterDefinitionAlreadyExists.
@Test
public void testCreateEmrClusterDefinitionEmrClusterDefinitionAlreadyExists() throws Exception {
// Create and persist the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create and persist the EMR cluster definition entity.
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Try to perform a create using an already existing EMR cluster definition name.
try {
emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
fail("Should throw an AlreadyExistsException when EMR cluster definition already exists.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create EMR cluster definition with name \"%s\" for namespace \"%s\" because it already exists.", EMR_CLUSTER_DEFINITION_NAME, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesExpectedPartitionValueAlreadyExists.
@Test
public void testCreateExpectedPartitionValuesExpectedPartitionValueAlreadyExists() {
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Create and persist a single test expected partition value.
expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE));
// Try to perform a create using an already existing expected partition value.
ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, Arrays.asList(PARTITION_VALUE));
try {
expectedPartitionValueService.createExpectedPartitionValues(request);
fail("Should throw an AlreadyExistsException when expected partition value already exists.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("Expected partition value \"%s\" already exists in \"%s\" partition key group.", PARTITION_VALUE, PARTITION_KEY_GROUP), e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoHelperTest method testValidateGlobalAttributeDefinitionNoExistsEntityExists.
@Test
public void testValidateGlobalAttributeDefinitionNoExistsEntityExists() {
// Create a global attribute definition key.
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Create a global attribute definition entity.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = new GlobalAttributeDefinitionEntity();
// Mock calls to external methods.
when(globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinitionEntity);
// Try to call the method under test.
try {
globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(globalAttributeDefinitionKey);
fail();
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create global attribute definition with global attribute definition level \"%s\" " + "and global attribute definition name \"%s\" because it already exists.", globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel(), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName()), e.getMessage());
}
// Verify the external calls.
verify(globalAttributeDefinitionDao).getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey);
verifyNoMoreInteractions(globalAttributeDefinitionDao);
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesS3ManagedStorageFilePreviouslyRegistered.
@Test
public void testCreateBusinessObjectDataStorageFilesS3ManagedStorageFilePreviouslyRegistered() {
// Create a test file path.
String testFilePath = testS3KeyPrefix + "/" + FILE_PATH_1;
// Create test data.
createData(null, true, Arrays.asList(testFilePath));
// Try to add an already registered storage file.
try {
businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, StorageEntity.MANAGED_STORAGE, Arrays.asList(createFile(testFilePath, FILE_SIZE_1_KB, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES));
fail("Should throw an AlreadyExistsException when request contains storage file what is already registered.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("S3 file \"%s\" in \"%s\" storage is already registered by the business object data {%s}.", testFilePath, StorageEntity.MANAGED_STORAGE, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION)), e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesStorageFilePreviouslyRegistered.
@Test
public void testCreateBusinessObjectDataStorageFilesStorageFilePreviouslyRegistered() {
createData(null, false);
// Try to add an already registered storage file.
try {
businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, STORAGE_NAME, Arrays.asList(createFile(FILE_PATH_1, FILE_SIZE_1_KB, ROW_COUNT_1000)), NO_DISCOVER_STORAGE_FILES));
fail("Should throw an AlreadyExistsException when request contains storage file what is already registered.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("S3 file \"%s\" in \"%s\" storage is already registered by the business object data {%s}.", FILE_PATH_1, STORAGE_NAME, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION)), e.getMessage());
}
}
Aggregations