@Test public void test_get_by_id() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Kolkata")); final Date now = new SimpleDateFormat("dd/MM/yyyy").parse("01/01/2017 00:00:00"); server.expect(once(), requestTo("http: .andExpect(content().string(resources.getFileContents("department/search_dept_by_id_request.json"))) .andRespond(withSuccess(resources.getFileContents("department/search_dept_by_id.json"), MediaType.APPLICATION_JSON_UTF8)); when(dateFactory.create()).thenReturn(now); final DepartmentRes response = departmentRepository.getDepartmentById("departmentId", "tenantId"); server.verify(); assertEquals(1, response.getDepartment().size()); }
public DepartmentRes getDepartmentById(final String departmentId, final String tenantId) { final RequestInfo requestInfo = new RequestInfo(); requestInfo.setTs(dateFactory.create()); final RequestInfoWrapper wrapper = new RequestInfoWrapper(); wrapper.setRequestInfo(requestInfo); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); }
DepartmentRepository { public DepartmentRes getDepartmentById(final String departmentId, final String tenantId) { final RequestInfo requestInfo = new RequestInfo(); requestInfo.setTs(dateFactory.create()); final RequestInfoWrapper wrapper = new RequestInfoWrapper(); wrapper.setRequestInfo(requestInfo); return restTemplate.postForObject(departmentByIdUrl, wrapper, DepartmentRes.class, departmentId, tenantId); } }
DepartmentRepository { public DepartmentRes getDepartmentById(final String departmentId, final String tenantId) { final RequestInfo requestInfo = new RequestInfo(); requestInfo.setTs(dateFactory.create()); final RequestInfoWrapper wrapper = new RequestInfoWrapper(); wrapper.setRequestInfo(requestInfo); 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, final DateFactory dateFactory); }
DepartmentRepository { public DepartmentRes getDepartmentById(final String departmentId, final String tenantId) { final RequestInfo requestInfo = new RequestInfo(); requestInfo.setTs(dateFactory.create()); final RequestInfoWrapper wrapper = new RequestInfoWrapper(); wrapper.setRequestInfo(requestInfo); 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, final DateFactory dateFactory); DepartmentRes getDepartmentById(final String departmentId, final String tenantId); }
DepartmentRepository { public DepartmentRes getDepartmentById(final String departmentId, final String tenantId) { final RequestInfo requestInfo = new RequestInfo(); requestInfo.setTs(dateFactory.create()); final RequestInfoWrapper wrapper = new RequestInfoWrapper(); wrapper.setRequestInfo(requestInfo); 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, final DateFactory dateFactory); DepartmentRes getDepartmentById(final String departmentId, final String tenantId);  }