use of org.ow2.petals.components.flowable.generic._1.SuspendProcessInstancesResponse in project petals-se-flowable by petalslink.
the class SuspendProcessInstancesOperation method doExecute.
@Override
public SuspendProcessInstancesResponse doExecute(final SuspendProcessInstances incomingObject) throws Exception {
final SuspendProcessInstancesResponse response = new SuspendProcessInstancesResponse();
final List<ProcessInstanceIdentifier> results = response.getProcessInstanceIdentifier();
for (final String processInstanceId : incomingObject.getProcessInstanceIdentifier()) {
this.log.fine(String.format("Suspends process instance #%s.", processInstanceId));
final ProcessInstanceIdentifier result = new ProcessInstanceIdentifier();
result.setValue(processInstanceId);
results.add(result);
try {
this.runtimeService.suspendProcessInstanceById(processInstanceId);
result.setResult(AdjournmentResult.SUSPENDED);
} catch (@SuppressWarnings("squid:S1166") final FlowableObjectNotFoundException e) {
result.setResult(AdjournmentResult.NOT_FOUND);
} catch (@SuppressWarnings("squid:S1166") final FlowableException e) {
result.setResult(AdjournmentResult.ALREADY_SUSPENDED);
}
}
return response;
}
use of org.ow2.petals.components.flowable.generic._1.SuspendProcessInstancesResponse in project petals-se-flowable by petalslink.
the class ServiceProviderVacationProcessTest method tryToSuspendProcessInstance.
private final void tryToSuspendProcessInstance(final String processInstanceId, final FlowLogData processStartedBeginFlowLogData, final AdjournmentResult expectedResult) throws Exception {
if (expectedResult == AdjournmentResult.SUSPENDED) {
// Check at Flowable level that the process instance is suspended
final List<org.flowable.engine.runtime.ProcessInstance> processInstances = this.flowableClient.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).list();
assertNotNull(processInstances);
assertEquals(1, processInstances.size());
assertFalse(processInstances.get(0).isSuspended());
}
final SuspendProcessInstances suspendProcessInstancesReq = new SuspendProcessInstances();
suspendProcessInstancesReq.getProcessInstanceIdentifier().add(processInstanceId);
IN_MEMORY_LOG_HANDLER.clear();
final RequestToProviderMessage requestM = new RequestToProviderMessage(COMPONENT_UNDER_TEST, NATIVE_PROCESSINSTANCES_SVC_CFG, ITG_OP_SUSPENDPROCESSINSTANCES, AbsItfOperation.MEPPatternConstants.IN_OUT.value(), toByteArray(suspendProcessInstancesReq));
{
final ResponseMessage suspendProcessInstancesRespMsg = COMPONENT.sendAndGetResponse(requestM);
assertNotNull("No XML payload in response", suspendProcessInstancesRespMsg.getPayload());
final Object suspendProcessInstancesRespObj = UNMARSHALLER.unmarshal(suspendProcessInstancesRespMsg.getPayload());
assertTrue(suspendProcessInstancesRespObj instanceof SuspendProcessInstancesResponse);
final SuspendProcessInstancesResponse suspendProcessInstancesResp = (SuspendProcessInstancesResponse) suspendProcessInstancesRespObj;
assertNotNull(suspendProcessInstancesResp.getProcessInstanceIdentifier());
assertEquals(1, suspendProcessInstancesResp.getProcessInstanceIdentifier().size());
assertNotNull(suspendProcessInstancesResp.getProcessInstanceIdentifier().get(0));
assertEquals(processInstanceId, suspendProcessInstancesResp.getProcessInstanceIdentifier().get(0).getValue());
assertEquals(expectedResult, suspendProcessInstancesResp.getProcessInstanceIdentifier().get(0).getResult());
COMPONENT.sendDoneStatus(suspendProcessInstancesRespMsg);
}
// Check MONIT traces about the process instance adjournment
final List<LogRecord> monitLogs_suspendProcessInstance = IN_MEMORY_LOG_HANDLER.getAllRecords(Level.MONIT);
assertEquals(2, monitLogs_suspendProcessInstance.size());
final FlowLogData providerBegin_suspendProcessInstance = assertMonitProviderBeginLog(ITG_PROCESSINSTANCES_PORT_TYPE, ITG_PROCESSINSTANCES_SERVICE, COMPONENT_UNDER_TEST.getNativeEndpointName(ITG_PROCESSINSTANCES_SERVICE), ITG_OP_SUSPENDPROCESSINSTANCES, monitLogs_suspendProcessInstance.get(0));
assertMonitProviderEndLog(providerBegin_suspendProcessInstance, monitLogs_suspendProcessInstance.get(1));
assertMonitFlowInstanceIdNotEquals(processStartedBeginFlowLogData, providerBegin_suspendProcessInstance);
if (expectedResult == AdjournmentResult.SUSPENDED) {
// Check at Flowable level that the process instance is suspended
final List<org.flowable.engine.runtime.ProcessInstance> processInstances = this.flowableClient.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).list();
assertNotNull(processInstances);
assertEquals(1, processInstances.size());
assertTrue(processInstances.get(0).isSuspended());
}
}
Aggregations