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