@Test public void test_getVacantPositions() { Position position1 = new Position().builder().id(1L).active(true).tenantId("default").build(); Position position2 = new Position().builder().id(2L).active(true).tenantId("default").build(); List<Long> positionIds = new ArrayList<>(); positionIds.add(position1.getId()); positionIds.add(position2.getId()); List<Position> positions = new ArrayList<>(); positions.add(position1); positions.add(position2); ResponseInfo responseInfo = new ResponseInfo("emp", "1.0", "2017-01-18T07:18:23.130Z", "uief87324", "20170310130900", "200"); NonVacantPositionsResponse nonVacantPositionsResponse = new NonVacantPositionsResponse().builder().positionIds(positionIds).responseInfo(responseInfo).build(); VacantPositionsGetRequest criteria = new VacantPositionsGetRequest().builder().id(positionIds).asOnDate(new Date()).departmentId(10L).designationId(15L).tenantId("default").destinationTenant("").build(); RequestInfo requestInfo = new RequestInfo().builder().apiId("emp").build(); RequestInfoWrapper requestInfoWrapper = new RequestInfoWrapper().builder().requestInfo(requestInfo).build(); when(restTemplate.postForObject(any(String.class), any(RequestInfoWrapper.class), Matchers.any(Class.class))).thenReturn(nonVacantPositionsResponse); when(vacantPositionsRepository.findForCriteria(criteria)).thenReturn(positions); List<Position> result = vacantPositionsService.getVacantPositions(criteria, requestInfoWrapper); assertThat(result).isEqualTo(positions); }
public List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest, RequestInfoWrapper requestInfoWrapper) { String url = propertiesManager.getEmployeeServiceHostName() + propertiesManager.getEmployeeServiceNonVacantPositionsBasePath() + propertiesManager.getEmployeeServiceNonVacantPositionsSearchPath() + "?tenantId=" + vacantPositionsGetRequest.getTenantId() + "&departmentId=" + vacantPositionsGetRequest.getDepartmentId() + "&designationId=" + vacantPositionsGetRequest.getDesignationId() + "&asOnDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()); if(vacantPositionsGetRequest.getDestinationTenant() != null && !vacantPositionsGetRequest.getDestinationTenant().isEmpty()) { url = url + "&destinationTenant=" + vacantPositionsGetRequest.getDestinationTenant() + "&fromDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()) + "&toDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getToDate()); vacantPositionsGetRequest.setTenantId(vacantPositionsGetRequest.getDestinationTenant()); } System.err.println(url); NonVacantPositionsResponse nonVacantPositionsResponse = restTemplate.postForObject(url, requestInfoWrapper, NonVacantPositionsResponse.class); if (!nonVacantPositionsResponse.getPositionIds().isEmpty()) vacantPositionsGetRequest.setId(nonVacantPositionsResponse.getPositionIds()); return vacantPositionsRepository.findForCriteria(vacantPositionsGetRequest); }
VacantPositionsService { public List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest, RequestInfoWrapper requestInfoWrapper) { String url = propertiesManager.getEmployeeServiceHostName() + propertiesManager.getEmployeeServiceNonVacantPositionsBasePath() + propertiesManager.getEmployeeServiceNonVacantPositionsSearchPath() + "?tenantId=" + vacantPositionsGetRequest.getTenantId() + "&departmentId=" + vacantPositionsGetRequest.getDepartmentId() + "&designationId=" + vacantPositionsGetRequest.getDesignationId() + "&asOnDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()); if(vacantPositionsGetRequest.getDestinationTenant() != null && !vacantPositionsGetRequest.getDestinationTenant().isEmpty()) { url = url + "&destinationTenant=" + vacantPositionsGetRequest.getDestinationTenant() + "&fromDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()) + "&toDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getToDate()); vacantPositionsGetRequest.setTenantId(vacantPositionsGetRequest.getDestinationTenant()); } System.err.println(url); NonVacantPositionsResponse nonVacantPositionsResponse = restTemplate.postForObject(url, requestInfoWrapper, NonVacantPositionsResponse.class); if (!nonVacantPositionsResponse.getPositionIds().isEmpty()) vacantPositionsGetRequest.setId(nonVacantPositionsResponse.getPositionIds()); return vacantPositionsRepository.findForCriteria(vacantPositionsGetRequest); } }
VacantPositionsService { public List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest, RequestInfoWrapper requestInfoWrapper) { String url = propertiesManager.getEmployeeServiceHostName() + propertiesManager.getEmployeeServiceNonVacantPositionsBasePath() + propertiesManager.getEmployeeServiceNonVacantPositionsSearchPath() + "?tenantId=" + vacantPositionsGetRequest.getTenantId() + "&departmentId=" + vacantPositionsGetRequest.getDepartmentId() + "&designationId=" + vacantPositionsGetRequest.getDesignationId() + "&asOnDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()); if(vacantPositionsGetRequest.getDestinationTenant() != null && !vacantPositionsGetRequest.getDestinationTenant().isEmpty()) { url = url + "&destinationTenant=" + vacantPositionsGetRequest.getDestinationTenant() + "&fromDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()) + "&toDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getToDate()); vacantPositionsGetRequest.setTenantId(vacantPositionsGetRequest.getDestinationTenant()); } System.err.println(url); NonVacantPositionsResponse nonVacantPositionsResponse = restTemplate.postForObject(url, requestInfoWrapper, NonVacantPositionsResponse.class); if (!nonVacantPositionsResponse.getPositionIds().isEmpty()) vacantPositionsGetRequest.setId(nonVacantPositionsResponse.getPositionIds()); return vacantPositionsRepository.findForCriteria(vacantPositionsGetRequest); }  }
VacantPositionsService { public List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest, RequestInfoWrapper requestInfoWrapper) { String url = propertiesManager.getEmployeeServiceHostName() + propertiesManager.getEmployeeServiceNonVacantPositionsBasePath() + propertiesManager.getEmployeeServiceNonVacantPositionsSearchPath() + "?tenantId=" + vacantPositionsGetRequest.getTenantId() + "&departmentId=" + vacantPositionsGetRequest.getDepartmentId() + "&designationId=" + vacantPositionsGetRequest.getDesignationId() + "&asOnDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()); if(vacantPositionsGetRequest.getDestinationTenant() != null && !vacantPositionsGetRequest.getDestinationTenant().isEmpty()) { url = url + "&destinationTenant=" + vacantPositionsGetRequest.getDestinationTenant() + "&fromDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()) + "&toDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getToDate()); vacantPositionsGetRequest.setTenantId(vacantPositionsGetRequest.getDestinationTenant()); } System.err.println(url); NonVacantPositionsResponse nonVacantPositionsResponse = restTemplate.postForObject(url, requestInfoWrapper, NonVacantPositionsResponse.class); if (!nonVacantPositionsResponse.getPositionIds().isEmpty()) vacantPositionsGetRequest.setId(nonVacantPositionsResponse.getPositionIds()); return vacantPositionsRepository.findForCriteria(vacantPositionsGetRequest); }  List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest,
			RequestInfoWrapper requestInfoWrapper); }
VacantPositionsService { public List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest, RequestInfoWrapper requestInfoWrapper) { String url = propertiesManager.getEmployeeServiceHostName() + propertiesManager.getEmployeeServiceNonVacantPositionsBasePath() + propertiesManager.getEmployeeServiceNonVacantPositionsSearchPath() + "?tenantId=" + vacantPositionsGetRequest.getTenantId() + "&departmentId=" + vacantPositionsGetRequest.getDepartmentId() + "&designationId=" + vacantPositionsGetRequest.getDesignationId() + "&asOnDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()); if(vacantPositionsGetRequest.getDestinationTenant() != null && !vacantPositionsGetRequest.getDestinationTenant().isEmpty()) { url = url + "&destinationTenant=" + vacantPositionsGetRequest.getDestinationTenant() + "&fromDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getAsOnDate()) + "&toDate=" + new SimpleDateFormat("dd/MM/yyyy").format(vacantPositionsGetRequest.getToDate()); vacantPositionsGetRequest.setTenantId(vacantPositionsGetRequest.getDestinationTenant()); } System.err.println(url); NonVacantPositionsResponse nonVacantPositionsResponse = restTemplate.postForObject(url, requestInfoWrapper, NonVacantPositionsResponse.class); if (!nonVacantPositionsResponse.getPositionIds().isEmpty()) vacantPositionsGetRequest.setId(nonVacantPositionsResponse.getPositionIds()); return vacantPositionsRepository.findForCriteria(vacantPositionsGetRequest); }  List<Position> getVacantPositions(VacantPositionsGetRequest vacantPositionsGetRequest,
			RequestInfoWrapper requestInfoWrapper);  }