@Test
public void testInitiateUploadSingle()
{

    // Create business object format keys.
    BusinessObjectFormatKey sourceBusinessObjectFormatKey =
        new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION);
    BusinessObjectFormatKey targetBusinessObjectFormatKey =
        new BusinessObjectFormatKey(BDEF_NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2);
    // Create a file object.
    File file = new File(LOCAL_FILE, FILE_SIZE);
    // Create a request.
    UploadSingleInitiationRequest request = new UploadSingleInitiationRequest(sourceBusinessObjectFormatKey, targetBusinessObjectFormatKey,
        Lists.newArrayList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1)), file, STORAGE_NAME);
    // Create business object data keys.
    BusinessObjectDataKey sourceBusinessObjectDataKey =
        new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES,
            DATA_VERSION);
    BusinessObjectDataKey targetBusinessObjectDataKey =
        new BusinessObjectDataKey(BDEF_NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, PARTITION_VALUE_2,
            SUBPARTITION_VALUES_2, DATA_VERSION_2);
    // Create a business object data objects.
    BusinessObjectData sourceBusinessObjectData = new BusinessObjectData();
    sourceBusinessObjectData.setId(ID);
    sourceBusinessObjectData.setStatus(BDATA_STATUS);
    sourceBusinessObjectData.setStorageUnits(Lists.newArrayList(
        new StorageUnit(new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES), NO_STORAGE_DIRECTORY, NO_STORAGE_FILES, STORAGE_UNIT_STATUS,
            NO_STORAGE_UNIT_STATUS_HISTORY, NO_STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, NO_RESTORE_EXPIRATION_ON)));
    BusinessObjectData targetBusinessObjectData = new BusinessObjectData();
    targetBusinessObjectData.setId(ID_2);
    targetBusinessObjectData.setStatus(BDATA_STATUS_2);
    targetBusinessObjectData.setStorageUnits(Lists.newArrayList(
        new StorageUnit(new Storage(STORAGE_NAME_2, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES), NO_STORAGE_DIRECTORY, NO_STORAGE_FILES, STORAGE_UNIT_STATUS_2,
            NO_STORAGE_UNIT_STATUS_HISTORY, NO_STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, NO_RESTORE_EXPIRATION_ON)));
    // Create a response.
    UploadSingleInitiationResponse response =
        new UploadSingleInitiationResponse(sourceBusinessObjectData, targetBusinessObjectData, file, UUID_VALUE, AWS_ASSUMED_ROLE_ACCESS_KEY,
            AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME, AWS_KMS_KEY_ID, STORAGE_NAME);
    // Mock the external calls.
    when(uploadDownloadService.initiateUploadSingle(request)).thenReturn(response);
    when(businessObjectDataHelper.getBusinessObjectDataKey(sourceBusinessObjectData)).thenReturn(sourceBusinessObjectDataKey);
    when(businessObjectDataHelper.getBusinessObjectDataKey(targetBusinessObjectData)).thenReturn(targetBusinessObjectDataKey);
    // Call the method under test.
    UploadSingleInitiationResponse result = uploadDownloadRestController.initiateUploadSingle(request);
    // Verify the external calls.
    verify(uploadDownloadService).initiateUploadSingle(request);
    verify(businessObjectDataHelper).getBusinessObjectDataKey(sourceBusinessObjectData);
    verify(businessObjectDataHelper).getBusinessObjectDataKey(targetBusinessObjectData);
    verify(notificationEventService)
        .processBusinessObjectDataNotificationEventAsync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN, sourceBusinessObjectDataKey,
            BDATA_STATUS, null);
    verify(notificationEventService)
        .processBusinessObjectDataNotificationEventAsync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG, sourceBusinessObjectDataKey,
            BDATA_STATUS, null);
    verify(notificationEventService)
        .processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, sourceBusinessObjectDataKey,
            STORAGE_NAME, STORAGE_UNIT_STATUS, null);
    verify(notificationEventService)
        .processBusinessObjectDataNotificationEventAsync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN, targetBusinessObjectDataKey,
            BDATA_STATUS_2, null);
    verify(notificationEventService)
        .processBusinessObjectDataNotificationEventAsync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG, targetBusinessObjectDataKey,
            BDATA_STATUS_2, null);
    verify(notificationEventService)
        .processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, targetBusinessObjectDataKey,
            STORAGE_NAME_2, STORAGE_UNIT_STATUS_2, null);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(response, result);
}