use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener in project camunda-bpm-platform by camunda.
the class MigrationUserTaskTest method addTaskListener.
protected static void addTaskListener(BpmnModelInstance targetModel, String activityId, String event, String className) {
CamundaTaskListener taskListener = targetModel.newInstance(CamundaTaskListener.class);
taskListener.setCamundaClass(className);
taskListener.setCamundaEvent(event);
UserTask task = targetModel.getModelElementById(activityId);
task.builder().addExtensionElement(taskListener);
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener in project camunda-bpmn-model by camunda.
the class ProcessBuilderTest method testCamundaTaskListenerByClass.
@Test
public void testCamundaTaskListenerByClass() {
modelInstance = Bpmn.createProcess().startEvent().userTask("task").camundaTaskListenerClass("start", this.getClass()).endEvent().done();
UserTask userTask = modelInstance.getModelElementById("task");
ExtensionElements extensionElements = userTask.getExtensionElements();
Collection<CamundaTaskListener> taskListeners = extensionElements.getChildElementsByType(CamundaTaskListener.class);
assertThat(taskListeners).hasSize(1);
CamundaTaskListener taskListener = taskListeners.iterator().next();
assertThat(taskListener.getCamundaClass()).isEqualTo(this.getClass().getName());
assertThat(taskListener.getCamundaEvent()).isEqualTo("start");
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testTaskListener.
@Test
public void testTaskListener() {
CamundaTaskListener taskListener = userTask.getExtensionElements().getElementsQuery().filterByType(CamundaTaskListener.class).list().get(0);
assertThat(taskListener.getCamundaEvent()).isEqualTo(TEST_TASK_EVENT_XML);
assertThat(taskListener.getCamundaClass()).isEqualTo(TEST_CLASS_XML);
assertThat(taskListener.getCamundaExpression()).isEqualTo(TEST_EXPRESSION_XML);
assertThat(taskListener.getCamundaDelegateExpression()).isEqualTo(TEST_DELEGATE_EXPRESSION_XML);
taskListener.setCamundaEvent(TEST_TASK_EVENT_API);
taskListener.setCamundaClass(TEST_CLASS_API);
taskListener.setCamundaExpression(TEST_EXPRESSION_API);
taskListener.setCamundaDelegateExpression(TEST_DELEGATE_EXPRESSION_API);
assertThat(taskListener.getCamundaEvent()).isEqualTo(TEST_TASK_EVENT_API);
assertThat(taskListener.getCamundaClass()).isEqualTo(TEST_CLASS_API);
assertThat(taskListener.getCamundaExpression()).isEqualTo(TEST_EXPRESSION_API);
assertThat(taskListener.getCamundaDelegateExpression()).isEqualTo(TEST_DELEGATE_EXPRESSION_API);
CamundaField field = taskListener.getCamundaFields().iterator().next();
assertThat(field.getCamundaName()).isEqualTo(TEST_STRING_XML);
assertThat(field.getCamundaString().getTextContent()).isEqualTo(TEST_STRING_XML);
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testCamundaScriptTaskListener.
@Test
public void testCamundaScriptTaskListener() {
CamundaTaskListener taskListener = userTask.getExtensionElements().getElementsQuery().filterByType(CamundaTaskListener.class).list().get(1);
CamundaScript script = taskListener.getCamundaScript();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isEqualTo("test.groovy");
assertThat(script.getTextContent()).isEmpty();
CamundaScript newScript = modelInstance.newInstance(CamundaScript.class);
newScript.setCamundaScriptFormat("groovy");
newScript.setTextContent("println 'Hello World'");
taskListener.setCamundaScript(newScript);
script = taskListener.getCamundaScript();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isNull();
assertThat(script.getTextContent()).isEqualTo("println 'Hello World'");
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener in project camunda-bpmn-model by camunda.
the class ProcessBuilderTest method testCamundaTaskListenerByExpression.
@Test
public void testCamundaTaskListenerByExpression() {
modelInstance = Bpmn.createProcess().startEvent().userTask("task").camundaTaskListenerExpression("start", "anExpression").endEvent().done();
UserTask userTask = modelInstance.getModelElementById("task");
ExtensionElements extensionElements = userTask.getExtensionElements();
Collection<CamundaTaskListener> taskListeners = extensionElements.getChildElementsByType(CamundaTaskListener.class);
assertThat(taskListeners).hasSize(1);
CamundaTaskListener taskListener = taskListeners.iterator().next();
assertThat(taskListener.getCamundaExpression()).isEqualTo("anExpression");
assertThat(taskListener.getCamundaEvent()).isEqualTo("start");
}
Aggregations