use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.
the class StageDiscretionaryItemHandlerTest method testWithParent.
@Test
public void testWithParent() {
// given:
// a new activity as parent
CmmnCaseDefinition parent = new CmmnCaseDefinition("aParentActivity");
context.setParent(parent);
// when
CmmnActivity activity = handler.handleElement(discretionaryItem, context);
// then
assertEquals(parent, activity.getParent());
assertTrue(parent.getActivities().contains(activity));
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.
the class ItemHandler method createActivity.
protected CmmnActivity createActivity(CmmnElement element, CmmnHandlerContext context) {
String id = element.getId();
CmmnActivity parent = context.getParent();
CmmnActivity newActivity = null;
if (parent != null) {
newActivity = parent.createActivity(id);
} else {
CmmnCaseDefinition caseDefinition = context.getCaseDefinition();
newActivity = new CmmnActivity(id, caseDefinition);
}
newActivity.setCmmnElement(element);
CmmnActivityBehavior behavior = getActivityBehavior();
newActivity.setActivityBehavior(behavior);
return newActivity;
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.
the class CaseTaskActivityBehavior method triggerCallableElement.
protected void triggerCallableElement(CmmnActivityExecution execution, Map<String, Object> variables, String businessKey) {
CmmnCaseDefinition definition = getCaseDefinitionToCall(execution, getCallableElement());
CmmnCaseInstance caseInstance = execution.createSubCaseInstance(definition, businessKey);
caseInstance.create(variables);
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.
the class CaseExecutionTerminationTest method testTerminateCaseInstance.
@Test
public void testTerminateCaseInstance() {
// given ///////////////////////////////////////////////////////////////
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// a case execution associated with Stage X
CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
// a case execution associated with Task A
CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
// a case execution associated with Task B
CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
// when
caseInstance.terminate();
// then
assertTrue(caseInstance.isTerminated());
assertTrue(stageX.isTerminated());
assertTrue(taskA.isTerminated());
assertTrue(taskB.isTerminated());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.
the class CaseExecutionTerminationTest method testTerminateStage.
@Test
public void testTerminateStage() {
// given ///////////////////////////////////////////////////////////////
// a case definition
CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
// an active case instance
CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
caseInstance.create();
// a case execution associated with Stage X
CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
// a case execution associated with Task A
CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
// a case execution associated with Task B
CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
// when
stageX.terminate();
// then
assertTrue(caseInstance.isCompleted());
assertTrue(stageX.isTerminated());
assertTrue(taskA.isTerminated());
assertTrue(taskB.isTerminated());
}
Aggregations