use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class StoragePolicyProcessorHelperServiceTest method testInitiateStoragePolicyTransitionStorageUnitNoExists.
@Test
public void testInitiateStoragePolicyTransitionStorageUnitNoExists() throws Exception {
// Create and persist the relative database entities.
storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting(STORAGE_POLICY_NAMESPACE_CD, Arrays.asList(STORAGE_POLICY_RULE_TYPE), BDEF_NAMESPACE, BDEF_NAME, Arrays.asList(FORMAT_FILE_TYPE_CODE), Arrays.asList(STORAGE_NAME), Arrays.asList(StoragePolicyTransitionTypeEntity.GLACIER));
// 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 and persist a business object data entity without any storage units.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
// 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, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Override configuration to specify some settings required for testing.
Map<String, Object> overrideMap = new HashMap<>();
overrideMap.put(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_ARN.getKey(), S3_OBJECT_TAGGER_ROLE_ARN);
overrideMap.put(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_SESSION_NAME.getKey(), S3_OBJECT_TAGGER_ROLE_SESSION_NAME);
modifyPropertySourceInEnvironment(overrideMap);
// Try to initiate a storage policy transition when storage unit does not exist.
try {
storagePolicyProcessorHelperService.initiateStoragePolicyTransition(new StoragePolicyTransitionParamsDto(), new StoragePolicySelection(businessObjectDataKey, storagePolicyKey, INITIAL_VERSION));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Could not find storage unit in \"%s\" storage for the business object data {%s}.", STORAGE_NAME, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage());
} finally {
// Restore the property sources so we don't affect other tests.
restorePropertySourceInEnvironment();
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class StoragePolicyProcessorHelperServiceTest method testCompleteStoragePolicyTransitionBusinessObjectDataNoExists.
@Test
public void testCompleteStoragePolicyTransitionBusinessObjectDataNoExists() {
// 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);
// Try to complete a storage policy transition when business object data does not exist.
StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto = new StoragePolicyTransitionParamsDto(businessObjectDataKey, STORAGE_NAME, S3_ENDPOINT, S3_BUCKET_NAME, TEST_S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, NO_STORAGE_FILES, S3_ARCHIVE_TO_GLACIER_TAG_KEY, S3_ARCHIVE_TO_GLACIER_TAG_VALUE, S3_OBJECT_TAGGER_ROLE_ARN, S3_OBJECT_TAGGER_ROLE_SESSION_NAME);
try {
storagePolicyProcessorHelperService.completeStoragePolicyTransition(storagePolicyTransitionParamsDto);
fail("Should throw an ObjectNotFoundException when business object data does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectDataKey, null), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorizationNoExists.
@Test
public void testDeleteUserNamespaceAuthorizationNoExists() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Try to delete a user namespace authorization when it does not exist.
try {
userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(key);
fail("Should throw an ObjectNotFoundException when user namespace authorization does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("User namespace authorization with user id \"%s\" and namespace \"%s\" doesn't exist.", key.getUserId(), key.getNamespace()), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class BaseJavaDelegateTest method testSetSecurityContextProcessDefinitionNoExists.
@Test
public void testSetSecurityContextProcessDefinitionNoExists() throws Exception {
// Set up expected values.
String processDefinitionId = "processDefinitionId";
// Mock dependency methods.
when(delegateExecution.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(activitiService.getProcessDefinitionById(any())).thenReturn(null);
// Clear the security context.
SecurityContextHolder.clearContext();
// Try to execute the test method when process definition does not exist.
try {
baseJavaDelegate.setSecurityContext(delegateExecution);
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Failed to find Activiti process definition for processDefinitionId=\"%s\".", processDefinitionId), e.getMessage());
}
// Verify dependencies were invoked correctly.
InOrder inOrder = inOrder(activitiService);
inOrder.verify(activitiService).getProcessDefinitionById(processDefinitionId);
inOrder.verifyNoMoreInteractions();
verifyNoMoreInteractions(activitiService);
// Assert that security context is not set.
assertNull(SecurityContextHolder.getContext().getAuthentication());
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class TagServiceTest method testGetTagTagNoExists.
@Test
public void testGetTagTagNoExists() {
// Try to get a non-existing tag.
try {
tagService.getTag(new TagKey(TAG_TYPE, TAG_CODE));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Tag with code \"%s\" doesn't exist for tag type \"%s\".", TAG_CODE, TAG_TYPE), e.getMessage());
}
}
Aggregations