@Test public void test_movement_service_should_return_movements() { Movement movement1 = new Movement(); Movement movement2 = new Movement(); workFlowDetails = new WorkFlowDetails(); movement1.setId(1L); movement1.setEmployeeId(1L); movement1.setTypeOfMovement(TypeOfMovement.PROMOTION); movement1.setWorkflowDetails(workFlowDetails); movement2.setId(2L); movement2.setEmployeeId(2L); movement2.setTypeOfMovement(TypeOfMovement.TRANSFER); movement2.setWorkflowDetails(workFlowDetails); movements = new ArrayList<>(); movements.add(movement1); movements.add(movement2); List<Document> documents = new ArrayList<>(); Document document = new Document(); document.setId(1L); document.setMovementId(1L); documents.add(document); when(movementRepository.findForCriteria(Mockito.any(MovementSearchRequest.class), Mockito.any(RequestInfo.class))) .thenReturn(movements); final MovementSearchRequest movementSearchRequest = new MovementSearchRequest(); final RequestInfo requestInfo = new RequestInfo(); when(documentsRepository.findByMovementId(Mockito.anyLong(), Mockito.anyString())) .thenReturn(documents); final List<Movement> response = movementService.getMovements(movementSearchRequest, requestInfo); assertEquals(movements.size(), response.size()); }
public List<Movement> getMovements(final MovementSearchRequest movementSearchRequest, final RequestInfo requestInfo) { List<Movement> movements = movementRepository.findForCriteria(movementSearchRequest, requestInfo); for (final Movement movement : movements) { final List<Document> documents = documentsRepository.findByMovementId(movement.getId(), movement.getTenantId()); for (final Document document : documents) movement.getDocuments().add(document.getDocument()); } return movements; }
MovementService { public List<Movement> getMovements(final MovementSearchRequest movementSearchRequest, final RequestInfo requestInfo) { List<Movement> movements = movementRepository.findForCriteria(movementSearchRequest, requestInfo); for (final Movement movement : movements) { final List<Document> documents = documentsRepository.findByMovementId(movement.getId(), movement.getTenantId()); for (final Document document : documents) movement.getDocuments().add(document.getDocument()); } return movements; } }
MovementService { public List<Movement> getMovements(final MovementSearchRequest movementSearchRequest, final RequestInfo requestInfo) { List<Movement> movements = movementRepository.findForCriteria(movementSearchRequest, requestInfo); for (final Movement movement : movements) { final List<Document> documents = documentsRepository.findByMovementId(movement.getId(), movement.getTenantId()); for (final Document document : documents) movement.getDocuments().add(document.getDocument()); } return movements; }  }
MovementService { public List<Movement> getMovements(final MovementSearchRequest movementSearchRequest, final RequestInfo requestInfo) { List<Movement> movements = movementRepository.findForCriteria(movementSearchRequest, requestInfo); for (final Movement movement : movements) { final List<Document> documents = documentsRepository.findByMovementId(movement.getId(), movement.getTenantId()); for (final Document document : documents) movement.getDocuments().add(document.getDocument()); } return movements; }  List<Movement> getMovements(final MovementSearchRequest movementSearchRequest,
									   final RequestInfo requestInfo); ResponseEntity<?> createMovements(final MovementRequest movementRequest, final String type); ResponseEntity<?> getSuccessResponseForCreate(final List<Movement> movementsList,
														  final RequestInfo requestInfo); MovementRequest create(final MovementRequest movementRequest); ResponseEntity<?> updateMovement(final MovementRequest movementRequest); Movement update(final MovementRequest movementRequest); Boolean checkEmployeeExists(final MovementRequest movementRequest); }
MovementService { public List<Movement> getMovements(final MovementSearchRequest movementSearchRequest, final RequestInfo requestInfo) { List<Movement> movements = movementRepository.findForCriteria(movementSearchRequest, requestInfo); for (final Movement movement : movements) { final List<Document> documents = documentsRepository.findByMovementId(movement.getId(), movement.getTenantId()); for (final Document document : documents) movement.getDocuments().add(document.getDocument()); } return movements; }  List<Movement> getMovements(final MovementSearchRequest movementSearchRequest,
									   final RequestInfo requestInfo); ResponseEntity<?> createMovements(final MovementRequest movementRequest, final String type); ResponseEntity<?> getSuccessResponseForCreate(final List<Movement> movementsList,
														  final RequestInfo requestInfo); MovementRequest create(final MovementRequest movementRequest); ResponseEntity<?> updateMovement(final MovementRequest movementRequest); Movement update(final MovementRequest movementRequest); Boolean checkEmployeeExists(final MovementRequest movementRequest); static final Logger LOGGER; }