VersionDetection implements SimplePayload { @Override public void run() { final Either<Throwable, Response> result = metadata.get(); if (result.isLeft()) { LOGGER.debug("Failed retrieving RoboZonky version information.", result.getLeft()); return; } final Response currentResponse = result.get(); processVersion(currentResponse.getMoreRecentStableVersion(), lastKnownStableVersion, "Latest stable version unchanged: {}.", "You are using an obsolete version of RoboZonky. Please upgrade to {}.", EventFactory::roboZonkyUpdateDetected); processVersion(currentResponse.getMoreRecentExperimentalVersion(), lastKnownExperimentalVersion, "Latest experimental version unchanged: {}.", "Experimental version of RoboZonky is available. Try {} at your own risk.", EventFactory::roboZonkyExperimentalUpdateDetected); } VersionDetection();   VersionDetection(final Supplier<Either<Throwable, Response>> metadata); @Override void run();  }
@Test void live() { final SimplePayload livePayload = new VersionDetection(); livePayload.run(); assertThat(getEventsRequested()).isEmpty(); }
@Test void noEventsOnFailure() { when(metadata.get()).thenReturn(Either.left(new IllegalStateException())); payload.run(); assertThat(getEventsRequested()).isEmpty(); }
@Test void noNewerVersions() { when(metadata.get()).thenReturn(Either.right(Response.noMoreRecentVersion())); payload.run(); assertThat(getEventsRequested()).isEmpty(); }