### Question:
WelcomeMsgUtils { public static void displayWelcomeMessage( final int consoleWidth, final PrintWriter writer ) { final String[] lines = { "", "===========================================", "= _ __ _____ ____ _ =", "= | |/ "= | ' /| (___ | | | | | =", "= | < \\___ \\| | | | | =", "= | . \\ ____) | |__| | |____ =", "= |_|\\_\\_____/ \\___\\_\\______| =", "= =", "= Streaming SQL Engine for Apache Kafka® =", "===========================================" }; final String copyrightMsg = "Copyright 2017 Confluent Inc."; final Integer logoWidth = Arrays.stream(lines) .map(String::length) .reduce(0, Math::max); if (consoleWidth < logoWidth) { writer.println("KSQL, " + copyrightMsg); } else { final int paddingChars = (consoleWidth - logoWidth) / 2; final String leftPadding = IntStream.range(0, paddingChars) .mapToObj(idx -> " ") .collect(Collectors.joining()); Arrays.stream(lines) .forEach(line -> writer.println(leftPadding + line)); writer.println(); writer.println(copyrightMsg); } writer.println(); writer.flush(); } private  WelcomeMsgUtils(); static void displayWelcomeMessage(
      final int consoleWidth,
      final PrintWriter writer
  );  }### Answer:
@Test public void shouldOutputLongWelcomeMessageIfConsoleIsWideEnough() { WelcomeMsgUtils.displayWelcomeMessage(80, realPrintWriter); assertThat(stringWriter.toString(), is( " \n" + " ===========================================\n" + " = _ __ _____ ____ _ =\n" + " = | |/ + " = | ' /| (___ | | | | | =\n" + " = | < \\___ \\| | | | | =\n" + " = | . \\ ____) | |__| | |____ =\n" + " = |_|\\_\\_____/ \\___\\_\\______| =\n" + " = =\n" + " = Streaming SQL Engine for Apache Kafka® =\n" + " ===========================================\n" + "\n" + "Copyright 2017 Confluent Inc.\n" + "\n") ); }
@Test public void shouldOutputShortWelcomeMessageIfConsoleNotWideEnough() { WelcomeMsgUtils.displayWelcomeMessage(35, realPrintWriter); assertThat(stringWriter.toString(), is("KSQL, Copyright 2017 Confluent Inc.\n\n")); }
@Test public void shouldFlushWriterWhenOutputtingLongMessage() { mockPrintWriter.flush(); EasyMock.expectLastCall(); EasyMock.replay(mockPrintWriter); WelcomeMsgUtils.displayWelcomeMessage(80, mockPrintWriter); EasyMock.verify(mockPrintWriter); }
@Test public void shouldFlushWriterWhenOutputtingShortMessage() { mockPrintWriter.flush(); EasyMock.expectLastCall(); EasyMock.replay(mockPrintWriter); WelcomeMsgUtils.displayWelcomeMessage(10, mockPrintWriter); EasyMock.verify(mockPrintWriter); }