Search in sources :

Example 1 with UploadSingleInitiationRequest

use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.

the class UploadDownloadRestControllerTest method testInitiateUploadSingle.

@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, Arrays.asList(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(Arrays.asList(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(Arrays.asList(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);
}
Also used : Storage(org.finra.herd.model.api.xml.Storage) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) File(org.finra.herd.model.api.xml.File) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 2 with UploadSingleInitiationRequest

use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.

the class UploadDownloadServiceTest method testInitiateUploadSingleDuplicateAttributes.

@Test
public void testInitiateUploadSingleDuplicateAttributes() {
    // Create database entities required for testing.
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    // Try to initiate a single file upload when duplicate attributes are specified.
    UploadSingleInitiationRequest request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.setBusinessObjectDataAttributes(Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3)));
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when duplicate attributes are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) Test(org.junit.Test)

Example 3 with UploadSingleInitiationRequest

use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.

the class UploadDownloadServiceTest method testInitiateUploadSingleInvalidParameters.

@Test
public void testInitiateUploadSingleInvalidParameters() {
    // Create database entities required for testing.
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    UploadSingleInitiationRequest request;
    // Try to initiate a single file upload using invalid namespace.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setNamespace("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage("I_DO_NOT_EXIST", BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
    // Try to initiate a single file upload using invalid business object definition name.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectDefinitionName("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
    // Try to initiate a single file upload using invalid format usage.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectFormatUsage("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
    // Try to initiate a single file upload using invalid format file type.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectFormatFileType("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION), e.getMessage());
    }
    // Try to initiate a single file upload using invalid business object format version.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectFormatVersion(INVALID_FORMAT_VERSION);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION), e.getMessage());
    }
    // Try to initiate a single file upload using invalid namespace.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setNamespace("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage("I_DO_NOT_EXIST", BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2), e.getMessage());
    }
    // Try to initiate a single file upload using invalid business object definition name.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectDefinitionName("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2), e.getMessage());
    }
    // Try to initiate a single file upload using invalid format usage.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectFormatUsage("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME_2, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2), e.getMessage());
    }
    // Try to initiate a single file upload using invalid format file type.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectFormatFileType("I_DO_NOT_EXIST");
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, "I_DO_NOT_EXIST", FORMAT_VERSION_2), e.getMessage());
    }
    // Try to initiate a single file upload using invalid business object format version.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectFormatVersion(INVALID_FORMAT_VERSION);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, INVALID_FORMAT_VERSION), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) Test(org.junit.Test)

Example 4 with UploadSingleInitiationRequest

use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.

the class UploadDownloadServiceTest method testInitiateUploadSingleMissingRequiredParameters.

@Test
public void testInitiateUploadSingleMissingRequiredParameters() {
    UploadSingleInitiationRequest request;
    // Try to initiate a single file upload when business object format key is not specified.
    request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.setSourceBusinessObjectFormatKey(null);
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format key is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format key must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when namespace is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setNamespace(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object definition name is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectDefinitionName(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format usage is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectFormatUsage(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format file type is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectFormatFileType(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format version is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getSourceBusinessObjectFormatKey().setBusinessObjectFormatVersion(null);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format version is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format version must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format key is not specified.
    request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.setTargetBusinessObjectFormatKey(null);
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format key is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format key must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when namespace is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setNamespace(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object definition name is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectDefinitionName(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format usage is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectFormatUsage(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format file type is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectFormatFileType(BLANK_TEXT);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when business object format version is not specified.
    try {
        request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
        request.getTargetBusinessObjectFormatKey().setBusinessObjectFormatVersion(null);
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when business object format version is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format version must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when attribute name is not specified.
    request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.getBusinessObjectDataAttributes().get(0).setName(BLANK_TEXT);
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when attribute name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An attribute name must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when file information is not specified.
    request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.setFile(null);
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when file information is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("File information must be specified.", e.getMessage());
    }
    // Try to initiate a single file upload when file name is not specified.
    request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.getFile().setFileName(BLANK_TEXT);
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when file name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A file name must be specified.", e.getMessage());
    }
}
Also used : UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) Test(org.junit.Test)

Example 5 with UploadSingleInitiationRequest

use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.

the class UploadDownloadServiceTestHelper method createUploadSingleInitiationRequest.

/**
 * Creates a upload single initiation request.
 *
 * @param sourceNamespaceCode the source namespace code
 * @param sourceBusinessObjectDefinitionName the source business object definition name
 * @param sourceBusinessObjectFormatUsage the source business object usage
 * @param sourceBusinessObjectFormatFileType the source business object format file type
 * @param sourceBusinessObjectFormatVersion the source business object format version
 * @param targetNamespaceCode the target namespace code
 * @param targetBusinessObjectDefinitionName the target business object definition name
 * @param targetBusinessObjectFormatUsage the target business object usage
 * @param targetBusinessObjectFormatFileType the target business object format file type
 * @param targetBusinessObjectFormatVersion the target business object format version
 * @param fileName the file name
 *
 * @return the newly created upload single initiation request
 */
public UploadSingleInitiationRequest createUploadSingleInitiationRequest(String sourceNamespaceCode, String sourceBusinessObjectDefinitionName, String sourceBusinessObjectFormatUsage, String sourceBusinessObjectFormatFileType, Integer sourceBusinessObjectFormatVersion, String targetNamespaceCode, String targetBusinessObjectDefinitionName, String targetBusinessObjectFormatUsage, String targetBusinessObjectFormatFileType, Integer targetBusinessObjectFormatVersion, String fileName) {
    UploadSingleInitiationRequest request = new UploadSingleInitiationRequest();
    request.setSourceBusinessObjectFormatKey(new BusinessObjectFormatKey(sourceNamespaceCode, sourceBusinessObjectDefinitionName, sourceBusinessObjectFormatUsage, sourceBusinessObjectFormatFileType, sourceBusinessObjectFormatVersion));
    request.setTargetBusinessObjectFormatKey(new BusinessObjectFormatKey(targetNamespaceCode, targetBusinessObjectDefinitionName, targetBusinessObjectFormatUsage, targetBusinessObjectFormatFileType, targetBusinessObjectFormatVersion));
    request.setBusinessObjectDataAttributes(businessObjectDefinitionServiceTestHelper.getNewAttributes());
    request.setFile(new File(fileName, AbstractServiceTest.FILE_SIZE_1_KB));
    return request;
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) File(org.finra.herd.model.api.xml.File)

Aggregations

UploadSingleInitiationRequest (org.finra.herd.model.api.xml.UploadSingleInitiationRequest)11 Test (org.junit.Test)10 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 StorageEntity (org.finra.herd.model.jpa.StorageEntity)4 Attribute (org.finra.herd.model.api.xml.Attribute)3 UploadSingleInitiationResponse (org.finra.herd.model.api.xml.UploadSingleInitiationResponse)3 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)2 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)2 File (org.finra.herd.model.api.xml.File)2 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)1 Storage (org.finra.herd.model.api.xml.Storage)1 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)1