use of javax.jbi.messaging.MessageExchange in project petals-se-flowable by petalslink.
the class DeploymentTest method completeFirstUserTask.
private void completeFirstUserTask(final String procInstId) throws Exception {
final Validation requestBean = new Validation();
requestBean.setValideur(BPMN_USER_VALIDEUR);
requestBean.setNumeroDde(procInstId);
requestBean.setApprobation(Boolean.TRUE.toString());
// Send the 2nd valid request
final ServiceProviderImplementation service = new ServiceProviderImplementation() {
private MessageExchange archiveMessageExchange;
@Override
public Message provides(final RequestMessage archiveRequestMsg) throws Exception {
// Assert the 1st request sent by Flowable on orchestrated service
this.archiveMessageExchange = archiveRequestMsg.getMessageExchange();
assertNotNull(this.archiveMessageExchange);
assertEquals(ARCHIVE_INTERFACE, this.archiveMessageExchange.getInterfaceName());
assertEquals(ARCHIVE_SERVICE, this.archiveMessageExchange.getService());
assertNotNull(this.archiveMessageExchange.getEndpoint());
assertEquals(ARCHIVE_ENDPOINT, this.archiveMessageExchange.getEndpoint().getEndpointName());
assertEquals(ARCHIVER_OPERATION, this.archiveMessageExchange.getOperation());
assertEquals(ExchangeStatus.ACTIVE, this.archiveMessageExchange.getStatus());
final Object archiveRequestObj = UNMARSHALLER.unmarshal(archiveRequestMsg.getPayload());
assertTrue(archiveRequestObj instanceof Archiver);
final Archiver archiveRequest = (Archiver) archiveRequestObj;
assertEquals(procInstId, archiveRequest.getItem());
// Returns the reply of the service provider to the Flowable service task
final ArchiverResponse archiverResponse = new ArchiverResponse();
archiverResponse.setItem("value of item");
archiverResponse.setItem2("value of item2");
return new ResponseToConsumerMessage(archiveRequestMsg, toByteArray(archiverResponse));
}
@Override
public void handleStatus(final StatusMessage statusDoneMsg) throws Exception {
// Assert the status DONE on the message exchange
assertNotNull(statusDoneMsg);
// It's the same message exchange instance
assertSame(statusDoneMsg.getMessageExchange(), this.archiveMessageExchange);
assertEquals(ExchangeStatus.DONE, statusDoneMsg.getMessageExchange().getStatus());
}
};
final RequestToProviderMessage request = new RequestToProviderMessage(COMPONENT_UNDER_TEST, VACATION_SU, OPERATION_VALIDERDEMANDE, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(requestBean));
// Assert the response of the valid request
final ResponseMessage responseMsg = COMPONENT.sendAndGetResponse(request, service);
// Check the reply
final Source fault = responseMsg.getFault();
assertNull("Unexpected fault", (fault == null ? null : SourceHelper.toString(fault)));
assertNotNull("No XML payload in response", responseMsg.getPayload());
final Object responseObj = UNMARSHALLER.unmarshal(responseMsg.getPayload());
assertTrue(responseObj instanceof AckResponse);
COMPONENT.sendDoneStatus(responseMsg, service);
}
use of javax.jbi.messaging.MessageExchange in project petals-se-flowable by petalslink.
the class ProcessWithInOnlyConsumerTest method nominal.
/**
* <p>
* Check the service invocation with MEP InOnly returning an acknowledge
* </p>
* <p>
* Expected results:
* </p>
* <ul>
* <li>the process instance is correctly created in the Flowable engine,</li>
* <li>the service is correctly invoked,</li>
* <li>the process instance is automatically completed when all is correctly done,</li>
* <li>MONIT traces are as expected.</li>
* </ul>
*/
@Test
public void nominal() throws Exception {
final StringBuilder processInstanceId = new StringBuilder();
final Start start = new Start();
final RequestToProviderMessage request = new RequestToProviderMessage(COMPONENT_UNDER_TEST, INONLY_SU, OPERATION_START, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(start));
COMPONENT.sendAndCheckResponseAndSendStatus(request, new ServiceProviderImplementation() {
private MessageExchange msgExchange;
@Override
public Message provides(final RequestMessage requestMsg) throws Exception {
this.msgExchange = requestMsg.getMessageExchange();
assertNotNull(this.msgExchange);
assertEquals(ARCHIVE_INTERFACE, this.msgExchange.getInterfaceName());
assertEquals(ARCHIVE_SERVICE, this.msgExchange.getService());
assertNotNull(this.msgExchange.getEndpoint());
assertEquals(ARCHIVE_ENDPOINT, this.msgExchange.getEndpoint().getEndpointName());
assertEquals(ARCHIVER_OPERATION, this.msgExchange.getOperation());
assertEquals(ExchangeStatus.ACTIVE, this.msgExchange.getStatus());
assertEquals(MEPPatternConstants.IN_ONLY, MEPPatternConstants.fromURI(this.msgExchange.getPattern()));
final Object requestObj = UNMARSHALLER.unmarshal(requestMsg.getPayload());
assertTrue(requestObj instanceof Archiver);
// Returns the reply of the service provider to the Flowable service task
return new StatusToConsumerMessage(requestMsg, ExchangeStatus.DONE);
}
@Override
public boolean statusExpected() {
return false;
}
}, new MessageChecks() {
@Override
public void checks(final Message message) throws Exception {
// Check the reply
final Source fault = message.getFault();
assertNull("Unexpected fault", (fault == null ? null : SourceHelper.toString(fault)));
assertNotNull("No XML payload in response", message.getPayload());
final Object responseObj = UNMARSHALLER.unmarshal(message.getPayload());
assertTrue(responseObj instanceof StartResponse);
final StartResponse response = (StartResponse) responseObj;
assertNotNull(response.getCaseFileNumber());
processInstanceId.append(response.getCaseFileNumber());
}
}, ExchangeStatus.DONE);
this.waitEndOfProcessInstance(processInstanceId.toString());
// Check MONIT traces
final List<LogRecord> monitLogs = IN_MEMORY_LOG_HANDLER.getAllRecords(Level.MONIT);
assertEquals(6, monitLogs.size());
final FlowLogData initialInteractionRequestFlowLogData = assertMonitProviderBeginLog(INONLY_INTERFACE, INONLY_SERVICE, INONLY_ENDPOINT, OPERATION_START, monitLogs.get(0));
final FlowLogData processBeginFlowLogData = assertMonitConsumerExtBeginLog(monitLogs.get(1));
assertMonitProviderEndLog(initialInteractionRequestFlowLogData, this.extractProviderEnd(initialInteractionRequestFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
final FlowLogData serviceTaskRequestBeginFlowLogData = assertMonitProviderBeginLog(processBeginFlowLogData, ARCHIVE_INTERFACE, ARCHIVE_SERVICE, ARCHIVE_ENDPOINT, ARCHIVER_OPERATION, this.extractProviderBegin(ARCHIVE_ENDPOINT, monitLogs));
assertMonitProviderEndLog(serviceTaskRequestBeginFlowLogData, this.extractProviderEnd(serviceTaskRequestBeginFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
assertMonitConsumerExtEndLog(processBeginFlowLogData, this.extractConsumerExtEnd(processBeginFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
}
use of javax.jbi.messaging.MessageExchange in project petals-se-flowable by petalslink.
the class ProcessWithRobustInOnlyConsumerTest method nominal.
/**
* <p>
* Check the service invocation with MEP RobustInOnly when no error or fault occurs
* </p>
* <p>
* Expected results:
* </p>
* <ul>
* <li>the process instance is correctly created in the Flowable engine,</li>
* <li>the service is correctly invoked,</li>
* <li>the process instance is automatically completed when all is correctly done,</li>
* <li>MONIT traces are as expected.</li>
* </ul>
*/
@Test
public void nominal() throws Exception {
final StringBuilder processInstanceId = new StringBuilder();
final Start start = new Start();
final RequestToProviderMessage request = new RequestToProviderMessage(COMPONENT_UNDER_TEST, ROBUSTINONLY_SU, OPERATION_START, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(start));
COMPONENT.sendAndCheckResponseAndSendStatus(request, new ServiceProviderImplementation() {
@Override
public Message provides(final RequestMessage requestMsg) throws Exception {
final MessageExchange msgExchange = requestMsg.getMessageExchange();
assertNotNull(msgExchange);
assertEquals(ARCHIVE_INTERFACE, msgExchange.getInterfaceName());
assertEquals(ARCHIVE_SERVICE, msgExchange.getService());
assertNotNull(msgExchange.getEndpoint());
assertEquals(ARCHIVE_ENDPOINT, msgExchange.getEndpoint().getEndpointName());
assertEquals(ARCHIVER_OPERATION, msgExchange.getOperation());
assertEquals(ExchangeStatus.ACTIVE, msgExchange.getStatus());
assertEquals(MEPPatternConstants.ROBUST_IN_ONLY, MEPPatternConstants.fromURI(msgExchange.getPattern()));
final Object requestObj = UNMARSHALLER.unmarshal(requestMsg.getPayload());
assertTrue(requestObj instanceof Archiver);
// Returns the reply of the service provider to the Flowable service task
return new StatusToConsumerMessage(requestMsg, ExchangeStatus.DONE);
}
@Override
public boolean statusExpected() {
return false;
}
}, new MessageChecks() {
@Override
public void checks(final Message message) throws Exception {
// Check the reply
final Source fault = message.getFault();
assertNull("Unexpected fault", (fault == null ? null : SourceHelper.toString(fault)));
assertNotNull("No XML payload in response", message.getPayload());
final Object responseObj = UNMARSHALLER.unmarshal(message.getPayload());
assertTrue(responseObj instanceof StartResponse);
final StartResponse response = (StartResponse) responseObj;
assertNotNull(response.getCaseFileNumber());
processInstanceId.append(response.getCaseFileNumber());
}
}, ExchangeStatus.DONE);
this.waitEndOfProcessInstance(processInstanceId.toString());
// Check MONIT traces
final List<LogRecord> monitLogs = IN_MEMORY_LOG_HANDLER.getAllRecords(Level.MONIT);
assertEquals(6, monitLogs.size());
final FlowLogData initialInteractionRequestFlowLogData = assertMonitProviderBeginLog(ROBUSTINONLY_INTERFACE, ROBUSTINONLY_SERVICE, ROBUSTINONLY_ENDPOINT, OPERATION_START, monitLogs.get(0));
final FlowLogData processBeginFlowLogData = assertMonitConsumerExtBeginLog(monitLogs.get(1));
assertMonitProviderEndLog(initialInteractionRequestFlowLogData, this.extractProviderEnd(initialInteractionRequestFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
final FlowLogData serviceTaskRequestBeginFlowLogData = assertMonitProviderBeginLog(processBeginFlowLogData, ARCHIVE_INTERFACE, ARCHIVE_SERVICE, ARCHIVE_ENDPOINT, ARCHIVER_OPERATION, this.extractProviderBegin(ARCHIVE_ENDPOINT, monitLogs));
assertMonitProviderEndLog(serviceTaskRequestBeginFlowLogData, this.extractProviderEnd(serviceTaskRequestBeginFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
assertMonitConsumerExtEndLog(processBeginFlowLogData, this.extractConsumerExtEnd(processBeginFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
}
use of javax.jbi.messaging.MessageExchange in project petals-se-flowable by petalslink.
the class ProcessWithRobustifiedInOnlyConsumerTest method nominal.
/**
* <p>
* Check the service invocation with MEP InOnly
* </p>
* <p>
* Expected results:
* </p>
* <ul>
* <li>the process instance is correctly created in the Flowable engine,</li>
* <li>the service is correctly invoked,</li>
* <li>the process instance is automatically completed when all is correctly done.</li>
* </ul>
*/
@Test
public void nominal() throws Exception {
final StringBuilder processInstanceId = new StringBuilder();
final Start start = new Start();
final RequestToProviderMessage request = new RequestToProviderMessage(COMPONENT_UNDER_TEST, ROBUSTIFIED_INONLY_SU, OPERATION_START, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(start));
COMPONENT.sendAndCheckResponseAndSendStatus(request, new ServiceProviderImplementation() {
private MessageExchange msgExchange;
@Override
public Message provides(final RequestMessage requestMsg) throws Exception {
this.msgExchange = requestMsg.getMessageExchange();
assertNotNull(this.msgExchange);
assertEquals(ARCHIVE_INTERFACE, this.msgExchange.getInterfaceName());
assertEquals(ARCHIVE_SERVICE, this.msgExchange.getService());
assertNotNull(this.msgExchange.getEndpoint());
assertEquals(ARCHIVE_ENDPOINT, this.msgExchange.getEndpoint().getEndpointName());
assertEquals(ARCHIVER_OPERATION, this.msgExchange.getOperation());
assertEquals(ExchangeStatus.ACTIVE, this.msgExchange.getStatus());
assertEquals(MEPPatternConstants.ROBUST_IN_ONLY, MEPPatternConstants.fromURI(this.msgExchange.getPattern()));
final Object requestObj = UNMARSHALLER.unmarshal(requestMsg.getPayload());
assertTrue(requestObj instanceof Archiver);
// Returns the reply of the service provider to the Flowable service task
return new StatusToConsumerMessage(requestMsg, ExchangeStatus.DONE);
}
@Override
public boolean statusExpected() {
return false;
}
}, new MessageChecks() {
@Override
public void checks(final Message message) throws Exception {
// Check the reply
final Source fault = message.getFault();
assertNull("Unexpected fault", (fault == null ? null : SourceHelper.toString(fault)));
assertNotNull("No XML payload in response", message.getPayload());
final Object responseObj = UNMARSHALLER.unmarshal(message.getPayload());
assertTrue(responseObj instanceof StartResponse);
final StartResponse response = (StartResponse) responseObj;
assertNotNull(response.getCaseFileNumber());
processInstanceId.append(response.getCaseFileNumber());
}
}, ExchangeStatus.DONE);
this.waitEndOfProcessInstance(processInstanceId.toString());
// Check MONIT traces
final List<LogRecord> monitLogs = IN_MEMORY_LOG_HANDLER.getAllRecords(Level.MONIT);
assertEquals(6, monitLogs.size());
final FlowLogData initialInteractionRequestFlowLogData = assertMonitProviderBeginLog(ROBUSTIFIED_INONLY_INTERFACE, ROBUSTIFIED_INONLY_SERVICE, ROBUSTIFIED_INONLY_ENDPOINT, OPERATION_START, monitLogs.get(0));
final FlowLogData processBeginFlowLogData = assertMonitConsumerExtBeginLog(monitLogs.get(1));
assertMonitProviderEndLog(initialInteractionRequestFlowLogData, this.extractProviderEnd(initialInteractionRequestFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
final FlowLogData serviceTaskRequestBeginFlowLogData = assertMonitProviderBeginLog(processBeginFlowLogData, ARCHIVE_INTERFACE, ARCHIVE_SERVICE, ARCHIVE_ENDPOINT, ARCHIVER_OPERATION, this.extractProviderBegin(ARCHIVE_ENDPOINT, monitLogs));
assertMonitProviderEndLog(serviceTaskRequestBeginFlowLogData, this.extractProviderEnd(serviceTaskRequestBeginFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
assertMonitConsumerExtEndLog(processBeginFlowLogData, this.extractConsumerExtEnd(processBeginFlowLogData.get(FlowLogData.FLOW_STEP_ID_PROPERTY_NAME), monitLogs));
}
use of javax.jbi.messaging.MessageExchange in project petals-se-flowable by petalslink.
the class ServiceProviderCallActivityProcessTest method getArchiveAttachmentsServiceImplAsFault.
private ServiceProviderImplementation getArchiveAttachmentsServiceImplAsFault(final ArchiverResponse responseBean, final StringBuilder callActivityId_level1) {
return new ServiceProviderImplementation() {
private MessageExchange msgExchange;
@Override
public Message provides(final RequestMessage requestMsg) throws Exception {
this.msgExchange = requestMsg.getMessageExchange();
assertIsArchiveServiceRequest(this.msgExchange);
final Object requestObj = UNMARSHALLER.unmarshal(requestMsg.getPayload());
assertTrue(requestObj instanceof Archiver);
callActivityId_level1.append(((Archiver) requestObj).getItem());
// Returns a fault to the Flowable service task
final UnknownDocument archiveFault = new UnknownDocument();
archiveFault.setDocId("docId");
return new FaultToConsumerMessage(requestMsg, toByteArray(archiveFault));
}
@Override
public void handleStatus(final StatusMessage statusDoneMsg) throws Exception {
// Assert the status DONE on the message exchange
assertNotNull(statusDoneMsg);
// It's the same message exchange instance
assertSame(statusDoneMsg.getMessageExchange(), this.msgExchange);
assertEquals(statusDoneMsg.getMessageExchange().getStatus(), ExchangeStatus.DONE);
}
};
}
Aggregations