From 90c42ec03e34dc63fb0b62bae4e8e7671c47cb31 Mon Sep 17 00:00:00 2001 From: Gintas Grigelionis Date: Thu, 24 Aug 2017 13:02:31 +0200 Subject: [PATCH] use collections instead of arrays; optimise their use --- .../org/apache/ivy/core/IvyPatternHelper.java | 14 ++-- .../core/module/descriptor/Configuration.java | 25 +++---- .../apache/ivy/core/report/ResolveReport.java | 6 +- .../parser/xml/XmlModuleDescriptorParser.java | 24 +++---- .../xml/XmlModuleDescriptorUpdater.java | 6 +- .../org/apache/ivy/plugins/version/Match.java | 30 ++++---- .../util/extendable/ExtendableItemHelper.java | 21 ++++-- .../apache/ivy/core/resolve/ResolveTest.java | 70 ++++++++----------- .../xml/XmlModuleDescriptorParserTest.java | 4 +- 9 files changed, 102 insertions(+), 98 deletions(-) diff --git a/src/java/org/apache/ivy/core/IvyPatternHelper.java b/src/java/org/apache/ivy/core/IvyPatternHelper.java index 613d7aceb..268be309f 100644 --- a/src/java/org/apache/ivy/core/IvyPatternHelper.java +++ b/src/java/org/apache/ivy/core/IvyPatternHelper.java @@ -163,7 +163,7 @@ public static String substitute(String pattern, String org, String module, Strin tokens.put(ORIGINAL_ARTIFACTNAME_KEY, new OriginalArtifactNameValue(origin)); } - return substituteTokens(pattern, tokens); + return substituteTokens(pattern, tokens, false); } // CheckStyle:ParameterNumber ON @@ -218,9 +218,15 @@ private static String substituteVariables(String pattern, IvyVariableContainer v } } - @SuppressWarnings({"rawtypes", "unchecked"}) - public static String substituteTokens(String pattern, Map tokens) { - Map tokensCopy = new HashMap<>(tokens); + // This is a cludge to reconcile different values passed to the method + public static String substituteTokens(String pattern, Map tokens) { + Map tokensCopy = new HashMap<>(); + tokensCopy.putAll(tokens); + return substituteTokens(pattern, tokensCopy, true); + } + + private static String substituteTokens(String pattern, Map tokens, boolean external) { + Map tokensCopy = external ? tokens : new HashMap<>(tokens); if (tokensCopy.containsKey(ORGANISATION_KEY) && !tokensCopy.containsKey(ORGANISATION_KEY2)) { tokensCopy.put(ORGANISATION_KEY2, tokensCopy.get(ORGANISATION_KEY)); } diff --git a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java b/src/java/org/apache/ivy/core/module/descriptor/Configuration.java index 56d96c48b..d5ff9c7c2 100644 --- a/src/java/org/apache/ivy/core/module/descriptor/Configuration.java +++ b/src/java/org/apache/ivy/core/module/descriptor/Configuration.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -74,7 +75,7 @@ public static Collection findConfigurationExtending(String conf, private String description; - private String[] extendsFrom; + private Set extendsFrom; private Visibility visibility; @@ -95,9 +96,9 @@ public Configuration(String name) { } public Configuration(Configuration source, ModuleRevisionId sourceModule) { - this(source.getAttributes(), source.getQualifiedExtraAttributes(), source.getName(), source - .getVisibility(), source.getDescription(), source.getExtends(), source - .isTransitive(), source.getDeprecated(), sourceModule); + this(source.getAttributes(), source.getQualifiedExtraAttributes(), source.getName(), + source.getVisibility(), source.getDescription(), source.getExtends(), + source.isTransitive(), source.getDeprecated(), sourceModule); } /** @@ -122,7 +123,7 @@ public Configuration(String name, Visibility visibility, String description, Str } private Configuration(Map attributes, Map extraAttributes, - String name, Visibility visibility, String description, String[] ext, + String name, Visibility visibility, String description, String[] exts, boolean transitive, String deprecated, ModuleRevisionId sourceModule) { super(attributes, extraAttributes); @@ -135,12 +136,12 @@ private Configuration(Map attributes, Map extraA this.name = name; this.visibility = visibility; this.description = description; - if (ext == null) { - extendsFrom = new String[0]; + if (exts == null) { + extendsFrom = Collections.emptySet(); } else { - extendsFrom = new String[ext.length]; - for (int i = 0; i < ext.length; i++) { - extendsFrom[i] = ext[i].trim(); + extendsFrom = new LinkedHashSet<>(); + for (String ext : exts) { + extendsFrom.add(ext.trim()); } } this.transitive = transitive; @@ -168,7 +169,7 @@ public String getDescription() { * @return Returns the extends. May be empty, but never null. */ public String[] getExtends() { - return extendsFrom; + return extendsFrom.toArray(new String[extendsFrom.size()]); } /** @@ -232,7 +233,7 @@ public void replaceWildcards(ModuleDescriptor md) { } } - this.extendsFrom = newExtends.toArray(new String[newExtends.size()]); + this.extendsFrom = newExtends; } private void addOther(Configuration[] allConfigs, Visibility visibility, Set configs) { diff --git a/src/java/org/apache/ivy/core/report/ResolveReport.java b/src/java/org/apache/ivy/core/report/ResolveReport.java index 5bc7e5664..e9eec57df 100644 --- a/src/java/org/apache/ivy/core/report/ResolveReport.java +++ b/src/java/org/apache/ivy/core/report/ResolveReport.java @@ -322,16 +322,16 @@ public String getResolveId() { * specified one. * * @param extended String - * @return String[] + * @return Set of String */ @SuppressWarnings("unused") - private String[] getExtendingConfs(String extended) { + private Set getExtendingConfs(String extended) { Set extendingConfs = new HashSet<>(); extendingConfs.add(extended); for (String conf : md.getConfigurationsNames()) { gatherExtendingConfs(extendingConfs, conf, extended); } - return extendingConfs.toArray(new String[extendingConfs.size()]); + return extendingConfs; } private boolean gatherExtendingConfs(Set extendingConfs, String conf, String extended) { diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java index 2828499ff..9c71ea69a 100644 --- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java +++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java @@ -89,8 +89,8 @@ * uses only the SAX API, which makes the parsing code harder to understand. */ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser { - static final String[] DEPENDENCY_REGULAR_ATTRIBUTES = new String[] {"org", "name", "branch", - "branchConstraint", "rev", "revConstraint", "force", "transitive", "changing", "conf"}; + static final List DEPENDENCY_REGULAR_ATTRIBUTES = Arrays.asList("org", "name", "branch", + "branchConstraint", "rev", "revConstraint", "force", "transitive", "changing", "conf"); private static final XmlModuleDescriptorParser INSTANCE = new XmlModuleDescriptorParser(); @@ -845,8 +845,8 @@ protected void confStarted(Attributes attributes) { settings.substitute(attributes.getValue("description")), (ext == null) ? null : ext.split(","), transitive, deprecated); ExtendableItemHelper.fillExtraAttributes(settings, configuration, attributes, - new String[] {"name", "visibility", "extends", "transitive", "description", - "deprecated"}); + Arrays.asList("name", "visibility", "extends", "transitive", "description", + "deprecated")); getMd().addConfiguration(configuration); break; case State.PUB: @@ -954,7 +954,7 @@ protected void artifactStarted(String qName, Attributes attributes) String url = settings.substitute(attributes.getValue("url")); artifact = new MDArtifact(getMd(), artName, type, ext, url == null ? null : new URL(url), ExtendableItemHelper.getExtraAttributes(settings, - attributes, new String[] {"ext", "type", "name", "conf"})); + attributes, Arrays.asList("ext", "type", "name", "conf"))); String confs = settings.substitute(attributes.getValue("conf")); // only add confs if they are specified. if they aren't, endElement will // handle this @@ -1013,9 +1013,9 @@ protected void infoStarted(Attributes attributes) { module, branch, revision, - ExtendableItemHelper.getExtraAttributes(settings, attributes, new String[] { + ExtendableItemHelper.getExtraAttributes(settings, attributes, Arrays.asList( "organisation", "module", "revision", "status", "publication", - "branch", "namespace", "default", "resolver"}))); + "branch", "namespace", "default", "resolver")))); String namespace = settings.substitute(attributes.getValue("namespace")); if (namespace != null) { @@ -1107,7 +1107,7 @@ protected void parseRule(String tag, Attributes attributes) throws MalformedURLE if (state == State.DEP_ARTIFACT) { String url = settings.substitute(attributes.getValue("url")); Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, - attributes, new String[] {"name", "type", "ext", "url", "conf"}); + attributes, Arrays.asList("name", "type", "ext", "url", "conf")); confAware = new DefaultDependencyArtifactDescriptor(dd, name, type, ext, url == null ? null : new URL(url), extraAtt); } else if (state == State.ARTIFACT_INCLUDE) { @@ -1118,8 +1118,8 @@ protected void parseRule(String tag, Attributes attributes) throws MalformedURLE module = module == null ? PatternMatcher.ANY_EXPRESSION : module; ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext); Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, - attributes, new String[] {"org", "module", "name", "type", "ext", "matcher", - "conf"}); + attributes, Arrays.asList("org", "module", "name", "type", "ext", "matcher", + "conf")); confAware = new DefaultIncludeRule(aid, matcher, extraAtt); } else { // _state == ARTIFACT_EXCLUDE || EXCLUDE PatternMatcher matcher = getPatternMatcher(attributes.getValue("matcher")); @@ -1129,8 +1129,8 @@ protected void parseRule(String tag, Attributes attributes) throws MalformedURLE module = module == null ? PatternMatcher.ANY_EXPRESSION : module; ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext); Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, - attributes, new String[] {"org", "module", "name", "type", "ext", "matcher", - "conf"}); + attributes, Arrays.asList("org", "module", "name", "type", "ext", "matcher", + "conf")); confAware = new DefaultExcludeRule(aid, matcher, extraAtt); } String confs = settings.substitute(attributes.getValue("conf")); diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java index aadfd991c..96c1bd4b3 100644 --- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java +++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java @@ -749,9 +749,9 @@ private void infoStarted(Attributes attributes) { // if necessary translate mrid using optional namespace argument ModuleRevisionId localMid = ModuleRevisionId.newInstance(organisation, module, branch, - rev, ExtendableItemHelper - .getExtraAttributes(settings, attributes, new String[] {"organisation", - "module", "revision", "status", "publication", "namespace"})); + rev, ExtendableItemHelper.getExtraAttributes(settings, attributes, + Arrays.asList("organisation", "module", "revision", "status", + "publication", "namespace"))); ModuleRevisionId systemMid = (ns == null) ? localMid : ns.getToSystemTransformer() .transform(localMid); diff --git a/src/java/org/apache/ivy/plugins/version/Match.java b/src/java/org/apache/ivy/plugins/version/Match.java index 93f283806..b2324e038 100644 --- a/src/java/org/apache/ivy/plugins/version/Match.java +++ b/src/java/org/apache/ivy/plugins/version/Match.java @@ -17,8 +17,9 @@ */ package org.apache.ivy.plugins.version; -import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.StringTokenizer; @@ -76,16 +77,16 @@ public void setRevision(String revision) { public Matcher getPatternMatcher(ModuleRevisionId askedMrid) { String revision = askedMrid.getRevision(); - String[] args = split(getArgs()); - String[] argValues = getRevisionArgs(revision); + List args = split(getArgs()); + List argValues = getRevisionArgs(revision); - if (args.length != argValues.length) { + if (args.size() != argValues.size()) { return new NoMatchMatcher(); } Map variables = new HashMap<>(); - for (int i = 0; i < args.length; i++) { - variables.put(args[i], argValues[i]); + for (String arg : args) { + variables.put(arg, argValues.get(args.indexOf(arg))); } String pattern = getPattern(); @@ -95,33 +96,32 @@ public Matcher getPatternMatcher(ModuleRevisionId askedMrid) { return pMatcher.getMatcher(pattern); } - private String[] getRevisionArgs(String revision) { + private List getRevisionArgs(String revision) { int bracketStartIndex = revision.indexOf('('); if (bracketStartIndex == -1) { - return new String[0]; + return Collections.emptyList(); } int bracketEndIndex = revision.indexOf(')'); if (bracketEndIndex <= (bracketStartIndex + 1)) { - return new String[0]; + return Collections.emptyList(); } - String args = revision.substring(bracketStartIndex + 1, bracketEndIndex); - return split(args); + return split(revision.substring(bracketStartIndex + 1, bracketEndIndex)); } - private static String[] split(String string) { + private static List split(String string) { if (string == null) { - return new String[0]; + return Collections.emptyList(); } StringTokenizer tokenizer = new StringTokenizer(string, ", "); - List tokens = new ArrayList<>(); + List tokens = new LinkedList<>(); while (tokenizer.hasMoreTokens()) { tokens.add(tokenizer.nextToken()); } - return tokens.toArray(new String[tokens.size()]); + return tokens; } private static class NoMatchMatcher implements Matcher { diff --git a/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java b/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java index 09ce46ca5..bf43e9c76 100644 --- a/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java +++ b/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java @@ -18,8 +18,8 @@ package org.apache.ivy.util.extendable; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -40,6 +40,12 @@ public static Map getExtraAttributes(Attributes attributes, Stri return ret; } + @Deprecated + public static Map getExtraAttributes(ParserSettings settings, + Attributes attributes, String[] ignoredAttNames) { + return getExtraAttributes(settings, attributes, Arrays.asList(ignoredAttNames)); + } + /** * Extract from the XML attribute the extra Ivy ones * @@ -50,19 +56,24 @@ public static Map getExtraAttributes(Attributes attributes, Stri * @return Map<String,String> */ public static Map getExtraAttributes(ParserSettings settings, - Attributes attributes, String[] ignoredAttNames) { + Attributes attributes, List ignoredAttNames) { Map ret = new HashMap<>(); - Collection ignored = Arrays.asList(ignoredAttNames); for (int i = 0; i < attributes.getLength(); i++) { - if (!ignored.contains(attributes.getQName(i))) { + if (!ignoredAttNames.contains(attributes.getQName(i))) { ret.put(attributes.getQName(i), settings.substitute(attributes.getValue(i))); } } return ret; } + @Deprecated + public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item, + Attributes attributes, String[] ignoredAttNames) { + fillExtraAttributes(settings, item, attributes, Arrays.asList(ignoredAttNames)); + } + public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item, - Attributes attributes, String[] ignoredAttNames) { + Attributes attributes, List ignoredAttNames) { Map att = getExtraAttributes(settings, attributes, ignoredAttNames); for (Entry entry : att.entrySet()) { item.setExtraAttribute(entry.getKey(), entry.getValue()); diff --git a/test/java/org/apache/ivy/core/resolve/ResolveTest.java b/test/java/org/apache/ivy/core/resolve/ResolveTest.java index 0ad84b181..73cf6853d 100644 --- a/test/java/org/apache/ivy/core/resolve/ResolveTest.java +++ b/test/java/org/apache/ivy/core/resolve/ResolveTest.java @@ -595,9 +595,8 @@ public void testDynamicFromCache() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // now we clean the repository to simulate repo not available (network pb for instance) FileUtil.forceDelete(new File("build/testCache2")); @@ -607,9 +606,8 @@ public void testDynamicFromCache() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); } @Test @@ -633,9 +631,8 @@ public void testDynamicFromCacheWithMD() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // now we clean the repository to simulate repo not available (network pb for instance) FileUtil.forceDelete(new File("build/testCache2")); @@ -645,9 +642,8 @@ public void testDynamicFromCacheWithMD() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); } @Test @@ -672,9 +668,8 @@ public void testDynamicFromCacheWithMDAfterOneTTLExpiration() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // now we wait for ttl expiration Thread.sleep(700); @@ -684,9 +679,8 @@ public void testDynamicFromCacheWithMDAfterOneTTLExpiration() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // now we clean the repository to simulate repo not available (network pb for instance) FileUtil.forceDelete(new File("build/testCache2")); @@ -696,9 +690,8 @@ public void testDynamicFromCacheWithMDAfterOneTTLExpiration() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); } @Test @@ -719,9 +712,8 @@ public void testDynamicFromCacheWithTTL0() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // now we update the repository FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), new File( @@ -732,9 +724,8 @@ public void testDynamicFromCacheWithTTL0() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.6"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")), + report.getConfigurationReport("default").getModuleRevisionIds()); } @Test @@ -766,9 +757,8 @@ public void testDynamicFromCacheWithTTL() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // wait for org1 TTL to expire Thread.sleep(700); @@ -778,9 +768,8 @@ public void testDynamicFromCacheWithTTL() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.6"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")), + report.getConfigurationReport("default").getModuleRevisionIds()); } @Test @@ -809,18 +798,16 @@ public void testRefreshDynamicFromCache() throws Exception { getResolveOptions(new String[] {"*"})); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.5"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.5")), + report.getConfigurationReport("default").getModuleRevisionIds()); // resolve again with refresh: it should find the new version report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] {"*"}).setRefresh(true)); assertFalse(report.hasError()); - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org1", - "mod1.2", "1.6"))), report.getConfigurationReport("default").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org1", "mod1.2", "1.6")), + report.getConfigurationReport("default").getModuleRevisionIds()); FileUtil.forceDelete(new File("build/testCache2")); } @@ -2029,9 +2016,8 @@ public void testDisableTransitivityPerConfiguration4() throws Exception { r.getConfigurationReport("B").getModuleRevisionIds()); // here we should get only mod2.1 cause compile is not transitive - assertEquals( - new HashSet<>(Collections.singletonList(ModuleRevisionId.newInstance("org2", - "mod2.1", "0.3.2"))), r.getConfigurationReport("compile").getModuleRevisionIds()); + assertEquals(Collections.singleton(ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2")), + r.getConfigurationReport("compile").getModuleRevisionIds()); } @Test diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java index 6fdcf5d00..d29cbbf36 100644 --- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java +++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java @@ -371,7 +371,7 @@ public void testFull() throws Exception { assertNotNull(dd); assertEquals("yourorg", dd.getDependencyId().getOrganisation()); assertEquals("11.1", dd.getDependencyRevisionId().getRevision()); - assertEquals(new HashSet<>(Collections.singletonList("*")), + assertEquals(Collections.singleton("*"), new HashSet<>(Arrays.asList(dd.getModuleConfigurations()))); assertEquals(Collections.singletonList("myconf1"), Arrays.asList(dd.getDependencyConfigurations("myconf1"))); @@ -447,7 +447,7 @@ public void testFull() throws Exception { assertNotNull(dd); assertEquals("yourorg", dd.getDependencyId().getOrganisation()); assertEquals("10.1", dd.getDependencyRevisionId().getRevision()); - assertEquals(new HashSet<>(Collections.singletonList("*")), + assertEquals(Collections.singleton("*"), new HashSet<>(Arrays.asList(dd.getModuleConfigurations()))); assertDependencyArtifactIncludeRules(dd, new String[] {"myconf1"}, new String[] {"your.*", PatternMatcher.ANY_EXPRESSION});