### Question:
MarkdownPrinter { public void print(InputStream stream) { System.out.print("Input markdown: "); try { String markdown = StreamUtils.copyToString(stream, StandardCharsets.UTF_8); String html = this.renderer.render(markdown); System.out.println(html); } catch (IOException e) { throw new UncheckedIOException(e); } } @Autowired  MarkdownPrinter(MarkdownRenderer renderer); void print(InputStream stream);  }### Answer:
@Test void print(CapturedOutput capture ) { MarkdownRenderer markdownRenderer = Mockito.mock(MarkdownRenderer.class); given(markdownRenderer.render(anyString())).willReturn("<p>Markdown!</p>"); MarkdownPrinter printer = new MarkdownPrinter(markdownRenderer); InputStream stream = new ByteArrayInputStream( "Markdown!".getBytes(StandardCharsets.UTF_8)); printer.print(stream); assertThat(capture.toString()).contains("Input markdown:"); assertThat(capture.toString()).contains("<p>Markdown!</p>"); }