Search in sources :

Example 11 with BusinessObjectDataInvalidateUnregisteredRequest

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

the class InvalidateUnregisteredBusinessObjectDataTest method testInvalidateUnregisteredBusinessObjectDataSuccessXml.

/**
 * Tests a standard request that is valid XML.
 *
 * @throws Exception
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataSuccessXml() throws Exception {
    // The test request
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    // The expected response
    BusinessObjectDataInvalidateUnregisteredResponse expectedResponse = getExpectedBusinessObjectDataInvalidateUnregisteredResponse(request);
    // Setup format
    businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Construct Activiti parameters
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataInvalidateUnregisteredRequest", "${businessObjectDataInvalidateUnregisteredRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataInvalidateUnregisteredRequest", xmlHelper.objectToXml(request)));
    /*
         * Assert that:
         * Status is SUCCESS
         * Error message is not set
         * Response is expected JSON
         */
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_STATUS, ActivitiRuntimeHelper.TASK_STATUS_SUCCESS);
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_ERROR_MESSAGE, VARIABLE_VALUE_IS_NULL);
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedResponse));
    testActivitiServiceTaskSuccess(InvalidateUnregisteredBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test)

Example 12 with BusinessObjectDataInvalidateUnregisteredRequest

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

the class InvalidateUnregisteredBusinessObjectDataTest method testInvalidateUnregisteredBusinessObjectDataError.

/**
 * Test request which results in ERROR.
 *
 * @throws Exception
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataError() throws Exception {
    // The test request
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    // Construct Activiti parameters
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataInvalidateUnregisteredRequest", "${businessObjectDataInvalidateUnregisteredRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataInvalidateUnregisteredRequest", xmlHelper.objectToXml(request)));
    /*
         * Assert that:
         * Status is ERROR
         * Error message is appropriate
         * JSON response is not set
         */
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_STATUS, ActivitiRuntimeHelper.TASK_STATUS_ERROR);
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_ERROR_MESSAGE, "Business object format with namespace \"" + request.getNamespace() + "\", business object definition name \"" + request.getBusinessObjectDefinitionName() + "\", format usage \"" + request.getBusinessObjectFormatUsage() + "\", format file type \"" + request.getBusinessObjectFormatFileType() + "\", and format version \"" + request.getBusinessObjectFormatVersion() + "\" doesn't exist.");
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_IS_NULL);
    executeWithoutLogging(ActivitiRuntimeHelper.class, () -> {
        testActivitiServiceTaskFailure(InvalidateUnregisteredBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
    });
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) 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 13 with BusinessObjectDataInvalidateUnregisteredRequest

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

the class BusinessObjectDataRestControllerTest method testInvalidateUnregisteredBusinessObjectData.

@Test
public void testInvalidateUnregisteredBusinessObjectData() {
    // Create an invalidate unregistered business object data request.
    BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest = new BusinessObjectDataInvalidateUnregisteredRequest();
    // Create an invalidate unregistered business object data request.
    BusinessObjectDataInvalidateUnregisteredResponse businessObjectDataInvalidateUnregisteredResponse = new BusinessObjectDataInvalidateUnregisteredResponse();
    // Mock the external calls.
    when(businessObjectDataService.invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest)).thenReturn(businessObjectDataInvalidateUnregisteredResponse);
    // Call the method under test.
    BusinessObjectDataInvalidateUnregisteredResponse result = businessObjectDataRestController.invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest);
    // Verify the external calls.
    verify(businessObjectDataService).invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest);
    verify(businessObjectDataDaoHelper).triggerNotificationsForInvalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredResponse);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataInvalidateUnregisteredResponse, result);
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test)

Example 14 with BusinessObjectDataInvalidateUnregisteredRequest

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

the class MessageNotificationEventServiceTest method testProcessBusinessObjectFormatVersionChangeNotificationEvent.

@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEvent() throws Exception {
    // Create a business object format entity.
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Get a business object data key.
    BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity);
    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Trigger the notification.
    List<NotificationMessage> result = messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);
    // Validate the results.
    assertEquals(1, CollectionUtils.size(result));
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormatVersionChangeMessageWithXmlPayload(MESSAGE_TYPE, MESSAGE_DESTINATION, businessObjectFormatKey, HerdDaoSecurityHelper.SYSTEM_USER, businessObjectFormatKey.getBusinessObjectFormatVersion().toString(), NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION, Collections.singletonList(new MessageHeader(KEY, VALUE)), result.get(0));
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) NotificationMessage(org.finra.herd.model.dto.NotificationMessage) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) MessageHeader(org.finra.herd.model.dto.MessageHeader) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Example 15 with BusinessObjectDataInvalidateUnregisteredRequest

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

the class MessageNotificationEventServiceTest method testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageType.

@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageType() throws Exception {
    // Create a business object format entity.
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Get a business object data key.
    BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity);
    // Override configuration, so there will be no message type specified in the relative notification message definition.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Try to trigger the notification.
    try {
        // Trigger the notification.
        messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format("Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey()), e.getMessage());
    }
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Aggregations

BusinessObjectDataInvalidateUnregisteredRequest (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest)32 Test (org.junit.Test)31 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)21 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)21 BusinessObjectDataInvalidateUnregisteredResponse (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse)13 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)12 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)4 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)4 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)4 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 MessageHeaderDefinition (org.finra.herd.model.api.xml.MessageHeaderDefinition)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)3 BusinessObjectDataAvailabilityCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionRequest)1 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)1