Search in sources :

Example 21 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testTaskDefinitionFollowUpDateExpression.

@Test
public void testTaskDefinitionFollowUpDateExpression() {
    // given
    String aFollowUpDate = "aFollowDate";
    humanTask.setCamundaFollowUpDate(aFollowUpDate);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    Expression followUpDateExpression = taskDefinition.getFollowUpDateExpression();
    assertNotNull(followUpDateExpression);
    assertEquals(aFollowUpDate, followUpDateExpression.getExpressionText());
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 22 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class HumanTaskPlanItemHandlerTest method testDeleteTaskListenerByDelegateExpression.

@Test
public void testDeleteTaskListenerByDelegateExpression() {
    // given:
    ExtensionElements extensionElements = addExtensionElements(humanTask);
    CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);
    String delegateExpression = "${myDelegateExpression}";
    String event = TaskListener.EVENTNAME_DELETE;
    taskListener.setCamundaEvent(event);
    taskListener.setCamundaDelegateExpression(delegateExpression);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    assertEquals(0, activity.getListeners().size());
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    TaskDefinition taskDefinition = behavior.getTaskDefinition();
    assertNotNull(taskDefinition);
    assertEquals(1, taskDefinition.getTaskListeners().size());
    List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
    assertEquals(1, createListeners.size());
    TaskListener listener = createListeners.get(0);
    assertTrue(listener instanceof DelegateExpressionTaskListener);
    DelegateExpressionTaskListener delegateExpressionListener = (DelegateExpressionTaskListener) listener;
    assertEquals(delegateExpression, delegateExpressionListener.getExpressionText());
    assertTrue(delegateExpressionListener.getFieldDeclarations().isEmpty());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 23 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class CmmnElementHandlerTest method setup.

@Before
public void setup() {
    modelInstance = Cmmn.createEmptyModel();
    definitions = modelInstance.newInstance(Definitions.class);
    definitions.setTargetNamespace("http://camunda.org/examples");
    modelInstance.setDefinitions(definitions);
    caseDefinition = createElement(definitions, "aCaseDefinition", Case.class);
    casePlanModel = createElement(caseDefinition, "aCasePlanModel", CasePlanModel.class);
    context = new CmmnHandlerContext();
    CaseDefinitionEntity caseDefinition = new CaseDefinitionEntity();
    caseDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
    context.setCaseDefinition(caseDefinition);
    ExpressionManager expressionManager = new ExpressionManager();
    context.setExpressionManager(expressionManager);
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Definitions(org.camunda.bpm.model.cmmn.instance.Definitions) CmmnHandlerContext(org.camunda.bpm.engine.impl.cmmn.handler.CmmnHandlerContext) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) Case(org.camunda.bpm.model.cmmn.instance.Case) Before(org.junit.Before)

Example 24 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class TaskDecoratorTest method setUp.

public void setUp() {
    task = (TaskEntity) taskService.newTask();
    taskService.saveTask(task);
    expressionManager = processEngineConfiguration.getExpressionManager();
    taskDefinition = new TaskDefinition(null);
    taskDecorator = new TaskDecorator(taskDefinition, expressionManager);
}
Also used : TaskDecorator(org.camunda.bpm.engine.impl.task.TaskDecorator) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition)

Example 25 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class EntitySerializationTest method testTaskEntitySerialization.

public void testTaskEntitySerialization() throws Exception {
    TaskEntity task = new TaskEntity();
    task.setDelegationState(DelegationState.RESOLVED);
    task.setExecution(new ExecutionEntity());
    task.setProcessInstance(new ExecutionEntity());
    task.setTaskDefinition(new TaskDefinition(null));
    task.setAssignee("kermit");
    task.setCreateTime(new Date());
    task.setDescription("Test description");
    task.setDueDate(new Date());
    task.setName("myTask");
    task.setEventName("end");
    task.setDeleted(false);
    task.setDelegationStateString(DelegationState.RESOLVED.name());
    byte[] data = writeObject(task);
    task = (TaskEntity) readObject(data);
    assertEquals("kermit", task.getAssignee());
    assertEquals("myTask", task.getName());
    assertEquals("end", task.getEventName());
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Date(java.util.Date)

Aggregations

TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)39 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)24 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)23 Test (org.junit.Test)23 Expression (org.camunda.bpm.engine.delegate.Expression)12 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)12 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)12 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)12 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)12 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)12 CamundaTaskListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener)12 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)11 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)4 UserTaskActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.UserTaskActivityBehavior)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 TaskDecorator (org.camunda.bpm.engine.impl.task.TaskDecorator)3 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)2 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2