use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class StorageServiceTest method testUpdateStorageStorageNoExists.
@Test
public void testUpdateStorageStorageNoExists() {
// Try to update a storage that doesn't yet exist.
try {
storageService.updateStorage(new StorageKey(INVALID_VALUE), new StorageUpdateRequest());
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class TagServiceTest method testUpdateTagParentTagNoExists.
@Test
public void testUpdateTagParentTagNoExists() {
// Create a tag key.
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
// Create and persist a tag entity without a parent tag.
tagDaoTestHelper.createTagEntity(tagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
// Try to update a tag using a non-existing parent tag.
try {
tagService.updateTag(tagKey, new TagUpdateRequest(TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, 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());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class TagServiceTest method testDeleteTagTagNoExists.
@Test
public void testDeleteTagTagNoExists() {
// Try to delete a non-existing tag.
try {
tagService.deleteTag(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());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class TagTypeServiceTest method testGetTagTypeTagTypeNotExists.
@Test
public void testGetTagTypeTagTypeNotExists() {
// Try to retrieve a tag type instance when tag type code is not registered.
try {
tagTypeService.getTagType(new TagTypeKey(TAG_TYPE));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", TAG_TYPE), e.getMessage());
}
}
use of org.finra.herd.model.ObjectNotFoundException in project herd by FINRAOS.
the class UploadDownloadHelperServiceTest method testUploadDownloadHelperServiceMethodsNewTransactionPropagation.
/**
* This method is to get coverage for the upload download helper service methods that have explicit annotations for transaction propagation.
*/
@Test
public void testUploadDownloadHelperServiceMethodsNewTransactionPropagation() throws Exception {
executeWithoutLogging(UploadDownloadHelperServiceImpl.class, () -> {
CompleteUploadSingleParamsDto completeUploadSingleParamsDto;
// Try to perform a prepare file move operation with a non-existing S3 key (file path).
completeUploadSingleParamsDto = new CompleteUploadSingleParamsDto();
uploadDownloadHelperServiceImpl.prepareForFileMove("KEY_DOES_NOT_EXIST", completeUploadSingleParamsDto);
// Validate the updated complete upload single parameters DTO.
assertNull(completeUploadSingleParamsDto.getSourceBusinessObjectDataKey());
assertNull(completeUploadSingleParamsDto.getSourceNewStatus());
assertNull(completeUploadSingleParamsDto.getSourceOldStatus());
assertNull(completeUploadSingleParamsDto.getTargetBusinessObjectDataKey());
assertNull(completeUploadSingleParamsDto.getTargetNewStatus());
assertNull(completeUploadSingleParamsDto.getTargetOldStatus());
// Try to perform an S3 file move. The S3 copy operation will fail since we are passing a special mocked file name.
completeUploadSingleParamsDto = new CompleteUploadSingleParamsDto(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION), EMPTY_S3_BUCKET_NAME, MockS3OperationsImpl.MOCK_S3_FILE_NAME_SERVICE_EXCEPTION, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION), EMPTY_S3_BUCKET_NAME, MockS3OperationsImpl.MOCK_S3_FILE_NAME_SERVICE_EXCEPTION, BusinessObjectDataStatusEntity.UPLOADING, BusinessObjectDataStatusEntity.RE_ENCRYPTING, MockS3OperationsImpl.MOCK_KMS_ID, emrHelper.getAwsParamsDto());
uploadDownloadHelperServiceImpl.performFileMove(completeUploadSingleParamsDto);
// Validate the updated complete upload single parameters DTO.
assertEquals(BusinessObjectDataStatusEntity.RE_ENCRYPTING, completeUploadSingleParamsDto.getSourceNewStatus());
assertEquals(BusinessObjectDataStatusEntity.UPLOADING, completeUploadSingleParamsDto.getSourceOldStatus());
assertEquals(BusinessObjectDataStatusEntity.INVALID, completeUploadSingleParamsDto.getTargetNewStatus());
assertEquals(BusinessObjectDataStatusEntity.RE_ENCRYPTING, completeUploadSingleParamsDto.getTargetOldStatus());
// Try to execute the file move post steps by passing a non-initialized complete upload single parameters DTO.
uploadDownloadHelperServiceImpl.executeFileMoveAfterSteps(new CompleteUploadSingleParamsDto());
// Try to delete the source file from S3
uploadDownloadHelperServiceImpl.deleteSourceFileFromS3(new CompleteUploadSingleParamsDto());
// Try to update the business object data status for a non-existing business object data.
try {
uploadDownloadHelperServiceImpl.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION), null);
fail("Should throw an ObjectNotFoundException.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
});
}
Aggregations