VersionLookup { public Version lookUpLatestVersion() { report.lookingUpLatestAvailableVersion(); try { Version latestVersion = strategy.findLatestUpdate().getVersion(); report.latestAvailableVersionIs(latestVersion); return latestVersion; } catch (Exception e) { report.versionLookupFailed(e); return VersionFinder.BASE_VERSION; } } VersionLookup(LookupStrategy strategy, ProgressReport report); Version lookUpLatestVersion();  }
@Test public void reportsVersionLookup() throws Exception { versionLookup.lookUpLatestVersion(); verify(report).lookingUpLatestAvailableVersion(); }
@Test public void reportsLatestVersion() throws Exception { NumericVersion value = new NumericVersion(3, 2, 1); when(strategy.findLatestUpdate()).thenReturn(new UpdateDescription(value)); versionLookup.lookUpLatestVersion(); verify(report).latestAvailableVersionIs(value); }
@Test public void reportsLookupFailure() throws Exception { RuntimeException exception = new RuntimeException(); when(strategy.findLatestUpdate()).thenThrow(exception); versionLookup.lookUpLatestVersion(); verify(report).versionLookupFailed(exception); }