Repository: GoogleContainerTools/jib
File: jib-cli/src/test/java/com/google/cloud/tools/jib/cli/JibCliTest.java (Java)

Code before:
  public void testLogTerminatingException() {
    JibCli.logTerminatingException(logger, new IOException("test error message"), false);

    verify(logger)
        .log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
    verifyNoMoreInteractions(logger);
  }

  @Test
  public void testLogTerminatingException_stackTrace() {
    JibCli.logTerminatingException(logger, new IOException("test error message"), true);

    String stackTraceLine =
        "at com.google.cloud.tools.jib.cli.JibCliTest.testLogTerminatingException_stackTrace";
    verify(logger).log(eq(LogEvent.Level.ERROR), contains(stackTraceLine));
    verify(logger)
        .log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
    verifyNoMoreInteractions(logger);
  }

  @Test
  public void testNewUpdateChecker_noUpdateCheck() throws ExecutionException, InterruptedException {
    when(globalConfig.isDisableUpdateCheck()).thenReturn(true);
    Future<Optional<String>> updateChecker =
        JibCli.newUpdateChecker(globalConfig, Verbosity.info, ignored -> {});
    assertThat(updateChecker.get()).isEqualTo(Optional.empty());
  }
}


Review comment (suggestion):
```suggestion
    assertThat(updateChecker.get()).isEmpty();
```

Code after:

  @Mock private JibContainer mockJibContainer;

  @Test
  public void testConfigureHttpLogging() {
    Logger logger = JibCli.configureHttpLogging(Level.ALL);
    assertThat(logger.getName()).isEqualTo("com.google.api.client.http.HttpTransport");
    assertThat(logger.getLevel()).isEqualTo(Level.ALL);

    assertThat(logger.getHandlers()).hasLength(1);
    Handler handler = logger.getHandlers()[0];
    assertThat(handler).isInstanceOf(ConsoleHandler.class);
    assertThat(handler.getLevel()).isEqualTo(Level.ALL);
  }

  @Test
  public void testLogTerminatingException() {
    JibCli.logTerminatingException(logger, new IOException("test error message"), false);

    verify(logger)
        .log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
    verifyNoMoreInteractions(logger);
  }

  @Test
  public void testLogTerminatingException_stackTrace() {
    JibCli.logTerminatingException(logger, new IOException("test error message"), true);

    String stackTraceLine =
        "at com.google.cloud.tools.jib.cli.JibCliTest.testLogTerminatingException_stackTrace";
    verify(logger).log(eq(LogEvent.Level.ERROR), contains(stackTraceLine));
    verify(logger)
        .log(LogEvent.Level.ERROR, "\u001B[31;1mjava.io.IOException: test error message\u001B[0m");
    verifyNoMoreInteractions(logger);
  }

  @Test
  public void testNewUpdateChecker_noUpdateCheck() throws ExecutionException, InterruptedException {
    when(globalConfig.isDisableUpdateCheck()).thenReturn(true);
    Future<Optional<String>> updateChecker =
        JibCli.newUpdateChecker(globalConfig, Verbosity.info, ignored -> {});
    assertThat(updateChecker.get()).isEmpty();
  }

  @Test
  public void testFinishUpdateChecker_correctMessageLogged() {
    Future<Optional<String>> updateCheckFuture = Futures.immediateFuture(Optional.of("2.0.0"));
    JibCli.finishUpdateChecker(logger, updateCheckFuture);
    verify(logger)
        .log(
            eq(LogEvent.Level.LIFECYCLE),