Search in sources :

Example 76 with ObjectNotFoundException

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) StorageUpdateRequest(org.finra.herd.model.api.xml.StorageUpdateRequest) StorageKey(org.finra.herd.model.api.xml.StorageKey) Test(org.junit.Test)

Example 77 with ObjectNotFoundException

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());
    }
}
Also used : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 78 with ObjectNotFoundException

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());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 79 with ObjectNotFoundException

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());
    }
}
Also used : TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 80 with ObjectNotFoundException

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());
        }
    });
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) CompleteUploadSingleParamsDto(org.finra.herd.model.dto.CompleteUploadSingleParamsDto) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)216 Test (org.junit.Test)193 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)36 ArrayList (java.util.ArrayList)18 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)16 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 BusinessObjectDataAttributeKey (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey)14 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)12 TagKey (org.finra.herd.model.api.xml.TagKey)11 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)10 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)10 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)9 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)8 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)7 MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)7 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)6 BusinessObjectDefinitionColumnKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey)6 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)6 AmazonServiceException (com.amazonaws.AmazonServiceException)5 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5