workflowService().release (subs);
}
public void testFilters () throws Exception {
// Obtain subscribers
EventSubscriber subs = workflowService().createEventSubscriber ();
// create the required process
WfRequester req = new DefaultRequester (workflowService());
process = createProcess("ut-procdef-audit", "auditTest2", req);
String procKey = process.key();
assertTrue(process != null);
// additional subscribers
final int[] counters = new int[5];
EventSubscriber subsAll = workflowService().createEventSubscriber ();
subsAll.setEventHandler(new WfAuditHandler () {
public void receiveEvent (WfAuditEvent e) {
counters[0] += 1;
}
});
EventSubscriber subsProc = workflowService()
.createEventSubscriber (procKey, null);
subsProc.setEventHandler(new WfAuditHandler () {
public void receiveEvent (WfAuditEvent e) {
counters[1] += 1;
}
});
EventSubscriber subsPSC = workflowService().createEventSubscriber
(procKey, WfAuditEvent.PROCESS_STATE_CHANGED);
subsPSC.setEventHandler(new WfAuditHandler () {
public void receiveEvent (WfAuditEvent e) {
assertTrue (e.eventType().equals
(WfAuditEvent.PROCESS_STATE_CHANGED));
counters[2] += 1;
}
});
EventSubscriber subsASC = workflowService().createEventSubscriber
(procKey, WfAuditEvent.ACTIVITY_STATE_CHANGED);
subsASC.setEventHandler(new WfAuditHandler () {
public void receiveEvent (WfAuditEvent e) {
assertTrue (e.eventType().equals
(WfAuditEvent.ACTIVITY_STATE_CHANGED));
counters[3] += 1;
}
});
EventSubscriber subsPASC = workflowService().createEventSubscriber
(procKey, WfAuditEvent.PROCESS_STATE_CHANGED
+ ", " + WfAuditEvent.ACTIVITY_STATE_CHANGED);
subsPASC.setEventHandler(new WfAuditHandler () {
public void receiveEvent (WfAuditEvent e) {
assertTrue (e.eventType().equals
(WfAuditEvent.PROCESS_STATE_CHANGED)
|| e.eventType().equals
(WfAuditEvent.ACTIVITY_STATE_CHANGED));