Search in sources :

Example 1 with BusinessObjectDataStorageUnitStatusUpdateResponse

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

the class UpdateBusinessObjectDataStorageUnitStatus 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);
    String storageName = activitiHelper.getExpressionVariableAsString(this.storageName, execution);
    Integer businessObjectDataVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectDataVersion, execution, "businessObjectDataVersion", true);
    String businessObjectDataStorageUnitStatus = activitiHelper.getExpressionVariableAsString(this.businessObjectDataStorageUnitStatus, execution);
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey();
    businessObjectDataStorageUnitKey.setNamespace(namespace);
    businessObjectDataStorageUnitKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    businessObjectDataStorageUnitKey.setBusinessObjectFormatUsage(businessObjectFormatUsage);
    businessObjectDataStorageUnitKey.setBusinessObjectFormatFileType(businessObjectFormatFileType);
    businessObjectDataStorageUnitKey.setBusinessObjectFormatVersion(businessObjectFormatVersion);
    businessObjectDataStorageUnitKey.setPartitionValue(partitionValue);
    businessObjectDataStorageUnitKey.setSubPartitionValues(subPartitionValues);
    businessObjectDataStorageUnitKey.setBusinessObjectDataVersion(businessObjectDataVersion);
    businessObjectDataStorageUnitKey.setStorageName(storageName);
    BusinessObjectDataStorageUnitStatusUpdateResponse businessObjectDataStorageUnitStatusUpdateResponse = businessObjectDataStorageUnitStatusService.updateBusinessObjectDataStorageUnitStatus(businessObjectDataStorageUnitKey, new BusinessObjectDataStorageUnitStatusUpdateRequest(businessObjectDataStorageUnitStatus));
    // Create a storage unit notification.
    notificationEventService.processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, storageUnitHelper.getBusinessObjectDataKey(businessObjectDataStorageUnitStatusUpdateResponse.getBusinessObjectDataStorageUnitKey()), businessObjectDataStorageUnitStatusUpdateResponse.getBusinessObjectDataStorageUnitKey().getStorageName(), businessObjectDataStorageUnitStatusUpdateResponse.getStatus(), businessObjectDataStorageUnitStatusUpdateResponse.getPreviousStatus());
    setJsonResponseAsWorkflowVariable(businessObjectDataStorageUnitStatusUpdateResponse, execution);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) BusinessObjectDataStorageUnitStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateResponse) BusinessObjectDataStorageUnitStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateRequest)

Example 2 with BusinessObjectDataStorageUnitStatusUpdateResponse

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

the class BusinessObjectDataStorageUnitStatusServiceImplTest method testUpdateBusinessObjectDataStorageUnitStatus.

@Test
public void testUpdateBusinessObjectDataStorageUnitStatus() {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data storage unit key.
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME);
    // Create a storage unit entity.
    StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS);
    // Create a storage unit status entity.
    StorageUnitStatusEntity storageUnitStatusEntity = storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(STORAGE_UNIT_STATUS_2);
    // Create a business object data storage unit status update request.
    BusinessObjectDataStorageUnitStatusUpdateRequest request = new BusinessObjectDataStorageUnitStatusUpdateRequest(STORAGE_UNIT_STATUS_2);
    // Create a business object data storage unit status update response.
    BusinessObjectDataStorageUnitStatusUpdateResponse expectedResponse = new BusinessObjectDataStorageUnitStatusUpdateResponse(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS);
    // Mock the external calls.
    when(storageUnitDaoHelper.getStorageUnitEntityByKey(businessObjectDataStorageUnitKey)).thenReturn(storageUnitEntity);
    when(storageUnitStatusDaoHelper.getStorageUnitStatusEntity(STORAGE_UNIT_STATUS_2)).thenReturn(storageUnitStatusEntity);
    doAnswer(new Answer<Void>() {

        public Void answer(InvocationOnMock invocation) {
            // Get the storage unit entity parameter.
            StorageUnitEntity storageUnitEntity = (StorageUnitEntity) invocation.getArguments()[0];
            StorageUnitStatusEntity storageUnitStatusEntity = (StorageUnitStatusEntity) invocation.getArguments()[1];
            // Update storage unit status.
            storageUnitEntity.setStatus(storageUnitStatusEntity);
            return null;
        }
    }).when(storageUnitDaoHelper).updateStorageUnitStatus(storageUnitEntity, storageUnitStatusEntity, STORAGE_UNIT_STATUS_2);
    when(businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData())).thenReturn(businessObjectDataKey);
    when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey);
    // Call the method under test.
    BusinessObjectDataStorageUnitStatusUpdateResponse result = businessObjectDataStorageUnitStatusServiceImpl.updateBusinessObjectDataStorageUnitStatus(businessObjectDataStorageUnitKey, request);
    // Verify the external calls.
    verify(storageUnitHelper).validateBusinessObjectDataStorageUnitKey(businessObjectDataStorageUnitKey);
    verify(storageUnitDaoHelper).getStorageUnitEntityByKey(businessObjectDataStorageUnitKey);
    verify(storageUnitStatusDaoHelper).getStorageUnitStatusEntity(STORAGE_UNIT_STATUS_2);
    verify(storageUnitDaoHelper).updateStorageUnitStatus(storageUnitEntity, storageUnitStatusEntity, STORAGE_UNIT_STATUS_2);
    verify(businessObjectDataHelper).createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData());
    verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(expectedResponse, result);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) InvocationOnMock(org.mockito.invocation.InvocationOnMock) StorageUnitStatusEntity(org.finra.herd.model.jpa.StorageUnitStatusEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataStorageUnitStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateRequest) BusinessObjectDataStorageUnitStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateResponse) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 3 with BusinessObjectDataStorageUnitStatusUpdateResponse

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

the class BusinessObjectDataStorageUnitStatusServiceImpl method updateBusinessObjectDataStorageUnitStatusImpl.

/**
 * Updates status of a business object data storage unit.
 *
 * @param businessObjectDataStorageUnitKey the business object data storage unit key
 * @param request the business object data storage unit status update request
 *
 * @return the business object data storage unit status update response
 */
protected BusinessObjectDataStorageUnitStatusUpdateResponse updateBusinessObjectDataStorageUnitStatusImpl(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey, BusinessObjectDataStorageUnitStatusUpdateRequest request) {
    // Validate and trim the business object data storage unit key.
    storageUnitHelper.validateBusinessObjectDataStorageUnitKey(businessObjectDataStorageUnitKey);
    // Validate status.
    Assert.hasText(request.getStatus(), "A business object data storage unit status must be specified.");
    request.setStatus(request.getStatus().trim());
    // Retrieve and ensure that a business object data storage unit exists with the specified key.
    StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntityByKey(businessObjectDataStorageUnitKey);
    // Retrieve and ensure the new storage unit status entity exists.
    StorageUnitStatusEntity newStorageUnitStatusEntity = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(request.getStatus());
    // Save the old storage unit status value.
    String oldStorageUnitStatus = storageUnitEntity.getStatus().getCode();
    // Update the storage unit status.
    storageUnitDaoHelper.updateStorageUnitStatus(storageUnitEntity, newStorageUnitStatusEntity, request.getStatus());
    // Get business object data key from the business object data entity.
    BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData());
    // Create and return the business object data storage unit status response object.
    BusinessObjectDataStorageUnitStatusUpdateResponse response = new BusinessObjectDataStorageUnitStatusUpdateResponse();
    response.setBusinessObjectDataStorageUnitKey(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, storageUnitEntity.getStorage().getName()));
    response.setStatus(storageUnitEntity.getStatus().getCode());
    response.setPreviousStatus(oldStorageUnitStatus);
    return response;
}
Also used : StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) StorageUnitStatusEntity(org.finra.herd.model.jpa.StorageUnitStatusEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataStorageUnitStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateResponse)

Example 4 with BusinessObjectDataStorageUnitStatusUpdateResponse

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

the class BusinessObjectDataStorageUnitStatusRestControllerTest method testUpdateBusinessObjectDataStorageUnitStatus.

@Test
public void testUpdateBusinessObjectDataStorageUnitStatus() {
    // Test for the business object data having all possible 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);
        // Create a business object data key.
        BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION);
        // Create a business object data storage unit key.
        BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues, DATA_VERSION, STORAGE_NAME);
        // Create a business object data storage unit status update request.
        BusinessObjectDataStorageUnitStatusUpdateRequest request = new BusinessObjectDataStorageUnitStatusUpdateRequest(STORAGE_UNIT_STATUS_2);
        // Create a business object data storage unit status update response.
        BusinessObjectDataStorageUnitStatusUpdateResponse expectedResponse = new BusinessObjectDataStorageUnitStatusUpdateResponse(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS);
        // Mock the external calls.
        when(businessObjectDataStorageUnitStatusService.updateBusinessObjectDataStorageUnitStatus(businessObjectDataStorageUnitKey, request)).thenReturn(expectedResponse);
        when(storageUnitHelper.getBusinessObjectDataKey(businessObjectDataStorageUnitKey)).thenReturn(businessObjectDataKey);
        // Call the method under test.
        BusinessObjectDataStorageUnitStatusUpdateResponse result = null;
        switch(i) {
            case 0:
                result = businessObjectDataStorageUnitStatusRestController.updateBusinessObjectDataStorageUnitStatus(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, request);
                break;
            case 1:
                result = businessObjectDataStorageUnitStatusRestController.updateBusinessObjectDataStorageUnitStatus(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues.get(0), DATA_VERSION, STORAGE_NAME, request);
                break;
            case 2:
                result = businessObjectDataStorageUnitStatusRestController.updateBusinessObjectDataStorageUnitStatus(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, subPartitionValues.get(0), subPartitionValues.get(1), DATA_VERSION, STORAGE_NAME, request);
                break;
            case 3:
                result = businessObjectDataStorageUnitStatusRestController.updateBusinessObjectDataStorageUnitStatus(BDEF_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, STORAGE_NAME, request);
                break;
            case 4:
                result = businessObjectDataStorageUnitStatusRestController.updateBusinessObjectDataStorageUnitStatus(BDEF_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, STORAGE_NAME, request);
                break;
        }
        // Verify the external calls.
        verify(businessObjectDataStorageUnitStatusService).updateBusinessObjectDataStorageUnitStatus(businessObjectDataStorageUnitKey, request);
        verify(storageUnitHelper).getBusinessObjectDataKey(businessObjectDataStorageUnitKey);
        verify(notificationEventService).processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, businessObjectDataKey, STORAGE_NAME, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS);
        verifyNoMoreInteractions(businessObjectDataStorageUnitStatusService, notificationEventService, storageUnitHelper);
        // Validate the results.
        assertEquals(expectedResponse, result);
    }
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataStorageUnitStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateRequest) BusinessObjectDataStorageUnitStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateResponse) Test(org.junit.Test)

Example 5 with BusinessObjectDataStorageUnitStatusUpdateResponse

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

the class UpdateBusinessObjectDataStorageUnitStatusTest method testUpdateBusinessObjectDataStorageUnitStatusMissingOptionalParametersSubPartitionValuesAsEmptyString.

@Test
public void testUpdateBusinessObjectDataStorageUnitStatusMissingOptionalParametersSubPartitionValuesAsEmptyString() throws Exception {
    // Create a business object data storage unit key.
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME);
    // Create a storage unit entity.
    storageUnitDaoTestHelper.createStorageUnitEntity(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS);
    // Create a storage unit status entity.
    storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(STORAGE_UNIT_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("storageName", "${storageName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStorageUnitStatus", "${businessObjectDataStorageUnitStatus}"));
    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("storageName", STORAGE_NAME));
    parameters.add(buildParameter("businessObjectDataStorageUnitStatus", STORAGE_UNIT_STATUS_2));
    // Build the expected response object.
    BusinessObjectDataStorageUnitStatusUpdateResponse expectedResponse = new BusinessObjectDataStorageUnitStatusUpdateResponse(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(UpdateBusinessObjectDataStorageUnitStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedResponse));
    testActivitiServiceTaskSuccess(UpdateBusinessObjectDataStorageUnitStatus.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataStorageUnitStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateResponse) Test(org.junit.Test)

Aggregations

BusinessObjectDataStorageUnitStatusUpdateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateResponse)8 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 BusinessObjectDataStorageUnitStatusUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitStatusUpdateRequest)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)2 StorageUnitStatusEntity (org.finra.herd.model.jpa.StorageUnitStatusEntity)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1