@Test public void testGetInvalidDependenciesLocations() throws URISyntaxException { PackageProperties packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS, "group1:name1:1.0maven:com.example.mygroupid:myartifactId:1.0.0:zip")); Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap())); packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS, "=maven:com.example.mygroupid:myartifactId:1.0.0:zip")); Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap())); packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS, "group1:name1:1.0=maven:invalid uri")); Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap())); }
@Override public Map<PackageId, URI> getDependenciesLocations() { String deps = getProperty(NAME_DEPENDENCIES_LOCATIONS); if (deps == null || deps.length() == 0) { return Collections.emptyMap(); } else { Map<PackageId, URI> dependenciesLocations = new HashMap<>(); for (String item : deps.split(",")) { String[] parts = item.split("=", 2); if (parts.length < 2) { log.error("Invalid dependencies locations string, item " +item + " does not contain a '='"); } else { PackageId packageId = PackageId.fromString(parts[0]); if (packageId == null) { log.error("Invalid package id given in item " + item); continue; } try { URI uri = new URI(parts[1]); dependenciesLocations.put(packageId, uri); } catch (URISyntaxException e) { log.error("Invalid uri given in item " + item); } } } return dependenciesLocations; } }
PackagePropertiesImpl implements PackageProperties { @Override public Map<PackageId, URI> getDependenciesLocations() { String deps = getProperty(NAME_DEPENDENCIES_LOCATIONS); if (deps == null || deps.length() == 0) { return Collections.emptyMap(); } else { Map<PackageId, URI> dependenciesLocations = new HashMap<>(); for (String item : deps.split(",")) { String[] parts = item.split("=", 2); if (parts.length < 2) { log.error("Invalid dependencies locations string, item " +item + " does not contain a '='"); } else { PackageId packageId = PackageId.fromString(parts[0]); if (packageId == null) { log.error("Invalid package id given in item " + item); continue; } try { URI uri = new URI(parts[1]); dependenciesLocations.put(packageId, uri); } catch (URISyntaxException e) { log.error("Invalid uri given in item " + item); } } } return dependenciesLocations; } } }
PackagePropertiesImpl implements PackageProperties { @Override public Map<PackageId, URI> getDependenciesLocations() { String deps = getProperty(NAME_DEPENDENCIES_LOCATIONS); if (deps == null || deps.length() == 0) { return Collections.emptyMap(); } else { Map<PackageId, URI> dependenciesLocations = new HashMap<>(); for (String item : deps.split(",")) { String[] parts = item.split("=", 2); if (parts.length < 2) { log.error("Invalid dependencies locations string, item " +item + " does not contain a '='"); } else { PackageId packageId = PackageId.fromString(parts[0]); if (packageId == null) { log.error("Invalid package id given in item " + item); continue; } try { URI uri = new URI(parts[1]); dependenciesLocations.put(packageId, uri); } catch (URISyntaxException e) { log.error("Invalid uri given in item " + item); } } } return dependenciesLocations; } }  }
PackagePropertiesImpl implements PackageProperties { @Override public Map<PackageId, URI> getDependenciesLocations() { String deps = getProperty(NAME_DEPENDENCIES_LOCATIONS); if (deps == null || deps.length() == 0) { return Collections.emptyMap(); } else { Map<PackageId, URI> dependenciesLocations = new HashMap<>(); for (String item : deps.split(",")) { String[] parts = item.split("=", 2); if (parts.length < 2) { log.error("Invalid dependencies locations string, item " +item + " does not contain a '='"); } else { PackageId packageId = PackageId.fromString(parts[0]); if (packageId == null) { log.error("Invalid package id given in item " + item); continue; } try { URI uri = new URI(parts[1]); dependenciesLocations.put(packageId, uri); } catch (URISyntaxException e) { log.error("Invalid uri given in item " + item); } } } return dependenciesLocations; } }  @Override PackageId getId(); @Override Calendar getLastModified(); @Override String getLastModifiedBy(); @Override Calendar getCreated(); @Override String getCreatedBy(); @Override Calendar getLastWrapped(); @Override String getLastWrappedBy(); @Override String getDescription(); @Override AccessControlHandling getACHandling(); @Override SubPackageHandling getSubPackageHandling(); @Override boolean requiresRoot(); @Override Dependency[] getDependencies(); @Override Map<PackageId, URI> getDependenciesLocations(); @Override Calendar getDateProperty(String name); @Override String getProperty(String name); @Nullable @Override PackageType getPackageType(); @Override Map<String, String> getExternalHooks(); }
PackagePropertiesImpl implements PackageProperties { @Override public Map<PackageId, URI> getDependenciesLocations() { String deps = getProperty(NAME_DEPENDENCIES_LOCATIONS); if (deps == null || deps.length() == 0) { return Collections.emptyMap(); } else { Map<PackageId, URI> dependenciesLocations = new HashMap<>(); for (String item : deps.split(",")) { String[] parts = item.split("=", 2); if (parts.length < 2) { log.error("Invalid dependencies locations string, item " +item + " does not contain a '='"); } else { PackageId packageId = PackageId.fromString(parts[0]); if (packageId == null) { log.error("Invalid package id given in item " + item); continue; } try { URI uri = new URI(parts[1]); dependenciesLocations.put(packageId, uri); } catch (URISyntaxException e) { log.error("Invalid uri given in item " + item); } } } return dependenciesLocations; } }  @Override PackageId getId(); @Override Calendar getLastModified(); @Override String getLastModifiedBy(); @Override Calendar getCreated(); @Override String getCreatedBy(); @Override Calendar getLastWrapped(); @Override String getLastWrappedBy(); @Override String getDescription(); @Override AccessControlHandling getACHandling(); @Override SubPackageHandling getSubPackageHandling(); @Override boolean requiresRoot(); @Override Dependency[] getDependencies(); @Override Map<PackageId, URI> getDependenciesLocations(); @Override Calendar getDateProperty(String name); @Override String getProperty(String name); @Nullable @Override PackageType getPackageType(); @Override Map<String, String> getExternalHooks();  }