Search in sources :

Example 36 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testBusinessObjectDataStorageFileServiceMethodsNewTx.

/**
 * This method is to get the coverage for the business object data storage file service method that starts the new transaction.
 */
@Test
public void testBusinessObjectDataStorageFileServiceMethodsNewTx() throws Exception {
    BusinessObjectDataStorageFilesCreateRequest request = new BusinessObjectDataStorageFilesCreateRequest();
    try {
        businessObjectDataStorageFileServiceImpl.createBusinessObjectDataStorageFiles(request);
        fail("Should throw a IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) Test(org.junit.Test)

Example 37 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataStorageFileServiceTest method testCreateBusinessObjectDataStorageFilesAutoDiscoveryPreviouslyRegisteredS3FileNotFound.

@Test
public void testCreateBusinessObjectDataStorageFilesAutoDiscoveryPreviouslyRegisteredS3FileNotFound() throws Exception {
    // Create test data.
    createData(testS3KeyPrefix, true, Arrays.asList(testS3KeyPrefix + "/" + FILE_PATH_1));
    // Create and upload to S3 managed storage a test file that is not the already registered storage file.
    businessObjectDataServiceTestHelper.prepareTestS3Files(testS3KeyPrefix, localTempPath, Arrays.asList(FILE_PATH_2));
    // Try to discover storage files when an already registered storage file is not found in S3.
    try {
        businessObjectDataStorageFileService.createBusinessObjectDataStorageFiles(new BusinessObjectDataStorageFilesCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, StorageEntity.MANAGED_STORAGE, NO_STORAGE_FILES, DISCOVER_STORAGE_FILES));
        fail("Should throw an ObjectNotFoundException when an already registered storage file not found in S3.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Previously registered storage file not found at s3://%s/%s/%s location.", storageDaoTestHelper.getS3ManagedBucketName(), testS3KeyPrefix, FILE_PATH_1), e.getMessage());
    }
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 38 with BusinessObjectDataStorageFilesCreateRequest

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

the class BusinessObjectDataServiceTestHelper method getNewBusinessObjectDataStorageFilesCreateRequest.

public BusinessObjectDataStorageFilesCreateRequest getNewBusinessObjectDataStorageFilesCreateRequest() {
    // Crete a test business object format (and associated data).
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(false);
    BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(AbstractServiceTest.BDATA_STATUS, AbstractServiceTest.DESCRIPTION, AbstractServiceTest.BDATA_STATUS_PRE_REGISTRATION_FLAG_SET);
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, AbstractServiceTest.PARTITION_VALUE, AbstractServiceTest.DATA_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET, businessObjectDataStatusEntity.getCode());
    StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity();
    storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, AbstractServiceTest.NO_STORAGE_DIRECTORY_PATH);
    // Create a business object data storage files create request.
    BusinessObjectDataStorageFilesCreateRequest businessObjectDataStorageFilesCreateRequest = new BusinessObjectDataStorageFilesCreateRequest();
    businessObjectDataStorageFilesCreateRequest.setNamespace(businessObjectFormatEntity.getBusinessObjectDefinition().getNamespace().getCode());
    businessObjectDataStorageFilesCreateRequest.setBusinessObjectDefinitionName(businessObjectFormatEntity.getBusinessObjectDefinition().getName());
    businessObjectDataStorageFilesCreateRequest.setBusinessObjectFormatUsage(businessObjectFormatEntity.getUsage());
    businessObjectDataStorageFilesCreateRequest.setBusinessObjectFormatFileType(businessObjectFormatEntity.getFileType().getCode());
    businessObjectDataStorageFilesCreateRequest.setBusinessObjectFormatVersion(businessObjectFormatEntity.getBusinessObjectFormatVersion());
    businessObjectDataStorageFilesCreateRequest.setPartitionValue(businessObjectDataEntity.getPartitionValue());
    businessObjectDataStorageFilesCreateRequest.setBusinessObjectDataVersion(businessObjectDataEntity.getVersion());
    businessObjectDataStorageFilesCreateRequest.setStorageName(storageEntity.getName());
    businessObjectDataStorageFilesCreateRequest.setStorageFiles(getStorageFiles());
    return businessObjectDataStorageFilesCreateRequest;
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Example 39 with BusinessObjectDataStorageFilesCreateRequest

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

the class AddBusinessObjectDataStorageFilesTest method testAddBusinessObjectDataStorageFilesJson.

@Test
public void testAddBusinessObjectDataStorageFilesJson() throws Exception {
    BusinessObjectDataStorageFilesCreateRequest businessObjectDataStorageFilesCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataStorageFilesCreateRequest();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStorageFilesCreateRequest", "${businessObjectDataStorageFilesCreateRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "json"));
    parameters.add(buildParameter("businessObjectDataStorageFilesCreateRequest", jsonHelper.objectToJson(businessObjectDataStorageFilesCreateRequest)));
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_NOT_NULL);
    testActivitiServiceTaskSuccess(AddBusinessObjectDataStorageFiles.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 40 with BusinessObjectDataStorageFilesCreateRequest

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

the class AddBusinessObjectDataStorageFilesTest method testAddBusinessObjectDataStorageFilesXml.

@Test
public void testAddBusinessObjectDataStorageFilesXml() throws Exception {
    BusinessObjectDataStorageFilesCreateRequest businessObjectDataStorageFilesCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataStorageFilesCreateRequest();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStorageFilesCreateRequest", "${businessObjectDataStorageFilesCreateRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataStorageFilesCreateRequest", xmlHelper.objectToXml(businessObjectDataStorageFilesCreateRequest)));
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_NOT_NULL);
    testActivitiServiceTaskSuccess(AddBusinessObjectDataStorageFiles.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataStorageFilesCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Aggregations

BusinessObjectDataStorageFilesCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateRequest)40 Test (org.junit.Test)37 BusinessObjectDataStorageFilesCreateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStorageFilesCreateResponse)14 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)5 StorageFileEntity (org.finra.herd.model.jpa.StorageFileEntity)5 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)5 ArrayList (java.util.ArrayList)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 StorageFile (org.finra.herd.model.api.xml.StorageFile)2 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 StringWriter (java.io.StringWriter)1 URI (java.net.URI)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 HttpPost (org.apache.http.client.methods.HttpPost)1