@Test public void testGenerateRedirects_one_url_is_empty() { List<String> registryUrls = new ArrayList<String>(); registryUrls.add(null); registryUrls.add("URL1"); List<Redirect> redirects = handler.generateRedirects("1.0.0.0/8", registryUrls); assertEquals(1, redirects.size()); List<String> results = redirects.get(0).getUrls(); assertEquals(1, results.size()); assertThat(results, CoreMatchers.hasItems("URL1")); }
@Override List<Redirect> generateRedirects(String key, List<String> registryUrls) { List<Redirect> redirects = new ArrayList<Redirect>(); if (!removeEmptyUrlsAndValidate(registryUrls)) { logger.error("ignore this key/urls:{},{}. Urls are empty.", key, registryUrls); return redirects; } NetworkRedirect networkRedirect = new NetworkRedirect(registryUrls); IpVersion ipVersion = IpUtil.getIpVersionOfNetwork(key); if (ipVersion.isNotValidIp()) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); return redirects; } try { QueryParam queryParam = NetworkQueryParam.generateQueryParam(key); if (null == queryParam) { logger.error( "ignore this key/urls:{},{}. generate networkQueryParam error:{}", key, registryUrls); return redirects; } networkRedirect .setNetworkQueryParam((NetworkQueryParam) queryParam); redirects.add(networkRedirect); } catch (Exception e) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); } return redirects; }
NetworkRegistryHandler extends RegistryHandler { @Override List<Redirect> generateRedirects(String key, List<String> registryUrls) { List<Redirect> redirects = new ArrayList<Redirect>(); if (!removeEmptyUrlsAndValidate(registryUrls)) { logger.error("ignore this key/urls:{},{}. Urls are empty.", key, registryUrls); return redirects; } NetworkRedirect networkRedirect = new NetworkRedirect(registryUrls); IpVersion ipVersion = IpUtil.getIpVersionOfNetwork(key); if (ipVersion.isNotValidIp()) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); return redirects; } try { QueryParam queryParam = NetworkQueryParam.generateQueryParam(key); if (null == queryParam) { logger.error( "ignore this key/urls:{},{}. generate networkQueryParam error:{}", key, registryUrls); return redirects; } networkRedirect .setNetworkQueryParam((NetworkQueryParam) queryParam); redirects.add(networkRedirect); } catch (Exception e) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); } return redirects; } }
NetworkRegistryHandler extends RegistryHandler { @Override List<Redirect> generateRedirects(String key, List<String> registryUrls) { List<Redirect> redirects = new ArrayList<Redirect>(); if (!removeEmptyUrlsAndValidate(registryUrls)) { logger.error("ignore this key/urls:{},{}. Urls are empty.", key, registryUrls); return redirects; } NetworkRedirect networkRedirect = new NetworkRedirect(registryUrls); IpVersion ipVersion = IpUtil.getIpVersionOfNetwork(key); if (ipVersion.isNotValidIp()) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); return redirects; } try { QueryParam queryParam = NetworkQueryParam.generateQueryParam(key); if (null == queryParam) { logger.error( "ignore this key/urls:{},{}. generate networkQueryParam error:{}", key, registryUrls); return redirects; } networkRedirect .setNetworkQueryParam((NetworkQueryParam) queryParam); redirects.add(networkRedirect); } catch (Exception e) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); } return redirects; }  }
NetworkRegistryHandler extends RegistryHandler { @Override List<Redirect> generateRedirects(String key, List<String> registryUrls) { List<Redirect> redirects = new ArrayList<Redirect>(); if (!removeEmptyUrlsAndValidate(registryUrls)) { logger.error("ignore this key/urls:{},{}. Urls are empty.", key, registryUrls); return redirects; } NetworkRedirect networkRedirect = new NetworkRedirect(registryUrls); IpVersion ipVersion = IpUtil.getIpVersionOfNetwork(key); if (ipVersion.isNotValidIp()) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); return redirects; } try { QueryParam queryParam = NetworkQueryParam.generateQueryParam(key); if (null == queryParam) { logger.error( "ignore this key/urls:{},{}. generate networkQueryParam error:{}", key, registryUrls); return redirects; } networkRedirect .setNetworkQueryParam((NetworkQueryParam) queryParam); redirects.add(networkRedirect); } catch (Exception e) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); } return redirects; }   }
NetworkRegistryHandler extends RegistryHandler { @Override List<Redirect> generateRedirects(String key, List<String> registryUrls) { List<Redirect> redirects = new ArrayList<Redirect>(); if (!removeEmptyUrlsAndValidate(registryUrls)) { logger.error("ignore this key/urls:{},{}. Urls are empty.", key, registryUrls); return redirects; } NetworkRedirect networkRedirect = new NetworkRedirect(registryUrls); IpVersion ipVersion = IpUtil.getIpVersionOfNetwork(key); if (ipVersion.isNotValidIp()) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); return redirects; } try { QueryParam queryParam = NetworkQueryParam.generateQueryParam(key); if (null == queryParam) { logger.error( "ignore this key/urls:{},{}. generate networkQueryParam error:{}", key, registryUrls); return redirects; } networkRedirect .setNetworkQueryParam((NetworkQueryParam) queryParam); redirects.add(networkRedirect); } catch (Exception e) { logger.error("ignore this key/urls:{},{}. Invalid network:{}", key, registryUrls); } return redirects; }    }