Hello Roman,
I have implemented the TimerEventListenerActivityBehavior as u have described.
Added a new test case TimeEventListenerItemHandlerTest and doing the basic tests like name, description, with/without parent. etc.
I have also added a timer expression test and startTrigger test, but not able to work it out.
@Test
public void testTimerExpression(){
//create a timer expression;
TimerExpression timerExprElement = createElement(timerEventListener, TimerExpression.class);
timerExprElement.setText("aTest");
Cmmn.validateModel(modelInstance);
CmmnActivity newActivity = timerEventListenerItemHandler.handleElement(planItem, context);
CmmnActivityBehavior timerEventActBehavior = newActivity.getActivityBehavior();
/*Expression tmrExpr=timerEventActBehavior.getTimerDef().getTimerExpression();
assertEquals(timerExprElement.getText(),tmrExpr.getText());*/
}
Do we also add a EventListenerDefinition, like there is a TaskDefinition assosciated with HumantTaskActivityBehavior and getting populated from the HumanTaskItemHandler?
Also, I dont see any testcase for the ActivityBehavior classes, how do I test these? Do i test using a complete deployment like below?
public class TimerEventListenerTest extends CmmnProcessEngineTestCase {
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/eventlistener/TimerEventListenerTest.testTimerEvents.cmmn"})
public void testTimerEvents() throws Exception {
Date date = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").parse("01-01-2015 12:10:00");
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("timerVariable", date);
String caseInstanceId = caseService.createCaseInstanceByKey("SampleCaseTimerEvent_1", variables).getId();
List<CaseInstance> caseInstList = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).list();
List<CaseExecution> caseExeList = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId).list();
//what goes here?
}
}
I have added the mentioned cmmn file.
I understand that ItemHandlers populates the behavior classes with camunda application data model of cmmn. Also i could trace that the behavior methods are called from some Command Objects. But I could not get the TimerActivityBehavior.created method to execute?
Please guide.
Thanks a lot for your time.
Subhro.