@Test public void testCreateWorkItemEvent() throws HumanTaskManagerException { /* Subscribe on the CreateWorkItemEvent */ eventhandler.subscribe(CreateWorkItemEvent.class, eventSubscriber); try { dataAccessRepository.beginTx(); /* Create the task instance during creation the work items are created as well, * thus the CreateWorkItem event is sent to all subscribers */ String tiid = createTaskInstanceDummy(); /* A potential owner claims the task instance this modifies the existing * work items (they are set to claimed), thus the ModifyWorkItem event is sent * to all its subscribers */ String userId = getExpectedPotentialOwners()[0]; initSecurityContext(userId, USER_PASSWORD); taskClient.claim(tiid); List<IEvent> events = eventSubscriber.getReceivedEvents(); List<WorkItemView> expectedWorkItemViews = taskClient.query("TIID=" + tiid); assertEquals(expectedWorkItemViews.size(), events.size()); dataAccessRepository.commitTx(); } catch (HumanTaskManagerException e) { dataAccessRepository.rollbackTx(); throw e; } finally { dataAccessRepository.close(); } }
/** * Creates a new {@link TaskParentInterfaceImpl} object.</b> It initializes the {@link * IDataAccessProvider}</b> Moreover all timers are reactivated (e.g. suspend until timer, * expiration timer). See {@link TaskInstanceTimers} for more information. */ public TaskParentInterfaceImpl() { // this.dataAccessProvider = IDataAccessProvider.Factory.newInstance(); this.evenHandler = EventHandler.newInstance(); /* * Reactivate all task instance timers (e.g. suspend until timer, * expiration timer) i.e. schedule the execution of certain actions * until their timer has expired. */ TaskInstanceTimers.reactivateTimers(); }
@Before public void init() throws HumanTaskManagerException, FileNotFoundException, SQLException, IOException { /* Create test task models, logical people groups, user etc. */ super.init(); eventhandler = EventHandler.newInstance(); /* Init the event subscriber that is used in the test cases */ eventSubscriber = new EventSubscriber(); /* The task client interface is also required in the test cases */ // TaskClientInterface = new TaskClientInterfaceImpl(); }
protected void publishNewWorkItemEvent(List<IWorkItem> workItems) { if (workItems != null) { Iterator<IWorkItem> iter = workItems.iterator(); /* * Create an event for each work item that was created and inform * the subscribers about it */ while (iter.hasNext()) { evenHandler.notifySubscribers( new CreateWorkItemEvent(new WorkItemView((IWorkItem) iter.next()))); } } }