@Test public void test_should_return_department_by_id() { server.expect(once(), requestTo("http: .andExpect(method(HttpMethod.POST)) .andRespond(withSuccess(new Resources().getFileContents("departmentResponse.json"), MediaType.APPLICATION_JSON_UTF8)); final DepartmentRes departmentRes=departmentRestRepository.getDepartmentById(1L,"default"); server.verify(); assertEquals(1, departmentRes.getDepartment().size()); }
public DepartmentRes getDepartmentById(final Long departmentId, final String tenantId) { final RequestInfo requestInfo = RequestInfo.builder() .ts(new Date()) .build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(requestInfo).build(); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); }
DepartmentRepository { public DepartmentRes getDepartmentById(final Long departmentId, final String tenantId) { final RequestInfo requestInfo = RequestInfo.builder() .ts(new Date()) .build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(requestInfo).build(); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); } }
DepartmentRepository { public DepartmentRes getDepartmentById(final Long departmentId, final String tenantId) { final RequestInfo requestInfo = RequestInfo.builder() .ts(new Date()) .build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(requestInfo).build(); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); } @Autowired  DepartmentRepository(final RestTemplate restTemplate,
                                @Value("${egov.services.commonmasters.host}") final String departmentServiceHostname,
                                @Value("${egov.services.common_masters.department}") final String departmentByIdUrl); }
DepartmentRepository { public DepartmentRes getDepartmentById(final Long departmentId, final String tenantId) { final RequestInfo requestInfo = RequestInfo.builder() .ts(new Date()) .build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(requestInfo).build(); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); } @Autowired  DepartmentRepository(final RestTemplate restTemplate,
                                @Value("${egov.services.commonmasters.host}") final String departmentServiceHostname,
                                @Value("${egov.services.common_masters.department}") final String departmentByIdUrl); DepartmentRes getDepartmentById(final Long departmentId, final String tenantId); }
DepartmentRepository { public DepartmentRes getDepartmentById(final Long departmentId, final String tenantId) { final RequestInfo requestInfo = RequestInfo.builder() .ts(new Date()) .build(); RequestInfoWrapper wrapper = RequestInfoWrapper.builder().RequestInfo(requestInfo).build(); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); } @Autowired  DepartmentRepository(final RestTemplate restTemplate,
                                @Value("${egov.services.commonmasters.host}") final String departmentServiceHostname,
                                @Value("${egov.services.common_masters.department}") final String departmentByIdUrl); DepartmentRes getDepartmentById(final Long departmentId, final String tenantId);  }