use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testIntermediateTimerEvent.
@Deployment
public void testIntermediateTimerEvent() {
// given
final List<String> timerEvents = new ArrayList<String>();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution delegateExecution) {
String currentActivityId = delegateExecution.getCurrentActivityId();
String eventName = delegateExecution.getEventName();
if ("timer".equals(currentActivityId) && (ExecutionListener.EVENTNAME_START.equals(eventName) || ExecutionListener.EVENTNAME_END.equals(eventName))) {
timerEvents.add(delegateExecution.getEventName());
}
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// when
runtimeService.startProcessInstanceByKey("process");
String jobId = managementService.createJobQuery().singleResult().getId();
managementService.executeJob(jobId);
// then
assertEquals(2, timerEvents.size());
// "start" event listener
assertEquals(ExecutionListener.EVENTNAME_START, timerEvents.get(0));
// "end" event listener
assertEquals(ExecutionListener.EVENTNAME_END, timerEvents.get(1));
}
use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testExecutionListenerWithTimerBoundaryEvent.
@Deployment
public void testExecutionListenerWithTimerBoundaryEvent() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
eventCount.incrementAndGet();
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// 1. (start)startEvent(end) -(take)-> (start)userTask(end) -(take)-> (start)endEvent(end) (8 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// complete task
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertEquals(10, eventCount.get());
// reset counter
eventCount.set(0);
// 2. (start)startEvent(end) -(take)-> (start)userTask(end)/(start)timerBoundaryEvent(end) -(take)-> (start)endEvent(end) (10 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// fire timer event
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
assertEquals(12, eventCount.get());
}
use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class DecisionServiceTest method evaluateDecisionTableByKeyAndLatestVersion.
@Deployment(resources = DMN_DECISION_TABLE)
@Test
public void evaluateDecisionTableByKeyAndLatestVersion() {
testRule.deploy(DMN_DECISION_TABLE_V2);
DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableByKey(DECISION_DEFINITION_KEY, createVariables());
assertThatDecisionHasResult(decisionResult, RESULT_OF_SECOND_VERSION);
}
use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class DecisionServiceTest method evaluateDecisionTableByKeyAndVersion.
@Deployment(resources = DMN_DECISION_TABLE)
@Test
public void evaluateDecisionTableByKeyAndVersion() {
testRule.deploy(DMN_DECISION_TABLE_V2);
DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableByKeyAndVersion(DECISION_DEFINITION_KEY, 1, createVariables());
assertThatDecisionHasResult(decisionResult, RESULT_OF_FIRST_VERSION);
}
use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.
the class DecisionServiceTest method evaluateDecisionByKeyAndVersion.
@Deployment(resources = DMN_DECISION_LITERAL_EXPRESSION)
@Test
public void evaluateDecisionByKeyAndVersion() {
testRule.deploy(DMN_DECISION_LITERAL_EXPRESSION_V2);
DmnDecisionResult decisionResult = decisionService.evaluateDecisionByKey(DECISION_DEFINITION_KEY).version(1).variables(createVariables()).evaluate();
assertThatDecisionHasResult(decisionResult, RESULT_OF_FIRST_VERSION);
}
Aggregations