UrlUpdatesCheckProvider implements UpdatesInfoProvider { @Override public VersionInfo getLatestStableVersion(UpdatesInfoContext context) throws IOException { HttpClient client = httpSettings.createHttpClientBuilder().build(); HttpGet get = new HttpGet(MessageFormat.format(updatesCheckUrlValue.get(), context.getCurrentVersion())); logger.debug("Calling '{}' to get updates info for: {}", get, context); HttpResponse response = client.execute(get); JsonResponseWrapper wrapper = objectMapper.readValue(response.getEntity().getContent(), JsonResponseWrapper.class); return wrapper.getStable(); }  @Override VersionInfo getLatestStableVersion(UpdatesInfoContext context); static final String PROP_LOGSNIFFER_UPDATES_CHECK_URL; }
@Test public void testValid() throws IOException { stubFor(get(urlEqualTo("/versionCheck.php?currentVersion=1.2.3")) .willReturn(aResponse().withStatus(201).withHeader("Content-Type", "application/json").withBody( "{ stable: { version: \"1.5.3\", features: true, bugfixes: true, security: false } }"))); VersionInfo version = provider.getLatestStableVersion(new UpdatesInfoContext() { @Override public String getCurrentVersion() { return "1.2.3"; } }); Assert.assertEquals("1.5.3", version.getName()); Assert.assertTrue(version.isBugfixes()); Assert.assertTrue(version.isFeatures()); Assert.assertFalse(version.isSecurity()); }
@Test(expected = IOException.class) public void testIOE() throws IOException { provider.getLatestStableVersion(Mockito.mock(UpdatesInfoContext.class)); }