@Test public void test_movement_repository_should_save_movement() { Movement movement1 = new Movement(); movement1.setId(1L); movement1.setEmployeeId(1L); movement1.setTypeOfMovement(TypeOfMovement.PROMOTION); movement1.setTransferType(TransferType.TRANSFER_WITHIN_DEPARTMENT_OR_CORPORATION_OR_ULB); PromotionBasis promotionBasis = new PromotionBasis(); promotionBasis.setId(1L); TransferReason transferReason = new TransferReason(); transferReason.setId(1L); movement1.setPromotionBasis(promotionBasis); movement1.setReason(transferReason); movements = new ArrayList<>(); movements.add(movement1); final MovementRequest movementRequest = new MovementRequest(); movementRequest.setMovement(movements); movementRequest.setRequestInfo(requestInfo); users = new ArrayList<>(); User user = new User(); user.setId(1L); users.add(user); userResponse = new UserResponse(responseInfo, users); final ProcessInstance processInstance = new ProcessInstance(); processInstance.setId("1"); when(workFlowService.start(Mockito.any(MovementRequest.class))).thenReturn(processInstance); when(userService.findUserByUserNameAndTenantId(Mockito.any(RequestInfo.class))).thenReturn(userResponse); when(jdbcTemplate.update(Mockito.anyString(), Mockito.any(Object[].class))).thenReturn(0); MovementRequest result = movementRepository.saveMovement(movementRequest); assertEquals(result.getMovement().size(), movementRequest.getMovement().size()); }
public MovementRequest saveMovement(final MovementRequest movementRequest) { ProcessInstance processInstance = new ProcessInstance(); Long stateId = null; if (StringUtils.isEmpty(movementRequest.getType())) processInstance = workFlowService.start(movementRequest); if (processInstance.getId() != null) stateId = Long.valueOf(processInstance.getId()); final Date now = new Date(); final UserResponse userResponse = userService.findUserByUserNameAndTenantId(movementRequest.getRequestInfo()); for (final Movement movement : movementRequest.getMovement()) { movement.setStateId(stateId); final Object[] obj = new Object[]{movement.getId(), movement.getEmployeeId(), movement.getTypeOfMovement().toString(), movement.getCurrentAssignment(), movement.getTransferType().toString(), movement.getPromotionBasis().getId(), movement.getRemarks(), movement.getReason().getId(), movement.getEffectiveFrom(), movement.getEnquiryPassedDate(), movement.getTransferedLocation(), movement.getDepartmentAssigned(), movement.getDesignationAssigned(), movement.getPositionAssigned(), movement.getFundAssigned(), movement.getFunctionAssigned(), movement.getEmployeeAcceptance(), movement.getStatus(), movement.getStateId(), userResponse.getUsers().get(0).getId(), now, userResponse.getUsers().get(0).getId(), now, movement.getTenantId()}; if (movement.getDocuments() != null && !movement.getDocuments().isEmpty()) documentsRepository.save(movement.getId(), movement.getDocuments(), movement.getTenantId()); jdbcTemplate.update(MovementQueryBuilder.insertMovementQuery(), obj); } return movementRequest; }
MovementRepository { public MovementRequest saveMovement(final MovementRequest movementRequest) { ProcessInstance processInstance = new ProcessInstance(); Long stateId = null; if (StringUtils.isEmpty(movementRequest.getType())) processInstance = workFlowService.start(movementRequest); if (processInstance.getId() != null) stateId = Long.valueOf(processInstance.getId()); final Date now = new Date(); final UserResponse userResponse = userService.findUserByUserNameAndTenantId(movementRequest.getRequestInfo()); for (final Movement movement : movementRequest.getMovement()) { movement.setStateId(stateId); final Object[] obj = new Object[]{movement.getId(), movement.getEmployeeId(), movement.getTypeOfMovement().toString(), movement.getCurrentAssignment(), movement.getTransferType().toString(), movement.getPromotionBasis().getId(), movement.getRemarks(), movement.getReason().getId(), movement.getEffectiveFrom(), movement.getEnquiryPassedDate(), movement.getTransferedLocation(), movement.getDepartmentAssigned(), movement.getDesignationAssigned(), movement.getPositionAssigned(), movement.getFundAssigned(), movement.getFunctionAssigned(), movement.getEmployeeAcceptance(), movement.getStatus(), movement.getStateId(), userResponse.getUsers().get(0).getId(), now, userResponse.getUsers().get(0).getId(), now, movement.getTenantId()}; if (movement.getDocuments() != null && !movement.getDocuments().isEmpty()) documentsRepository.save(movement.getId(), movement.getDocuments(), movement.getTenantId()); jdbcTemplate.update(MovementQueryBuilder.insertMovementQuery(), obj); } return movementRequest; } }
MovementRepository { public MovementRequest saveMovement(final MovementRequest movementRequest) { ProcessInstance processInstance = new ProcessInstance(); Long stateId = null; if (StringUtils.isEmpty(movementRequest.getType())) processInstance = workFlowService.start(movementRequest); if (processInstance.getId() != null) stateId = Long.valueOf(processInstance.getId()); final Date now = new Date(); final UserResponse userResponse = userService.findUserByUserNameAndTenantId(movementRequest.getRequestInfo()); for (final Movement movement : movementRequest.getMovement()) { movement.setStateId(stateId); final Object[] obj = new Object[]{movement.getId(), movement.getEmployeeId(), movement.getTypeOfMovement().toString(), movement.getCurrentAssignment(), movement.getTransferType().toString(), movement.getPromotionBasis().getId(), movement.getRemarks(), movement.getReason().getId(), movement.getEffectiveFrom(), movement.getEnquiryPassedDate(), movement.getTransferedLocation(), movement.getDepartmentAssigned(), movement.getDesignationAssigned(), movement.getPositionAssigned(), movement.getFundAssigned(), movement.getFunctionAssigned(), movement.getEmployeeAcceptance(), movement.getStatus(), movement.getStateId(), userResponse.getUsers().get(0).getId(), now, userResponse.getUsers().get(0).getId(), now, movement.getTenantId()}; if (movement.getDocuments() != null && !movement.getDocuments().isEmpty()) documentsRepository.save(movement.getId(), movement.getDocuments(), movement.getTenantId()); jdbcTemplate.update(MovementQueryBuilder.insertMovementQuery(), obj); } return movementRequest; }  }
MovementRepository { public MovementRequest saveMovement(final MovementRequest movementRequest) { ProcessInstance processInstance = new ProcessInstance(); Long stateId = null; if (StringUtils.isEmpty(movementRequest.getType())) processInstance = workFlowService.start(movementRequest); if (processInstance.getId() != null) stateId = Long.valueOf(processInstance.getId()); final Date now = new Date(); final UserResponse userResponse = userService.findUserByUserNameAndTenantId(movementRequest.getRequestInfo()); for (final Movement movement : movementRequest.getMovement()) { movement.setStateId(stateId); final Object[] obj = new Object[]{movement.getId(), movement.getEmployeeId(), movement.getTypeOfMovement().toString(), movement.getCurrentAssignment(), movement.getTransferType().toString(), movement.getPromotionBasis().getId(), movement.getRemarks(), movement.getReason().getId(), movement.getEffectiveFrom(), movement.getEnquiryPassedDate(), movement.getTransferedLocation(), movement.getDepartmentAssigned(), movement.getDesignationAssigned(), movement.getPositionAssigned(), movement.getFundAssigned(), movement.getFunctionAssigned(), movement.getEmployeeAcceptance(), movement.getStatus(), movement.getStateId(), userResponse.getUsers().get(0).getId(), now, userResponse.getUsers().get(0).getId(), now, movement.getTenantId()}; if (movement.getDocuments() != null && !movement.getDocuments().isEmpty()) documentsRepository.save(movement.getId(), movement.getDocuments(), movement.getTenantId()); jdbcTemplate.update(MovementQueryBuilder.insertMovementQuery(), obj); } return movementRequest; }  List<Movement> findForCriteria(final MovementSearchRequest movementSearchRequest,
                                          final RequestInfo requestInfo); MovementRequest saveMovement(final MovementRequest movementRequest); Movement updateMovement(final MovementRequest movementRequest); List<Movement> findForExistingMovement(final Movement movement, final RequestInfo requestInfo); Long generateSequence(); }
MovementRepository { public MovementRequest saveMovement(final MovementRequest movementRequest) { ProcessInstance processInstance = new ProcessInstance(); Long stateId = null; if (StringUtils.isEmpty(movementRequest.getType())) processInstance = workFlowService.start(movementRequest); if (processInstance.getId() != null) stateId = Long.valueOf(processInstance.getId()); final Date now = new Date(); final UserResponse userResponse = userService.findUserByUserNameAndTenantId(movementRequest.getRequestInfo()); for (final Movement movement : movementRequest.getMovement()) { movement.setStateId(stateId); final Object[] obj = new Object[]{movement.getId(), movement.getEmployeeId(), movement.getTypeOfMovement().toString(), movement.getCurrentAssignment(), movement.getTransferType().toString(), movement.getPromotionBasis().getId(), movement.getRemarks(), movement.getReason().getId(), movement.getEffectiveFrom(), movement.getEnquiryPassedDate(), movement.getTransferedLocation(), movement.getDepartmentAssigned(), movement.getDesignationAssigned(), movement.getPositionAssigned(), movement.getFundAssigned(), movement.getFunctionAssigned(), movement.getEmployeeAcceptance(), movement.getStatus(), movement.getStateId(), userResponse.getUsers().get(0).getId(), now, userResponse.getUsers().get(0).getId(), now, movement.getTenantId()}; if (movement.getDocuments() != null && !movement.getDocuments().isEmpty()) documentsRepository.save(movement.getId(), movement.getDocuments(), movement.getTenantId()); jdbcTemplate.update(MovementQueryBuilder.insertMovementQuery(), obj); } return movementRequest; }  List<Movement> findForCriteria(final MovementSearchRequest movementSearchRequest,
                                          final RequestInfo requestInfo); MovementRequest saveMovement(final MovementRequest movementRequest); Movement updateMovement(final MovementRequest movementRequest); List<Movement> findForExistingMovement(final Movement movement, final RequestInfo requestInfo); Long generateSequence(); static final Logger LOGGER; }