@Test public void testFindNewUpdateIfAvailable() throws Exception { NewVersionCheckerGitHubImpl f = new NewVersionCheckerGitHubImpl(); f.setConfiguredVersion("0.0.0.1"); UpdatePackageInfo result = f.findNewUpdateIfAvailable(); assertNotNull(result); }
@Override public UpdatePackageInfo findNewUpdateIfAvailable() throws GenericException { try { String currentVersion = getCurrentVersion(); if (VERSION_UNRESOLVED.equals(currentVersion) || DEV_VERSION.equals(currentVersion)) { log.info("DEV mode detected -- not spaming github with updates check"); return null; } String json = HttpTools.httpGet(latestVersionUrl, headers); LatestRelease latestRelease = gson.fromJson(json, LatestRelease.class); if (latestRelease.isDraft() || latestRelease.isPrerelease()) { log.info("Ignoring draft or prerelease release " + latestRelease.getTagName()); return null; } if (CollectionUtils.isEmpty(latestRelease.getAssets())) { log.info("GitHub API returned empty array of assets for release " + latestRelease.getTagName()); return null; } if (compareVersions(currentVersion, latestRelease.getTagName()) >= 0) { return null; } return buildUpdatePackageInfo(latestRelease); } catch (Throwable t) { throw new GenericException("error.failedToCheckForNewVersions", t); } }
NewVersionCheckerGitHubImpl implements NewVersionChecker { @Override public UpdatePackageInfo findNewUpdateIfAvailable() throws GenericException { try { String currentVersion = getCurrentVersion(); if (VERSION_UNRESOLVED.equals(currentVersion) || DEV_VERSION.equals(currentVersion)) { log.info("DEV mode detected -- not spaming github with updates check"); return null; } String json = HttpTools.httpGet(latestVersionUrl, headers); LatestRelease latestRelease = gson.fromJson(json, LatestRelease.class); if (latestRelease.isDraft() || latestRelease.isPrerelease()) { log.info("Ignoring draft or prerelease release " + latestRelease.getTagName()); return null; } if (CollectionUtils.isEmpty(latestRelease.getAssets())) { log.info("GitHub API returned empty array of assets for release " + latestRelease.getTagName()); return null; } if (compareVersions(currentVersion, latestRelease.getTagName()) >= 0) { return null; } return buildUpdatePackageInfo(latestRelease); } catch (Throwable t) { throw new GenericException("error.failedToCheckForNewVersions", t); } } }
NewVersionCheckerGitHubImpl implements NewVersionChecker { @Override public UpdatePackageInfo findNewUpdateIfAvailable() throws GenericException { try { String currentVersion = getCurrentVersion(); if (VERSION_UNRESOLVED.equals(currentVersion) || DEV_VERSION.equals(currentVersion)) { log.info("DEV mode detected -- not spaming github with updates check"); return null; } String json = HttpTools.httpGet(latestVersionUrl, headers); LatestRelease latestRelease = gson.fromJson(json, LatestRelease.class); if (latestRelease.isDraft() || latestRelease.isPrerelease()) { log.info("Ignoring draft or prerelease release " + latestRelease.getTagName()); return null; } if (CollectionUtils.isEmpty(latestRelease.getAssets())) { log.info("GitHub API returned empty array of assets for release " + latestRelease.getTagName()); return null; } if (compareVersions(currentVersion, latestRelease.getTagName()) >= 0) { return null; } return buildUpdatePackageInfo(latestRelease); } catch (Throwable t) { throw new GenericException("error.failedToCheckForNewVersions", t); } }  }
NewVersionCheckerGitHubImpl implements NewVersionChecker { @Override public UpdatePackageInfo findNewUpdateIfAvailable() throws GenericException { try { String currentVersion = getCurrentVersion(); if (VERSION_UNRESOLVED.equals(currentVersion) || DEV_VERSION.equals(currentVersion)) { log.info("DEV mode detected -- not spaming github with updates check"); return null; } String json = HttpTools.httpGet(latestVersionUrl, headers); LatestRelease latestRelease = gson.fromJson(json, LatestRelease.class); if (latestRelease.isDraft() || latestRelease.isPrerelease()) { log.info("Ignoring draft or prerelease release " + latestRelease.getTagName()); return null; } if (CollectionUtils.isEmpty(latestRelease.getAssets())) { log.info("GitHub API returned empty array of assets for release " + latestRelease.getTagName()); return null; } if (compareVersions(currentVersion, latestRelease.getTagName()) >= 0) { return null; } return buildUpdatePackageInfo(latestRelease); } catch (Throwable t) { throw new GenericException("error.failedToCheckForNewVersions", t); } }  @Override UpdatePackageInfo findNewUpdateIfAvailable(); @Override String getCurrentVersion(); static String getVerisonsInfo(); String getConfiguredVersion(); void setConfiguredVersion(String version); }
NewVersionCheckerGitHubImpl implements NewVersionChecker { @Override public UpdatePackageInfo findNewUpdateIfAvailable() throws GenericException { try { String currentVersion = getCurrentVersion(); if (VERSION_UNRESOLVED.equals(currentVersion) || DEV_VERSION.equals(currentVersion)) { log.info("DEV mode detected -- not spaming github with updates check"); return null; } String json = HttpTools.httpGet(latestVersionUrl, headers); LatestRelease latestRelease = gson.fromJson(json, LatestRelease.class); if (latestRelease.isDraft() || latestRelease.isPrerelease()) { log.info("Ignoring draft or prerelease release " + latestRelease.getTagName()); return null; } if (CollectionUtils.isEmpty(latestRelease.getAssets())) { log.info("GitHub API returned empty array of assets for release " + latestRelease.getTagName()); return null; } if (compareVersions(currentVersion, latestRelease.getTagName()) >= 0) { return null; } return buildUpdatePackageInfo(latestRelease); } catch (Throwable t) { throw new GenericException("error.failedToCheckForNewVersions", t); } }  @Override UpdatePackageInfo findNewUpdateIfAvailable(); @Override String getCurrentVersion(); static String getVerisonsInfo(); String getConfiguredVersion(); void setConfiguredVersion(String version); static final String DEV_VERSION; }