RemoteCaseManagementServiceImpl implements CaseManagementService { public List<CaseActionSummary> getAdHocActions(String containerId, String caseId) { List<CaseActionSummary> adHocActions = getAdHocFragments(containerId, caseId); CaseInstanceSummary caseInstanceSummary = getCaseInstance(containerId, caseId); caseInstanceSummary.getStages().stream() .filter(s -> s.getStatus().equals(CaseStageStatus.ACTIVE.getStatus())) .forEach(ah -> { if (ah.getAdHocActions().size() > 0) { adHocActions.addAll(ah.getAdHocActions()); } return; }); return adHocActions; }  @Override List<CaseDefinitionSummary> getCaseDefinitions(); @Override CaseDefinitionSummary getCaseDefinition(final String containerId, final String caseDefinitionId); @Override List<CaseInstanceSummary> getCaseInstances(final CaseInstanceSearchRequest request); @Override String startCaseInstance(final String containerId,
                                    final String caseDefinitionId,
                                    final String owner,
                                    final List<CaseRoleAssignmentSummary> roleAssignments); @Override void cancelCaseInstance(final String containerId, final String caseId); @Override void closeCaseInstance(final String containerId, final String caseId, final String comment); @Override CaseInstanceSummary getCaseInstance(final String containerId, final String caseId); @Override void assignUserToRole(final String containerId,
                                 final String caseId,
                                 final String roleName,
                                 final String user); @Override void assignGroupToRole(final String containerId,
                                  final String caseId,
                                  final String roleName,
                                  final String group); @Override void removeUserFromRole(final String containerId,
                                   final String caseId,
                                   final String roleName,
                                   final String user); @Override void removeGroupFromRole(final String containerId,
                                    final String caseId,
                                    final String roleName,
                                    final String group); @Override List<CaseCommentSummary> getComments(final String containerId,
                                                final String caseId,
                                                final Integer page,
                                                final Integer pageSize); @Override void addComment(final String containerId,
                           final String caseId,
                           final String author,
                           final String text); @Override void updateComment(final String containerId,
                              final String caseId,
                              final String commentId,
                              final String author,
                              final String text); @Override void removeComment(final String containerId,
                              final String caseId,
                              final String commentId); @Override List<CaseMilestoneSummary> getCaseMilestones(final String containerId,
                                                        final String caseId,
                                                        final CaseMilestoneSearchRequest request); @Override List<CaseStageSummary> getCaseStages(final String containerId, final String caseId); @Override Actions getCaseActions(String container, String caseId, String userId); List<CaseActionSummary> getInProgressActions(String containerId,
                                                        String caseId); List<NodeInstance> getCaseCompletedNodes(String containerId, String caseId); List<CaseActionSummary> getCompletedActions(String containerId, String caseId); List<CaseActionSummary> getAdHocFragments(String containerId, String caseId); List<CaseActionSummary> getAdHocActions(String containerId, String caseId); void addDynamicUserTask(String containerId,
                                   String caseId,
                                   String name,
                                   String description,
                                   String actors,
                                   String groups,
                                   Map<String, Object> data); void addDynamicUserTaskToStage(String containerId,
                                          String caseId,
                                          String stageId,
                                          String name,
                                          String description,
                                          String actors,
                                          String groups,
                                          Map<String, Object> data); void addDynamicSubProcess(String containerId,
                                     String caseId,
                                     String processId,
                                     Map<String, Object> data); void addDynamicSubProcessToStage(String containerId,
                                            String caseId,
                                            String stageId,
                                            String processId,
                                            Map<String, Object> data); @Override void triggerAdHocActionInStage(String containerId,
                                          String caseId,
                                          String stageId,
                                          String adHocName,
                                          Map<String, Object> data); @Override void triggerAdHocAction(String containerId,
                                   String caseId,
                                   String adHocName,
                                   Map<String, Object> data); @Override List<ProcessDefinitionSummary> getProcessDefinitions(String containerId); static final int PAGE_SIZE_UNLIMITED; static final String CASE_OWNER_ROLE; }
@Test public void getAdHocActionsTest() { final CaseInstance ci = createTestInstance(caseId); CaseStage stage1 = createTestCaseStage("stage1", "stage1-name", CaseStageStatus.ACTIVE.getStatus()); CaseAdHocFragment cAHF1_stage1 = createTestCaseAdHocFragment("stage1-adHoc-1", "adHocFragment-type-1"); CaseAdHocFragment cAHF2_stage1 = createTestCaseAdHocFragment("stage1-adHoc-2", "adHocFragment-type-2"); CaseStage stage2 = createTestCaseStage("stage2", "stage2-name", CaseStageStatus.COMPLETED.getStatus()); CaseAdHocFragment cAHF1_stage2 = createTestCaseAdHocFragment("stage2-adHoc-1", "adHocFragment-type-1"); CaseAdHocFragment cAHF2_stage2 = createTestCaseAdHocFragment("stage2-adHoc-2", "adHocFragment-type-2"); stage1.setAdHocFragments(Arrays.asList(cAHF1_stage1, cAHF2_stage1)); stage2.setAdHocFragments(Arrays.asList(cAHF1_stage2, cAHF2_stage2)); ci.setStages(Arrays.asList(stage1, stage2)); when(clientMock.getCaseInstance(ci.getContainerId(), ci.getCaseId(), false, true, true, true)) .thenReturn(ci); CaseAdHocFragment cAHF1 = createTestCaseAdHocFragment("adHocFragment-name-1", "adHocFragment-type-1"); CaseAdHocFragment cAHF2 = createTestCaseAdHocFragment("adHocFragment-name-2", "adHocFragment-type-2"); when(clientMock.getAdHocFragments(containerId, caseId)).thenReturn(Arrays.asList(cAHF1, cAHF2)); List<CaseActionSummary> ahdocActions = testedService.getAdHocActions(containerId, caseId); assertEquals(4, ahdocActions.size()); assertCaseActionAdHocFragment(cAHF1, ahdocActions.get(0)); assertCaseActionAdHocFragment(cAHF2, ahdocActions.get(1)); assertCaseActionAdHocFragmentWithStage(cAHF1_stage1, ahdocActions.get(2)); assertCaseActionAdHocFragmentWithStage(cAHF2_stage1, ahdocActions.get(3)); verify(clientMock).getAdHocFragments(containerId, caseId); }