@Test public void compare_If_Complicated_Version_Is_Outdated() { String current = "v1-rev110-1.24.0"; String latest = "v1-rev110-1.25.0"; VersionNumber currentVersion = new VersionNumber(current); VersionNumber latestVersion = new VersionNumber(latest); String receivedValue = currentVersion.compareTo(latestVersion); assertThat(receivedValue).isEqualTo("Outdated"); }
public String compareTo(VersionNumber latestVersion) { if (versionNumberArray != null) { int maxLength = Math.max(versionNumberArray.length, latestVersion.versionNumberArray.length); for (int i = 0; i < maxLength; i++) { int left = i < versionNumberArray.length ? versionNumberArray[i] : 0; int right = i < latestVersion.versionNumberArray.length ? latestVersion.versionNumberArray[i] : 0; if (left != right) { return left < right ? VersionStatus.OUTDATED.toString() : VersionStatus.AHEAD.toString(); } } return VersionStatus.UP_TO_DATE.toString(); } else { return "Nothing to compare"; } }
VersionNumber { public String compareTo(VersionNumber latestVersion) { if (versionNumberArray != null) { int maxLength = Math.max(versionNumberArray.length, latestVersion.versionNumberArray.length); for (int i = 0; i < maxLength; i++) { int left = i < versionNumberArray.length ? versionNumberArray[i] : 0; int right = i < latestVersion.versionNumberArray.length ? latestVersion.versionNumberArray[i] : 0; if (left != right) { return left < right ? VersionStatus.OUTDATED.toString() : VersionStatus.AHEAD.toString(); } } return VersionStatus.UP_TO_DATE.toString(); } else { return "Nothing to compare"; } } }
VersionNumber { public String compareTo(VersionNumber latestVersion) { if (versionNumberArray != null) { int maxLength = Math.max(versionNumberArray.length, latestVersion.versionNumberArray.length); for (int i = 0; i < maxLength; i++) { int left = i < versionNumberArray.length ? versionNumberArray[i] : 0; int right = i < latestVersion.versionNumberArray.length ? latestVersion.versionNumberArray[i] : 0; if (left != right) { return left < right ? VersionStatus.OUTDATED.toString() : VersionStatus.AHEAD.toString(); } } return VersionStatus.UP_TO_DATE.toString(); } else { return "Nothing to compare"; } } VersionNumber(String version); }
VersionNumber { public String compareTo(VersionNumber latestVersion) { if (versionNumberArray != null) { int maxLength = Math.max(versionNumberArray.length, latestVersion.versionNumberArray.length); for (int i = 0; i < maxLength; i++) { int left = i < versionNumberArray.length ? versionNumberArray[i] : 0; int right = i < latestVersion.versionNumberArray.length ? latestVersion.versionNumberArray[i] : 0; if (left != right) { return left < right ? VersionStatus.OUTDATED.toString() : VersionStatus.AHEAD.toString(); } } return VersionStatus.UP_TO_DATE.toString(); } else { return "Nothing to compare"; } } VersionNumber(String version); String compareTo(VersionNumber latestVersion); }
VersionNumber { public String compareTo(VersionNumber latestVersion) { if (versionNumberArray != null) { int maxLength = Math.max(versionNumberArray.length, latestVersion.versionNumberArray.length); for (int i = 0; i < maxLength; i++) { int left = i < versionNumberArray.length ? versionNumberArray[i] : 0; int right = i < latestVersion.versionNumberArray.length ? latestVersion.versionNumberArray[i] : 0; if (left != right) { return left < right ? VersionStatus.OUTDATED.toString() : VersionStatus.AHEAD.toString(); } } return VersionStatus.UP_TO_DATE.toString(); } else { return "Nothing to compare"; } } VersionNumber(String version); String compareTo(VersionNumber latestVersion);  }