Search in sources :

Example 6 with CamundaTaskListener

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);
}
Also used : CamundaTaskListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask)

Example 7 with CamundaTaskListener

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");
}
Also used : CamundaTaskListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener) Test(org.junit.Test)

Example 8 with CamundaTaskListener

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);
}
Also used : CamundaField(org.camunda.bpm.model.bpmn.instance.camunda.CamundaField) CamundaTaskListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener) Test(org.junit.Test)

Example 9 with CamundaTaskListener

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'");
}
Also used : CamundaTaskListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener) CamundaScript(org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript) Test(org.junit.Test)

Example 10 with CamundaTaskListener

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");
}
Also used : CamundaTaskListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener) Test(org.junit.Test)

Aggregations

CamundaTaskListener (org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener)12 Test (org.junit.Test)6 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)2 CamundaField (org.camunda.bpm.model.bpmn.instance.camunda.CamundaField)1 CamundaScript (org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1