@Test public void testForEndWorkflow() throws Exception { final State expectedState = new State(); expectedState.setId(119L); expectedState.setComments("Workflow Terminated"); final RequestInfo requestInfo = RequestInfo.builder().userInfo(getUserInfo()).build(); final Role role = Role.builder().name("citizen").id(1l).description("CITIZEN").build(); final User user = User.builder().id(67L).roles(Collections.singleton(role)).build(); final UserResponse expectedUserRequest = UserResponse.builder().responseInfo(new ResponseInfo()) .user(Collections.singletonList(user)).build(); final ProcessInstance expectedProcessInstance = ProcessInstance.builder().requestInfo(requestInfo) .type("Complaint").description("Workflow Terminated").assignee(2L) .values(new HashMap<String, Attribute>()).businessKey("765").build(); expectedProcessInstance.setStateId(119L); when(stateService.getStateByIdAndTenantId(119L,TENANT_ID)).thenReturn(expectedState); when(userRepository.findUserByIdAndTenantId(16L,TENANT_ID)).thenReturn(expectedUserRequest); workflow.end(TENANT_ID, expectedProcessInstance); }
@Override public ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance) { final Long stateId = Long.valueOf(processInstance.getValueForKey(STATE_ID)); final State state = stateService.getStateByIdAndTenantId(stateId, jurisdiction); if (Objects.nonNull(state)) { state.addStateHistory(new StateHistory(state)); state.setStatus(State.StateStatus.ENDED); state.setValue(processInstance.getStatus()); state.setComments(processInstance.getComments()); state.setSenderName(processInstance.getSenderName()); state.setDateInfo(processInstance.getCreatedDate()); state.setTenantId(jurisdiction); UserResponse user = userRepository .findUserByIdAndTenantId(Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId()), jurisdiction); if (user.isGrievanceOfficer()) { state.setOwnerPosition(state.getOwnerPosition()); } setAuditableFields(state, Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId())); stateService.update(state); processInstance.setStateId(state.getId()); processInstance.setAssignee(state.getOwnerPosition()); } return processInstance; }
PgrWorkflow implements Workflow { @Override public ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance) { final Long stateId = Long.valueOf(processInstance.getValueForKey(STATE_ID)); final State state = stateService.getStateByIdAndTenantId(stateId, jurisdiction); if (Objects.nonNull(state)) { state.addStateHistory(new StateHistory(state)); state.setStatus(State.StateStatus.ENDED); state.setValue(processInstance.getStatus()); state.setComments(processInstance.getComments()); state.setSenderName(processInstance.getSenderName()); state.setDateInfo(processInstance.getCreatedDate()); state.setTenantId(jurisdiction); UserResponse user = userRepository .findUserByIdAndTenantId(Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId()), jurisdiction); if (user.isGrievanceOfficer()) { state.setOwnerPosition(state.getOwnerPosition()); } setAuditableFields(state, Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId())); stateService.update(state); processInstance.setStateId(state.getId()); processInstance.setAssignee(state.getOwnerPosition()); } return processInstance; } }
PgrWorkflow implements Workflow { @Override public ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance) { final Long stateId = Long.valueOf(processInstance.getValueForKey(STATE_ID)); final State state = stateService.getStateByIdAndTenantId(stateId, jurisdiction); if (Objects.nonNull(state)) { state.addStateHistory(new StateHistory(state)); state.setStatus(State.StateStatus.ENDED); state.setValue(processInstance.getStatus()); state.setComments(processInstance.getComments()); state.setSenderName(processInstance.getSenderName()); state.setDateInfo(processInstance.getCreatedDate()); state.setTenantId(jurisdiction); UserResponse user = userRepository .findUserByIdAndTenantId(Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId()), jurisdiction); if (user.isGrievanceOfficer()) { state.setOwnerPosition(state.getOwnerPosition()); } setAuditableFields(state, Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId())); stateService.update(state); processInstance.setStateId(state.getId()); processInstance.setAssignee(state.getOwnerPosition()); } return processInstance; } @Autowired  PgrWorkflow(final ComplaintRouterService complaintRouterService, final StateService stateService,
                       final EmployeeRepository employeeRepository, final UserRepository userRepository, final DepartmentRestRepository departmentRestRepository); }
PgrWorkflow implements Workflow { @Override public ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance) { final Long stateId = Long.valueOf(processInstance.getValueForKey(STATE_ID)); final State state = stateService.getStateByIdAndTenantId(stateId, jurisdiction); if (Objects.nonNull(state)) { state.addStateHistory(new StateHistory(state)); state.setStatus(State.StateStatus.ENDED); state.setValue(processInstance.getStatus()); state.setComments(processInstance.getComments()); state.setSenderName(processInstance.getSenderName()); state.setDateInfo(processInstance.getCreatedDate()); state.setTenantId(jurisdiction); UserResponse user = userRepository .findUserByIdAndTenantId(Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId()), jurisdiction); if (user.isGrievanceOfficer()) { state.setOwnerPosition(state.getOwnerPosition()); } setAuditableFields(state, Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId())); stateService.update(state); processInstance.setStateId(state.getId()); processInstance.setAssignee(state.getOwnerPosition()); } return processInstance; } @Autowired  PgrWorkflow(final ComplaintRouterService complaintRouterService, final StateService stateService,
                       final EmployeeRepository employeeRepository, final UserRepository userRepository, final DepartmentRestRepository departmentRestRepository); @Override ProcessInstance start(final String jurisdiction, final ProcessInstance processInstance); @Override ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance); @Override PositionResponse getAssignee(final Long boundaryId, final String complaintTypeCode, final Long assigneeId, final String tenantId); @Override List<Task> getHistoryDetail(final String tenantId, final String workflowId); @Override Task update(final String tenantId, final Task task); }
PgrWorkflow implements Workflow { @Override public ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance) { final Long stateId = Long.valueOf(processInstance.getValueForKey(STATE_ID)); final State state = stateService.getStateByIdAndTenantId(stateId, jurisdiction); if (Objects.nonNull(state)) { state.addStateHistory(new StateHistory(state)); state.setStatus(State.StateStatus.ENDED); state.setValue(processInstance.getStatus()); state.setComments(processInstance.getComments()); state.setSenderName(processInstance.getSenderName()); state.setDateInfo(processInstance.getCreatedDate()); state.setTenantId(jurisdiction); UserResponse user = userRepository .findUserByIdAndTenantId(Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId()), jurisdiction); if (user.isGrievanceOfficer()) { state.setOwnerPosition(state.getOwnerPosition()); } setAuditableFields(state, Long.valueOf(processInstance.getRequestInfo().getUserInfo().getId())); stateService.update(state); processInstance.setStateId(state.getId()); processInstance.setAssignee(state.getOwnerPosition()); } return processInstance; } @Autowired  PgrWorkflow(final ComplaintRouterService complaintRouterService, final StateService stateService,
                       final EmployeeRepository employeeRepository, final UserRepository userRepository, final DepartmentRestRepository departmentRestRepository); @Override ProcessInstance start(final String jurisdiction, final ProcessInstance processInstance); @Override ProcessInstance end(final String jurisdiction, final ProcessInstance processInstance); @Override PositionResponse getAssignee(final Long boundaryId, final String complaintTypeCode, final Long assigneeId, final String tenantId); @Override List<Task> getHistoryDetail(final String tenantId, final String workflowId); @Override Task update(final String tenantId, final Task task); static final String STATE_ID; static final String DEPARTMENT; static final String ESCALATED; static final String COMPLAINT; static final String SYSTEM_KEYWORD; static final String DELIVERABLE_SERVICE; static final String STATE_DETAILS; }