private List<FlowNodeInstance> getFailedFlowNodes() throws SearchException { SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 3); builder.filter(FlowNodeInstanceSearchDescriptor.STATE_NAME, ActivityStates.FAILED_STATE); SearchResult<FlowNodeInstance> searchResult = getProcessAPI().searchFlowNodeInstances(builder.done()); return searchResult.getResult(); }
/* * 1 receiveProcess, no message sent * dynamic -> deployAndEnable(receiveProcess), startProcess(receiveProcess) * checks : receiveProcess wait on receive task and don't and halt on the user task. */ @SuppressWarnings("unchecked") @Cover( classes = {EventInstance.class, ReceiveTaskInstance.class}, concept = BPMNConcept.EVENTS, keywords = {"Event", "Message event", "Receive task", "Send", "Receive"}, jira = "") @Test public void noMessageSentSoReceiveProcessIsWaiting() throws Exception { final ProcessDefinition receiveMessageProcess = deployAndEnableProcessWithReceivedTask( "receiveMessageProcess", "waitForMessage", "userTask1", "delivery", user, "m1", null, null, null); final ProcessInstance receiveMessageProcessInstance = getProcessAPI().startProcess(receiveMessageProcess.getId()); waitForFlowNodeInState( receiveMessageProcessInstance, "waitForMessage", TestStates.WAITING, true); // we check after that that the waiting event is still here forceMatchingOfEvents(); final SearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(0, 10); searchOptionsBuilder.filter( WaitingEventSearchDescriptor.ROOT_PROCESS_INSTANCE_ID, receiveMessageProcessInstance.getId()); final Map<String, Serializable> parameters = new HashMap<String, Serializable>(1); parameters.put(SEARCH_OPTIONS_KEY, searchOptionsBuilder.done()); final SearchResult<WaitingEvent> searchResult = (SearchResult<WaitingEvent>) getCommandAPI().execute(SEARCH_WAITING_EVENTS_COMMAND, parameters); assertEquals(1, searchResult.getCount()); disableAndDeleteProcess(receiveMessageProcess); }
/** * Search and get next human task * * @param apiSession * @return * @throws Exception */ public TestHumanTask getNextHumanTask(final APISession apiSession) { final ProcessAPI processAPI = TestProcess.getProcessAPI(apiSession); final SearchOptionsBuilder searchOptBuilder = new SearchOptionsBuilder(0, 1); searchOptBuilder.filter( HumanTaskInstanceSearchDescriptor.STATE_NAME, ActivityStates.READY_STATE); /** Get next workable human task. (e.g not in initialization state) */ HumanTaskInstance humanTask = null; SearchResult<HumanTaskInstance> result = null; for (int i = 0; i < GET_NEXT_NB_ATTEMPT; i++) { try { result = processAPI.searchHumanTaskInstances(searchOptBuilder.done()); if (!result.getResult().isEmpty()) { humanTask = result.getResult().get(0); break; } Thread.sleep(SLEEP_TIME_MS); } catch (final InvalidSessionException e) { throw new TestToolkitException("Can't search human task instances. Invalid session", e); } catch (final SearchException e) { throw new TestToolkitException("Can't search human task instances", e); } catch (final InterruptedException e) { throw new TestToolkitException("Interrupted during searching process", e); } } if (humanTask != null) { return new TestHumanTask(humanTask); } else { if (result != null && result.getResult().size() > 0) { throw new NextActivityIsNotAllowedStateException(result.getResult().get(0)); } else { throw new NoActivityLeftException(); } } }
/* * dynamic -> deployAndEnable(receiveProcess), startProcess(receiveProcess), cancelProcessInstance(receiveProcess) * checks : receiveProcess wait on receive task, 1 waiting event, receiveProcess is cancelled, receiveProcess is archived, no more waiting event */ @SuppressWarnings("unchecked") @Cover( classes = {EventInstance.class, ReceiveTaskInstance.class}, concept = BPMNConcept.EVENTS, keywords = {"Event", "Message event", "Receive task", "Send", "Receive"}, jira = "") @Test public void cancelInstanceShouldDeleteWaitingEvents() throws Exception { final ProcessDefinition receiveMessageProcess = deployAndEnableProcessWithReceivedTask( "receiveMessageProcess", "waitForMessage", "userTask1", "delivery", user, "m1", null, null, null); final ProcessInstance receiveMessageProcessInstance = getProcessAPI().startProcess(receiveMessageProcess.getId()); waitForFlowNodeInState( receiveMessageProcessInstance, "waitForMessage", TestStates.WAITING, true); SearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(0, 10); searchOptionsBuilder.filter( WaitingEventSearchDescriptor.ROOT_PROCESS_INSTANCE_ID, receiveMessageProcessInstance.getId()); final Map<String, Serializable> parameters = new HashMap<String, Serializable>(1); parameters.put(SEARCH_OPTIONS_KEY, searchOptionsBuilder.done()); SearchResult<WaitingEvent> searchResult = (SearchResult<WaitingEvent>) getCommandAPI().execute(SEARCH_WAITING_EVENTS_COMMAND, parameters); assertEquals(1, searchResult.getCount()); getProcessAPI().cancelProcessInstance(receiveMessageProcessInstance.getId()); waitForProcessToBeInState(receiveMessageProcessInstance, ProcessInstanceState.CANCELLED); searchOptionsBuilder = new SearchOptionsBuilder(0, 10); searchOptionsBuilder.filter( ArchivedActivityInstanceSearchDescriptor.ROOT_PROCESS_INSTANCE_ID, receiveMessageProcessInstance.getId()); searchOptionsBuilder.filter( ArchivedActivityInstanceSearchDescriptor.ACTIVITY_TYPE, FlowNodeType.RECEIVE_TASK); final SearchResult<ArchivedActivityInstance> archivedActivityInstancesSearch = getProcessAPI().searchArchivedActivities(searchOptionsBuilder.done()); assertEquals(1, archivedActivityInstancesSearch.getCount()); assertTrue( archivedActivityInstancesSearch.getResult().get(0) instanceof ArchivedReceiveTaskInstance); assertEquals( TestStates.CANCELLED.getStateName(), archivedActivityInstancesSearch.getResult().get(0).getState()); searchResult = (SearchResult<WaitingEvent>) getCommandAPI().execute(SEARCH_WAITING_EVENTS_COMMAND, parameters); assertEquals(0, searchResult.getCount()); disableAndDeleteProcess(receiveMessageProcess); }