HttpRepository implements Repository { public static String upgradePath(String spec, String version, Pattern versionPattern) { Matcher matcher = versionPattern.matcher(spec); StringBuilder out = new StringBuilder(); int end = 0; while (matcher.find()) { for (int group = 0; group < matcher.groupCount(); group++) { out.append(spec.substring(end, matcher.start(group + 1))).append(version); end = matcher.end(group + 1); } } if (end == 0) { return null; } out.append(spec.substring(end)); return out.toString(); } @Inject  HttpRepository(CoordinatorConfig config);  HttpRepository(Iterable<URI> baseUris, String configShortNamePattern, String configVersionPattern, String binaryVersionPattern); @Override String configShortName(String config); @Override String configRelativize(String config); @Override String configResolve(String config); @Override String configUpgrade(String config, String version); @Override boolean configEqualsIgnoreVersion(String config1, String config2); @Override URI configToHttpUri(String config); @Override String binaryRelativize(String binary); @Override String binaryResolve(String binary); @Override String binaryUpgrade(String binary, String version); @Override boolean binaryEqualsIgnoreVersion(String binary1, String binary2); @Override URI binaryToHttpUri(String binary); static String upgradePath(String spec, String version, Pattern versionPattern); @Override String toString();  }
@Test public void upgradeVersion() { Assert.assertEquals(HttpRepository.upgradePath("#", "X", Pattern.compile("(#)")), "X"); Assert.assertEquals(HttpRepository.upgradePath("##", "X", Pattern.compile("(#)")), "XX"); Assert.assertEquals(HttpRepository.upgradePath("a#b", "X", Pattern.compile("(#)")), "aXb"); Assert.assertEquals(HttpRepository.upgradePath("a#b#c#d", "X", Pattern.compile("(#)")), "aXbXcXd"); Assert.assertEquals(HttpRepository.upgradePath("#ooo@", "X", Pattern.compile("(#)ooo(@)")), "XoooX"); Assert.assertEquals(HttpRepository.upgradePath("#ooo@#ooo@", "X", Pattern.compile("(#)ooo(@)")), "XoooXXoooX"); Assert.assertEquals(HttpRepository.upgradePath("a#ooo@b", "X", Pattern.compile("(#)ooo(@)")), "aXoooXb"); Assert.assertEquals(HttpRepository.upgradePath("a#ooo@b#ooo@c", "X", Pattern.compile("(#)ooo(@)")), "aXoooXbXoooXc"); }