@Test public void testGetDepartment() { ResponseInfo responseInfo = new ResponseInfo("emp", "1.0", "2017-01-18T07:18:23.130Z", "uief87324", "20170310130900", "200"); Department department = new Department().builder().id(100L).name("employee1").tenantId("1").build(); List<Department> departments = new ArrayList<>(); departments.add(department); DepartmentResponse departmentResponse = new DepartmentResponse().builder().responseInfo(responseInfo) .department(departments).build(); when(propertiesManager.getEgovCommonMastersServiceHost()).thenReturn("http: when(propertiesManager.getEgovCommonMastersServiceBasepath()).thenReturn("/egov-common-masters"); when(propertiesManager.getEgovCommonMastersServiceDepartmentSearchPath()).thenReturn("/departments/_search"); RequestInfoWrapper requestInfoWrapper = new RequestInfoWrapper(); URI uri = null; try { uri = new URI( "http: } catch (URISyntaxException e) { e.printStackTrace(); } when(restTemplate.postForObject(uri, getRequestInfoAsHttpEntity(requestInfoWrapper), DepartmentResponse.class)) .thenReturn(departmentResponse); Department insertedDepartment = commonMasterService.getDepartment(100L, "1", new RequestInfoWrapper()); assertEquals(insertedDepartment, department); }
public Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; DepartmentResponse departmentResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceDepartmentSearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); departmentResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), DepartmentResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Department API : " + e.getMessage()); return null; } return departmentResponse.getDepartment().get(0); }
CommonMasterService { public Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; DepartmentResponse departmentResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceDepartmentSearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); departmentResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), DepartmentResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Department API : " + e.getMessage()); return null; } return departmentResponse.getDepartment().get(0); } }
CommonMasterService { public Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; DepartmentResponse departmentResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceDepartmentSearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); departmentResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), DepartmentResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Department API : " + e.getMessage()); return null; } return departmentResponse.getDepartment().get(0); }  }
CommonMasterService { public Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; DepartmentResponse departmentResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceDepartmentSearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); departmentResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), DepartmentResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Department API : " + e.getMessage()); return null; } return departmentResponse.getDepartment().get(0); }  Religion getReligion(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); List<Language> getLanguages(List<Long> ids, String tenantId, RequestInfoWrapper requestInfoWrapper); Community getCommunity(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); }
CommonMasterService { public Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; DepartmentResponse departmentResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceDepartmentSearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); departmentResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), DepartmentResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Department API : " + e.getMessage()); return null; } return departmentResponse.getDepartment().get(0); }  Religion getReligion(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); List<Language> getLanguages(List<Long> ids, String tenantId, RequestInfoWrapper requestInfoWrapper); Community getCommunity(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); Department getDepartment(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper); static final Logger LOGGER; }