@Test public void test_should_fetch_positions_of_employees(){ server.expect(once(), requestTo("http: .andExpect(method(HttpMethod.POST)) .andRespond(withSuccess(new Resources().getFileContents("positionResponse.json"), MediaType.APPLICATION_JSON_UTF8)); PositionResponse positionResponse = positionRestRepository.getPositions("1","ap.kurnool", new RequestInfoWrapper()); server.verify(); assertTrue(null != positionResponse); assertEquals(Long.valueOf(1l), positionResponse.getPosition().get(0).getId()); }
public PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper){ String positionUrl = hostName + searchPath.replace(pathVariable, allotteeId) + "?tenantId=" + tenantId; logger.info("the request url to position get call :: " + positionUrl); logger.info("the request body to position get call :: " + requestInfoWrapper); try { PositionResponse positionResponse = restTemplate.postForObject(positionUrl, requestInfoWrapper, PositionResponse.class); logger.info("the response form position get call :: " + positionResponse); return positionResponse; } catch (Exception e) { logger.info("the exception from poisition search :: " + e); throw e; } }
PositionRestRepository { public PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper){ String positionUrl = hostName + searchPath.replace(pathVariable, allotteeId) + "?tenantId=" + tenantId; logger.info("the request url to position get call :: " + positionUrl); logger.info("the request body to position get call :: " + requestInfoWrapper); try { PositionResponse positionResponse = restTemplate.postForObject(positionUrl, requestInfoWrapper, PositionResponse.class); logger.info("the response form position get call :: " + positionResponse); return positionResponse; } catch (Exception e) { logger.info("the exception from poisition search :: " + e); throw e; } } }
PositionRestRepository { public PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper){ String positionUrl = hostName + searchPath.replace(pathVariable, allotteeId) + "?tenantId=" + tenantId; logger.info("the request url to position get call :: " + positionUrl); logger.info("the request body to position get call :: " + requestInfoWrapper); try { PositionResponse positionResponse = restTemplate.postForObject(positionUrl, requestInfoWrapper, PositionResponse.class); logger.info("the response form position get call :: " + positionResponse); return positionResponse; } catch (Exception e) { logger.info("the exception from poisition search :: " + e); throw e; } } PositionRestRepository(RestTemplate restTemplate,
                                  @Value("${egov.services.employee_service.hostname}") String hostName,
                                  @Value("${egov.services.employee_service.searchpath}") String searchPath,
                                  @Value("${egov.services.employee_service.searchpath.pathvariable}") String pathVariable); }
PositionRestRepository { public PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper){ String positionUrl = hostName + searchPath.replace(pathVariable, allotteeId) + "?tenantId=" + tenantId; logger.info("the request url to position get call :: " + positionUrl); logger.info("the request body to position get call :: " + requestInfoWrapper); try { PositionResponse positionResponse = restTemplate.postForObject(positionUrl, requestInfoWrapper, PositionResponse.class); logger.info("the response form position get call :: " + positionResponse); return positionResponse; } catch (Exception e) { logger.info("the exception from poisition search :: " + e); throw e; } } PositionRestRepository(RestTemplate restTemplate,
                                  @Value("${egov.services.employee_service.hostname}") String hostName,
                                  @Value("${egov.services.employee_service.searchpath}") String searchPath,
                                  @Value("${egov.services.employee_service.searchpath.pathvariable}") String pathVariable); PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper); }
PositionRestRepository { public PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper){ String positionUrl = hostName + searchPath.replace(pathVariable, allotteeId) + "?tenantId=" + tenantId; logger.info("the request url to position get call :: " + positionUrl); logger.info("the request body to position get call :: " + requestInfoWrapper); try { PositionResponse positionResponse = restTemplate.postForObject(positionUrl, requestInfoWrapper, PositionResponse.class); logger.info("the response form position get call :: " + positionResponse); return positionResponse; } catch (Exception e) { logger.info("the exception from poisition search :: " + e); throw e; } } PositionRestRepository(RestTemplate restTemplate,
                                  @Value("${egov.services.employee_service.hostname}") String hostName,
                                  @Value("${egov.services.employee_service.searchpath}") String searchPath,
                                  @Value("${egov.services.employee_service.searchpath.pathvariable}") String pathVariable); PositionResponse getPositions(String allotteeId, String tenantId, RequestInfoWrapper requestInfoWrapper); static final Logger logger; }