@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) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(RequestInfo.builder().apiId("apiId").ver("ver").ts(new Date()).build()).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse response = restTemplate .postForObject(this.url, request,PositionsResponse.class, tenantId, assigneeId); return response.toDomain(); }
PositionRepository { public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(RequestInfo.builder().apiId("apiId").ver("ver").ts(new Date()).build()).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse response = restTemplate .postForObject(this.url, request,PositionsResponse.class, tenantId, assigneeId); return response.toDomain(); } }
PositionRepository { public Position getDesignationIdForAssignee(String tenantId, long assigneeId) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(RequestInfo.builder().apiId("apiId").ver("ver").ts(new Date()).build()).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse response = restTemplate .postForObject(this.url, request,PositionsResponse.class, tenantId, assigneeId); return response.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) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(RequestInfo.builder().apiId("apiId").ver("ver").ts(new Date()).build()).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse response = restTemplate .postForObject(this.url, request,PositionsResponse.class, tenantId, assigneeId); return response.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) { RequestInfoWrapper wrapper = RequestInfoWrapper.builder().requestInfo(RequestInfo.builder().apiId("apiId").ver("ver").ts(new Date()).build()).build(); final HttpEntity<RequestInfoWrapper> request = new HttpEntity<>(wrapper); PositionsResponse response = restTemplate .postForObject(this.url, request,PositionsResponse.class, tenantId, assigneeId); return response.toDomain(); } PositionRepository(RestTemplate restTemplate,
                              @Value("${egov.services.position.host}") String host,
                              @Value("${egov.services.position.designation}") String endpointUrl); Position getDesignationIdForAssignee(String tenantId, long assigneeId);  }