### Question:
UpdateChecker implements Runnable { static boolean compareVersions(String newVersion, String runningVersion) { boolean usesDevBuild = false; if (runningVersion.endsWith("-SNAPSHOT")) { usesDevBuild = true; runningVersion = runningVersion.replace("-SNAPSHOT", ""); } String[] current = runningVersion.split("\\."); String[] latest = newVersion.split("\\."); int i = 0; boolean higher = false; boolean equal = true; for (; i < current.length && i < latest.length; i++) { if (Integer.valueOf(current[i]) < Integer.valueOf(latest[i])) { higher = true; break; } else if (Objects.equals(Integer.valueOf(current[i]), Integer.valueOf(latest[i]))) { equal = true; } else { equal = false; break; } } boolean updateAvailable = false; if (higher) { updateAvailable = true; } if (equal) { if (current.length < latest.length) { updateAvailable = true; } else if (current.length == latest.length && usesDevBuild) { updateAvailable = true; } } return updateAvailable; } UpdateChecker(Plugin plugin); @Override void run(); boolean isUpdateAvailable(); boolean isNewDevBuildAvailable(); static final long interval; }### Answer:
@Test public void testCompareVersions() throws Exception { Assert.assertTrue(UpdateChecker.compareVersions("2.0", "1.9")); Assert.assertTrue(UpdateChecker.compareVersions("2.0", "2.0-SNAPSHOT")); Assert.assertTrue(UpdateChecker.compareVersions("2.1", "2.0-SNAPSHOT")); Assert.assertTrue(UpdateChecker.compareVersions("2.1", "2.0")); Assert.assertTrue(UpdateChecker.compareVersions("2.0.1", "2.0")); Assert.assertFalse(UpdateChecker.compareVersions("2.1.1", "2.1.2")); Assert.assertFalse(UpdateChecker.compareVersions("1.9", "2.0")); Assert.assertFalse(UpdateChecker.compareVersions("2.0", "2.1")); Assert.assertFalse(UpdateChecker.compareVersions("2.0", "2.0.1")); Assert.assertFalse(UpdateChecker.compareVersions("2.0", "2.1-SNAPSHOT")); Assert.assertFalse(UpdateChecker.compareVersions("2.2", "2.2.1-SNAPSHOT")); }