@Test public void testGetCategory() { ResponseInfo responseInfo = new ResponseInfo("emp", "1.0", "2017-01-18T07:18:23.130Z", "uief87324", "20170310130900", "200"); Category category = new Category().builder().id(100L).name("employee1").tenantId("1").build(); List<Category> categories = new ArrayList<>(); categories.add(category); CategoryResponse categoryResponse = new CategoryResponse().builder().responseInfo(responseInfo) .category(categories).build(); when(propertiesManager.getEgovCommonMastersServiceHost()).thenReturn("http: when(propertiesManager.getEgovCommonMastersServiceBasepath()).thenReturn("/egov-common-masters"); when(propertiesManager.getEgovCommonMastersServiceCategorySearchPath()).thenReturn("/categories/_search"); RequestInfoWrapper requestInfoWrapper = new RequestInfoWrapper(); URI uri = null; try { uri = new URI( "http: } catch (URISyntaxException e) { e.printStackTrace(); } when(restTemplate.postForObject(uri, getRequestInfoAsHttpEntity(requestInfoWrapper), CategoryResponse.class)) .thenReturn(categoryResponse); Category insertedCategory = commonMasterService.getCategory(100L, "1", new RequestInfoWrapper()); assertEquals(insertedCategory, category); }
public Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; CategoryResponse categoryResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceCategorySearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); categoryResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), CategoryResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Category API : " + e.getMessage()); return null; } return categoryResponse.getCategory().get(0); }
CommonMasterService { public Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; CategoryResponse categoryResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceCategorySearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); categoryResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), CategoryResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Category API : " + e.getMessage()); return null; } return categoryResponse.getCategory().get(0); } }
CommonMasterService { public Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; CategoryResponse categoryResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceCategorySearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); categoryResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), CategoryResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Category API : " + e.getMessage()); return null; } return categoryResponse.getCategory().get(0); }  }
CommonMasterService { public Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; CategoryResponse categoryResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceCategorySearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); categoryResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), CategoryResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Category API : " + e.getMessage()); return null; } return categoryResponse.getCategory().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 Category getCategory(Long id, String tenantId, RequestInfoWrapper requestInfoWrapper) { URI url = null; CategoryResponse categoryResponse = null; try { url = new URI(propertiesManager.getEgovCommonMastersServiceHost() + propertiesManager.getEgovCommonMastersServiceBasepath() + propertiesManager.getEgovCommonMastersServiceCategorySearchPath() + "?id=" + id + "&tenantId=" + tenantId); LOGGER.debug(url.toString()); categoryResponse = restTemplate.postForObject(url, getRequestInfoAsHttpEntity(requestInfoWrapper), CategoryResponse.class); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Following exception occurred while accessing Category API : " + e.getMessage()); return null; } return categoryResponse.getCategory().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; }