use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class ActivitiDelegateTest method testActivitiReportableError.
/**
* This method tests the scenario when an error that is not workflow related is throws while workflow is executing an Async type task like Timer. This error
* is logged as ERROR.
*/
@Test(expected = ActivitiException.class)
public void testActivitiReportableError() throws Exception {
BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH);
ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
FieldExtension exceptionField = new FieldExtension();
exceptionField.setFieldName("exceptionToThrow");
exceptionField.setExpression("${exceptionToThrow}");
serviceTask.getFieldExtensions().add(exceptionField);
jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel));
List<Parameter> parameters = new ArrayList<>();
Parameter parameter = new Parameter("exceptionToThrow", MockJavaDelegate.EXCEPTION_BPMN_ERROR);
parameters.add(parameter);
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, parameters));
org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult();
if (timer != null) {
executeWithoutLogging(Arrays.asList(ActivitiRuntimeHelper.class, TimerExecuteNestedActivityJobHandler.class), () -> {
activitiManagementService.executeJob(timer.getId());
});
}
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync.
/**
* Asserts that update job definition proceeds without exceptions when first task is set to async
*
* @throws Exception
*/
@Test
public void testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
ScriptTask element = new ScriptTask();
element.setId("script");
element.setScriptFormat("js");
element.setScript("// do nothing");
element.setAsynchronous(true);
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "script"));
process.addFlowElement(new SequenceFlow("script", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
jobDefinitionService.updateJobDefinition(namespace, jobName, new JobDefinitionUpdateRequest(null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionAssertSuccessWhenFirstTaskNotAsyncable.
/**
* Asserts that create job definition proceeds without exceptions when first task does not support async (ex. events)
*
* @throws Exception
*/
@Test
public void testCreateJobDefinitionAssertSuccessWhenFirstTaskNotAsyncable() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionAssertSuccessWhenFirstTaskAsync.
/**
* Asserts that create job definition proceeds without exceptions when first task is set to async
*
* @throws Exception
*/
@Test
public void testCreateJobDefinitionAssertSuccessWhenFirstTaskAsync() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
ScriptTask element = new ScriptTask();
element.setId("script");
element.setScriptFormat("js");
element.setScript("// do nothing");
element.setAsynchronous(true);
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "script"));
process.addFlowElement(new SequenceFlow("script", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class HerdActivitiServiceTaskTest method buildActivitiXml.
protected String buildActivitiXml(String implementation, List<FieldExtension> fieldExtensionList) throws Exception {
BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_TEST_SERVICE_TASK_WITH_CLASSPATH);
ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement(serviceTaskId);
serviceTask.setImplementation(implementation);
serviceTask.getFieldExtensions().addAll(fieldExtensionList);
return getActivitiXmlFromBpmnModel(bpmnModel);
}
Aggregations