Search in sources :

Example 11 with BusinessObjectDataStatusUpdateResponse

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

the class UpdateBusinessObjectDataStatusTest method testUpdateBusinessObjectDataStatusMissingOptionalParameters.

@Test
public void testUpdateBusinessObjectDataStatusMissingOptionalParameters() throws Exception {
    // Create a business object data key without sub-partition values.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data entity.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Create a business object data status entity.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStatus", "${businessObjectDataStatus}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataStatus", BDATA_STATUS_2));
    // Build the expected response object.
    BusinessObjectDataStatusUpdateResponse expectedBusinessObjectDataStatusUpdateResponse = new BusinessObjectDataStatusUpdateResponse(businessObjectDataKey, BDATA_STATUS_2, BDATA_STATUS);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(UpdateBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataStatusUpdateResponse));
    testActivitiServiceTaskSuccess(UpdateBusinessObjectDataStatus.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 12 with BusinessObjectDataStatusUpdateResponse

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

the class BusinessObjectDataStatusRestControllerTest method testUpdateBusinessObjectDataStatusMissingOptionalParameters.

@Test
public void testUpdateBusinessObjectDataStatusMissingOptionalParameters() {
    // Test if we can retrieve an attribute for the business object data with any allowed number of subpartition values (from 0 to MAX_SUBPARTITIONS).
    for (int i = 0; i <= BusinessObjectDataEntity.MAX_SUBPARTITIONS; i++) {
        // Build a list of subpartition values.
        List<String> subPartitionValues = SUBPARTITION_VALUES.subList(0, i);
        BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION);
        BusinessObjectDataStatusUpdateRequest request = new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2);
        BusinessObjectDataStatusUpdateResponse businessObjectDataStatusUpdateResponse = new BusinessObjectDataStatusUpdateResponse();
        when(businessObjectDataStatusService.updateBusinessObjectDataStatus(businessObjectDataKey, request)).thenReturn(businessObjectDataStatusUpdateResponse);
        // Update the business object data status using the relative endpoint.
        BusinessObjectDataStatusUpdateResponse response = null;
        switch(i) {
            case 0:
                response = businessObjectDataStatusRestController.updateBusinessObjectDataStatus(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
                break;
            case 1:
                response = businessObjectDataStatusRestController.updateBusinessObjectDataStatus(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues.get(0), DATA_VERSION, new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
                break;
            case 2:
                response = businessObjectDataStatusRestController.updateBusinessObjectDataStatus(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues.get(0), subPartitionValues.get(1), DATA_VERSION, new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
                break;
            case 3:
                response = businessObjectDataStatusRestController.updateBusinessObjectDataStatus(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues.get(0), subPartitionValues.get(1), subPartitionValues.get(2), DATA_VERSION, new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
                break;
            case 4:
                response = businessObjectDataStatusRestController.updateBusinessObjectDataStatus(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues.get(0), subPartitionValues.get(1), subPartitionValues.get(2), subPartitionValues.get(3), DATA_VERSION, new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2));
                break;
        }
        verify(businessObjectDataStatusService).updateBusinessObjectDataStatus(businessObjectDataKey, request);
        assertEquals(businessObjectDataStatusUpdateResponse, response);
    }
    verifyNoMoreInteractions(businessObjectDataStatusService);
}
Also used : BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 13 with BusinessObjectDataStatusUpdateResponse

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

the class UpdateBusinessObjectDataStatusTest method testUpdateBusinessObjectDataStatusMissingOptionalParametersSubPartitionValuesAsEmptyString.

@Test
public void testUpdateBusinessObjectDataStatusMissingOptionalParametersSubPartitionValuesAsEmptyString() throws Exception {
    // Create a business object data key without sub-partition values.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data entity.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Create a business object data status entity.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStatus", "${businessObjectDataStatus}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("subPartitionValues", EMPTY_STRING));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataStatus", BDATA_STATUS_2));
    // Build the expected response object.
    BusinessObjectDataStatusUpdateResponse expectedBusinessObjectDataStatusUpdateResponse = new BusinessObjectDataStatusUpdateResponse(businessObjectDataKey, BDATA_STATUS_2, BDATA_STATUS);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(UpdateBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataStatusUpdateResponse));
    testActivitiServiceTaskSuccess(UpdateBusinessObjectDataStatus.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 14 with BusinessObjectDataStatusUpdateResponse

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

the class BusinessObjectDataStatusServiceImpl method updateBusinessObjectDataStatusImpl.

/**
 * Updates status of the business object data.
 *
 * @param businessObjectDataKey the business object data key
 * @param request the business object data status update request
 *
 * @return the business object data status update response
 */
protected BusinessObjectDataStatusUpdateResponse updateBusinessObjectDataStatusImpl(BusinessObjectDataKey businessObjectDataKey, BusinessObjectDataStatusUpdateRequest request) {
    // Validate and trim the business object data key.
    businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true);
    // Validate status
    Assert.hasText(request.getStatus(), "A business object data status must be specified.");
    request.setStatus(request.getStatus().trim());
    // Retrieve and ensure that a business object data exists with the specified key.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
    // Get the current status value.
    String previousBusinessObjectDataStatus = businessObjectDataEntity.getStatus().getCode();
    // Update the entity with the new values.
    businessObjectDataDaoHelper.updateBusinessObjectDataStatus(businessObjectDataEntity, request.getStatus());
    // Create and return the business object data status response object.
    BusinessObjectDataStatusUpdateResponse response = new BusinessObjectDataStatusUpdateResponse();
    response.setBusinessObjectDataKey(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity));
    response.setStatus(businessObjectDataEntity.getStatus().getCode());
    response.setPreviousStatus(previousBusinessObjectDataStatus);
    return response;
}
Also used : BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse)

Example 15 with BusinessObjectDataStatusUpdateResponse

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

the class UpdateBusinessObjectDataStatus method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String namespace = activitiHelper.getExpressionVariableAsString(this.namespace, execution);
    String businessObjectDefinitionName = activitiHelper.getExpressionVariableAsString(this.businessObjectDefinitionName, execution);
    String businessObjectFormatUsage = activitiHelper.getExpressionVariableAsString(this.businessObjectFormatUsage, execution);
    String businessObjectFormatFileType = activitiHelper.getExpressionVariableAsString(this.businessObjectFormatFileType, execution);
    Integer businessObjectFormatVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectFormatVersion, execution, "businessObjectFormatVersion", true);
    String partitionValue = activitiHelper.getExpressionVariableAsString(this.partitionValue, execution);
    String subPartitionValuesString = activitiHelper.getExpressionVariableAsString(this.subPartitionValues, execution);
    List<String> subPartitionValues = daoHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValuesString);
    Integer businessObjectDataVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectDataVersion, execution, "businessObjectDataVersion", true);
    String businessObjectDataStatus = activitiHelper.getExpressionVariableAsString(this.businessObjectDataStatus, execution);
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
    businessObjectDataKey.setNamespace(namespace);
    businessObjectDataKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    businessObjectDataKey.setBusinessObjectFormatUsage(businessObjectFormatUsage);
    businessObjectDataKey.setBusinessObjectFormatFileType(businessObjectFormatFileType);
    businessObjectDataKey.setBusinessObjectFormatVersion(businessObjectFormatVersion);
    businessObjectDataKey.setPartitionValue(partitionValue);
    businessObjectDataKey.setSubPartitionValues(subPartitionValues);
    businessObjectDataKey.setBusinessObjectDataVersion(businessObjectDataVersion);
    BusinessObjectDataStatusUpdateResponse businessObjectDataStatusUpdateResponse = businessObjectDataStatusService.updateBusinessObjectDataStatus(businessObjectDataKey, new BusinessObjectDataStatusUpdateRequest(businessObjectDataStatus));
    // Create a business object data notification.
    notificationEventService.processBusinessObjectDataNotificationEventAsync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG, businessObjectDataStatusUpdateResponse.getBusinessObjectDataKey(), businessObjectDataStatusUpdateResponse.getStatus(), businessObjectDataStatusUpdateResponse.getPreviousStatus());
    setJsonResponseAsWorkflowVariable(businessObjectDataStatusUpdateResponse, execution);
}
Also used : BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Aggregations

BusinessObjectDataStatusUpdateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse)17 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)14 Test (org.junit.Test)11 BusinessObjectDataStatusUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest)10 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 StringWriter (java.io.StringWriter)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 HttpPut (org.apache.http.client.methods.HttpPut)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 StringEntity (org.apache.http.entity.StringEntity)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1 Secured (org.springframework.security.access.annotation.Secured)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1