Example #1
0
  @Test
  public void shouldDisplayFormattedTimeWhenFormattedTimeIsAnEmptyString() {

    createBooksPrintStreamDateTimeAndLibrary();
    when(dateTimeFormatter.print(time)).thenReturn("");
    library.welcome(time);
    verify(printStream).println(contains("The current time is "));
  }
Example #2
0
 // This one is done for you
 @Test
 public void shouldWelcomeUser() {
   // We don't need to mock DateTime because it is a value object
   // We can't mock it because it is a final class
   createBooksPrintStreamDateTimeAndLibrary();
   library.welcome(time);
   verify(printStream).println(contains("Welcome"));
 }