@Test public void test_should_get_position_for_given_assignee() throws Exception { String tenantId = "default"; Long assigneeId = 1L; String expectedUrl = "http: server.expect(once(), requestTo(expectedUrl)).andExpect(method(HttpMethod.POST)) .andRespond(withSuccess(resources.getFileContents("positionResponse.json"), MediaType.APPLICATION_JSON_UTF8)); Position position = positionRepository.getDesignationIdForAssignee(tenantId, assigneeId); server.verify(); assertEquals(new Position("2", "2"), position); }
public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { final RequestInfo requestInfo = RequestInfo.builder().build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(requestInfo).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse positions = restTemplate.postForObject(url, request,PositionsResponse.class,assigneeId,tenantId); return positions.toDomain(); }
PositionRepository { public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { final RequestInfo requestInfo = RequestInfo.builder().build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(requestInfo).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse positions = restTemplate.postForObject(url, request,PositionsResponse.class,assigneeId,tenantId); return positions.toDomain(); } }
PositionRepository { public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { final RequestInfo requestInfo = RequestInfo.builder().build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(requestInfo).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse positions = restTemplate.postForObject(url, request,PositionsResponse.class,assigneeId,tenantId); return positions.toDomain(); } PositionRepository(RestTemplate restTemplate,
                              @Value("${egov.services.position.host}") String host,
                              @Value("${egov.services.position.designation}") String endpointUrl); }
PositionRepository { public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { final RequestInfo requestInfo = RequestInfo.builder().build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(requestInfo).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse positions = restTemplate.postForObject(url, request,PositionsResponse.class,assigneeId,tenantId); return positions.toDomain(); } PositionRepository(RestTemplate restTemplate,
                              @Value("${egov.services.position.host}") String host,
                              @Value("${egov.services.position.designation}") String endpointUrl); Position getDesignationIdForAssignee(String tenantId, long assigneeId); }
PositionRepository { public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { final RequestInfo requestInfo = RequestInfo.builder().build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(requestInfo).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse positions = restTemplate.postForObject(url, request,PositionsResponse.class,assigneeId,tenantId); return positions.toDomain(); } PositionRepository(RestTemplate restTemplate,
                              @Value("${egov.services.position.host}") String host,
                              @Value("${egov.services.position.designation}") String endpointUrl); Position getDesignationIdForAssignee(String tenantId, long assigneeId);  }