ConnectionManagerCache implements ConnectionManager { @Override public String getEndpointURLFromNhinTarget(NhinTargetSystemType targetSystem, String serviceName) throws ConnectionManagerException { String sEndpointURL = null; if (targetSystem != null) { if (targetSystem.getEpr() != null) { LOG.debug("Attempting to look up URL by EPR"); if (targetSystem.getEpr() != null && targetSystem.getEpr().getAddress() != null && NullChecker.isNotNullish(targetSystem.getEpr().getAddress().getValue())) { sEndpointURL = targetSystem.getEpr().getAddress().getValue(); } } else if (NullChecker.isNotNullish(targetSystem.getUrl())) { LOG.debug("Attempting to look up URL by URL"); sEndpointURL = targetSystem.getUrl(); } else if (targetSystem.getHomeCommunity() != null && NullChecker.isNotNullish(targetSystem.getHomeCommunity().getHomeCommunityId()) && NullChecker.isNotNullish(serviceName)) { String homeCommunityId = HomeCommunityMap .formatHomeCommunityId(targetSystem.getHomeCommunity().getHomeCommunityId()); final String userSpecVersion = targetSystem.getUseSpecVersion(); if (!StringUtils.isEmpty(userSpecVersion)) { final UDDI_SPEC_VERSION version = UDDI_SPEC_VERSION.fromString(userSpecVersion); LOG.debug( "Attempting to look up URL by home communinity id:{}, and service name: {}, and version {}", homeCommunityId, serviceName, version.toString()); sEndpointURL = getEndpointURLByServiceNameSpecVersion(homeCommunityId, serviceName, version); } else { LOG.debug("Retrieve endpoint from service Name {}", serviceName); sEndpointURL = getDefaultEndpointURLByServiceName(homeCommunityId, serviceName); } } } LOG.debug("Returning URL: {}", sEndpointURL); return sEndpointURL; } ConnectionManagerCache();  ConnectionManagerCache(PropertyAccessor accessor); static ConnectionManagerCache getInstance(); void setCommunityId(BusinessEntity businessEntity, String newId); void forceRefreshUDDICache(); void forceRefreshInternalConnectCache(); @Override List<BusinessEntity> getAllBusinessEntities(); @Override BusinessEntity getBusinessEntity(String sHomeCommunityId); @Override String getBusinessEntityName(String homeCommunityId); @Override Set<BusinessEntity> getBusinessEntitySet(List<String> saHomeCommunityId); @Override BusinessEntity getBusinessEntityByServiceName(String sHomeCommunityId, String sUniformServiceName); @Override BusinessEntity getBusinessEntityByHCID(String sHomeCommunityId); @Override Set<BusinessEntity> getBusinessEntitySetByServiceName(List<String> saHomeCommunityId,
        String sUniformServiceName); @Override Set<BusinessEntity> getAllBusinessEntitySetByServiceName(String sUniformServiceName); @Override List<UDDI_SPEC_VERSION> getSpecVersions(String homeCommunityId,
        NhincConstants.NHIN_SERVICE_NAMES serviceName); @Override String getAdapterEndpointURL(String sHomeCommunityId, String sServiceName, ADAPTER_API_LEVEL level); @Override String getAdapterEndpointURL(String sServiceName, ADAPTER_API_LEVEL level); @Override String getDefaultEndpointURLByServiceName(String sHomeCommunityId, String sUniformServiceName); @Override String getEndpointURLByServiceNameSpecVersion(String sHomeCommunityId, String sUniformServiceName,
        UDDI_SPEC_VERSION version); @Override String getInternalEndpointURLByServiceName(String sUniformServiceName); @Override String getEndpointURLFromNhinTarget(NhinTargetSystemType targetSystem, String serviceName); @Override List<UrlInfo> getEndpointURLFromNhinTargetCommunities(NhinTargetCommunitiesType targets, String serviceName); boolean updateInternalServiceUrl(String serviceName, String url);  }
@Test public void testGetEndpointURLFromNhinTarget() { try { ConnectionManagerCache connectionManager = createConnectionManager(); String url = connectionManager.getEndpointURLFromNhinTarget(createNhinTargetSystem(), QUERY_FOR_DOCUMENTS_NAME); assertTrue(url.equals(NHIN_TARGET_ENDPOINT_URL_VALUE)); url = connectionManager.getEndpointURLFromNhinTarget(createNhinTargetSystem_UrlOnly(), QUERY_FOR_DOCUMENTS_NAME); assertTrue(url.equals(NHIN_TARGET_ENDPOINT_URL_VALUE)); url = connectionManager.getEndpointURLFromNhinTarget(createNhinTargetSystem_HCIDOnly(), QUERY_FOR_DOCUMENTS_NAME); assertTrue(url.equals(QUERY_FOR_DOCUMENTS_URL)); url = connectionManager.getEndpointURLFromNhinTarget( createNhinTargetSystem_HCIDOnly(HCID_2, VERSION_OF_SERVICE_2_0), QUERY_FOR_DOCUMENTS_NAME); assertEquals(QUERY_FOR_DOCUMENTS_URL_2, url); url = connectionManager.getEndpointURLFromNhinTarget( createNhinTargetSystem_HCIDOnly(HCID_2, VERSION_OF_SERVICE_3_0), QUERY_FOR_DOCUMENTS_NAME); assertEquals(QUERY_FOR_DOCUMENTS_URL_3, url); } catch (Throwable t) { t.printStackTrace(); fail("Error running testGetEndpointURLFromNhinTarget test: " + t.getMessage()); } }