WorkbenchRepositoryEventListener implements RepositoryEventListener { protected String resolveVersion(String version, boolean useVersionRange) { if (useVersionRange) { String[] versionElements = version.split("\\."); StringBuilder builder = new StringBuilder("["); builder.append(versionElements[0]); if (versionElements.length > 1) { try { Integer minor = Integer.parseInt(versionElements[1]); builder.append("."); builder.append(minor); } catch (NumberFormatException e) { logger.debug("Version element {} is not a number, ignoring", versionElements[1]); } } builder.append(",)"); return builder.toString(); } return version; }  @PostConstruct void init(); @Override void onServiceTaskAdded(RepoData service); @Override void onServiceTaskEnabled(RepoData service); @Override void onServiceTaskDisabled(RepoData service); @Override void onServiceTaskInstalled(RepoData service, String target, List<String> parameters, String branchName); @Override void onServiceTaskUninstalled(RepoData service, String target, String branchName);  }
@Test public void testVersionResolveNoRangeOnFinal() { WorkbenchRepositoryEventListener listener = new WorkbenchRepositoryEventListener(); String version = "7.16.0.Final"; String resolved = listener.resolveVersion(version, false); assertEquals(version, resolved); }
@Test public void testVersionResolveNoRangeOnSnapshot() { WorkbenchRepositoryEventListener listener = new WorkbenchRepositoryEventListener(); String version = "7.16.0-SNAPSHOT"; String resolved = listener.resolveVersion(version, false); assertEquals(version, resolved); }
@Test public void testVersionResolveRangeOnFinal() { WorkbenchRepositoryEventListener listener = new WorkbenchRepositoryEventListener(); String version = "7.16.0.Final"; String resolved = listener.resolveVersion(version, true); assertEquals("[7.16,)", resolved); }
@Test public void testVersionResolveRangeOnSnapshot() { WorkbenchRepositoryEventListener listener = new WorkbenchRepositoryEventListener(); String version = "7.16.0-SNAPSHOT"; String resolved = listener.resolveVersion(version, true); assertEquals("[7.16,)", resolved); }
@Test public void testVersionResolveRangeOnShortFinal() { WorkbenchRepositoryEventListener listener = new WorkbenchRepositoryEventListener(); String version = "7.Final"; String resolved = listener.resolveVersion(version, true); assertEquals("[7,)", resolved); }