@Test public void testComparingNewREVersioning() { assertEquals("dev vs new re versioning asc", -1L, underTest.compare(() -> "2.1.1-dev.1", () -> "2.1.1-b3")); assertEquals("dev vs new re versioning desc", 1L, underTest.compare(() -> "2.1.2-dev.13", () -> "2.1.1-b3")); assertEquals("dev vs new re versioning desc build number", -1L, underTest.compare(() -> "2.1.1-dev.13", () -> "2.1.1-b3")); assertEquals("dev vs new re versioning equals", -1L, underTest.compare(() -> "2.1.1-dev.3", () -> "2.1.1-b3")); assertEquals("rc vs new re versioning asc", -1L, underTest.compare(() -> "2.1.1-rc.1", () -> "2.1.1-b3")); assertEquals("rc vs new re versioning desc", 1L, underTest.compare(() -> "2.1.2-rc.13", () -> "2.1.1-b3")); assertEquals("rc vs new re versioning desc build number", -1L, underTest.compare(() -> "2.1.1-rc.13", () -> "2.1.1-b3")); assertEquals("rc vs new re versioning equals", -1L, underTest.compare(() -> "2.1.1-rc.3", () -> "2.1.1-b3")); assertEquals("released vs new re versioning asc", -1L, underTest.compare(() -> "2.1.1-rc.1", () -> "2.3.1")); assertEquals("released vs new re versioning desc", 1L, underTest.compare(() -> "2.1.2-b13", () -> "2.1.1")); assertEquals("re versioning asc", -1L, underTest.compare(() -> "2.1.1-b2", () -> "2.1.1-b3")); assertEquals("re versioning desc", 1L, underTest.compare(() -> "2.1.1-b12", () -> "2.1.1-b3")); assertEquals("unspecified vs new re versioning", -1L, underTest.compare(() -> "2.1.2-b13", () -> "unspecified")); assertEquals("dev vs new re versioning asc", -1L, underTest.compare(() -> "2.1.1-dev.1", () -> "2.2.1-b3")); assertEquals("rc vs new re versioning asc", -1L, underTest.compare(() -> "2.1.1-rc.1", () -> "2.2.1-b3")); }
@Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); } }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }  }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }  @Override int compare(Versioned o1, Versioned o2); }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }  @Override int compare(Versioned o1, Versioned o2);  }