Search in sources :

Example 11 with UploadSingleInitiationRequest

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

the class UploadDownloadServiceTest method testInitiateUploadSingleRequiredAttributeMissingValue.

@Test
public void testInitiateUploadSingleRequiredAttributeMissingValue() {
    // Create database entities required for testing.
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    // Create and persist a business object data attribute definition entity.
    businessObjectFormatDaoTestHelper.createBusinessObjectDataAttributeDefinitionEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE);
    // Try to initiate a single file upload when a required attribute value is not specified.
    UploadSingleInitiationRequest request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
    request.setBusinessObjectDataAttributes(Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, BLANK_TEXT)));
    try {
        uploadDownloadService.initiateUploadSingle(request);
        fail("Should throw an IllegalArgumentException when required attribute value is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The business object format has a required attribute \"%s\" which was not specified or has a value which is blank.", ATTRIBUTE_NAME_1_MIXED_CASE), e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) UploadSingleInitiationRequest(org.finra.herd.model.api.xml.UploadSingleInitiationRequest) Test(org.junit.Test)

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