### Question:
UpdateChecker { public static Optional<String> finishUpdateCheck(Future<Optional<String>> updateMessageFuture) { if (updateMessageFuture.isDone()) { try { return updateMessageFuture.get(); } catch (InterruptedException | ExecutionException ignored) { } } updateMessageFuture.cancel(true); return Optional.empty(); } private  UpdateChecker(); static Future<Optional<String>> checkForUpdate(
      ExecutorService executorService,
      Consumer<LogEvent> log,
      String versionUrl,
      String toolName,
      String toolVersion); static Optional<String> finishUpdateCheck(Future<Optional<String>> updateMessageFuture);  }### Answer:
@Test public void testFinishUpdateCheck_success() { Future<Optional<String>> updateCheckFuture = Futures.immediateFuture(Optional.of("Hello")); Optional<String> result = UpdateChecker.finishUpdateCheck(updateCheckFuture); Assert.assertTrue(result.isPresent()); Assert.assertEquals("Hello", result.get()); }
@Test public void testFinishUpdateCheck_notDone() { @SuppressWarnings("unchecked") Future<Optional<String>> updateCheckFuture = Mockito.mock(Future.class); Mockito.when(updateCheckFuture.isDone()).thenReturn(false); Optional<String> result = UpdateChecker.finishUpdateCheck(updateCheckFuture); Assert.assertFalse(result.isPresent()); }