@Test public void buildDependencyMapUniquePluginsTest() { List<ArtifactCoordinates> dependencies = new ArrayList<>(); dependencies.add(createDependency(0, "1.0.0", "mule-plugin")); dependencies.add(createDependency(1, "1.0.0", "mule-plugin")); dependencies.add(createDependency(2, "1.0.0", "mule-plugin")); Map<String, List<ArtifactCoordinates>> actualDependencyMap = validator.buildDependencyMap(dependencies); assertThat("Dependency map should contain 3 elements", actualDependencyMap.size(), equalTo(3)); assertThat("Every dependency list should contain 1 element", actualDependencyMap.values().stream().allMatch(l -> l.size() == 1), is(true)); }
protected Map<String, List<ArtifactCoordinates>> buildDependencyMap(List<ArtifactCoordinates> dependencyList) { Map<String, List<ArtifactCoordinates>> dependencyMap = new HashMap<>(); for (ArtifactCoordinates plugin : dependencyList) { String key = plugin.getGroupId() + ":" + plugin.getArtifactId(); dependencyMap.computeIfAbsent(key, k -> new ArrayList<>()); dependencyMap.get(key).add(plugin); } return dependencyMap; }
MulePluginsCompatibilityValidator { protected Map<String, List<ArtifactCoordinates>> buildDependencyMap(List<ArtifactCoordinates> dependencyList) { Map<String, List<ArtifactCoordinates>> dependencyMap = new HashMap<>(); for (ArtifactCoordinates plugin : dependencyList) { String key = plugin.getGroupId() + ":" + plugin.getArtifactId(); dependencyMap.computeIfAbsent(key, k -> new ArrayList<>()); dependencyMap.get(key).add(plugin); } return dependencyMap; } }
MulePluginsCompatibilityValidator { protected Map<String, List<ArtifactCoordinates>> buildDependencyMap(List<ArtifactCoordinates> dependencyList) { Map<String, List<ArtifactCoordinates>> dependencyMap = new HashMap<>(); for (ArtifactCoordinates plugin : dependencyList) { String key = plugin.getGroupId() + ":" + plugin.getArtifactId(); dependencyMap.computeIfAbsent(key, k -> new ArrayList<>()); dependencyMap.get(key).add(plugin); } return dependencyMap; }  }
MulePluginsCompatibilityValidator { protected Map<String, List<ArtifactCoordinates>> buildDependencyMap(List<ArtifactCoordinates> dependencyList) { Map<String, List<ArtifactCoordinates>> dependencyMap = new HashMap<>(); for (ArtifactCoordinates plugin : dependencyList) { String key = plugin.getGroupId() + ":" + plugin.getArtifactId(); dependencyMap.computeIfAbsent(key, k -> new ArrayList<>()); dependencyMap.get(key).add(plugin); } return dependencyMap; }  void validate(List<ArtifactCoordinates> mulePlugins); }
MulePluginsCompatibilityValidator { protected Map<String, List<ArtifactCoordinates>> buildDependencyMap(List<ArtifactCoordinates> dependencyList) { Map<String, List<ArtifactCoordinates>> dependencyMap = new HashMap<>(); for (ArtifactCoordinates plugin : dependencyList) { String key = plugin.getGroupId() + ":" + plugin.getArtifactId(); dependencyMap.computeIfAbsent(key, k -> new ArrayList<>()); dependencyMap.get(key).add(plugin); } return dependencyMap; }  void validate(List<ArtifactCoordinates> mulePlugins);  }