### Question:
Printer { public String print(Object input) throws RuntimeException { for (PrinterPreProcessor preProcessor : preProcessors) { input = preProcessor.process(input); } String string = serialize(input); for (PrinterPostProcessor postProcessor : postProcessors) { string = postProcessor.process(string); } return string; }  boolean supports(Class<?> clazz); Printer addPreProcessor(PrinterPreProcessor preProcessor); Printer addPostProcessor(PrinterPostProcessor postProcessor); String print(Object input);  }### Answer:
@Test public void print() { Printer printer = new NoOpPrinter(); PrinterPreProcessor preProcessor = mock(PrinterPreProcessor.class); when(preProcessor.process(printer)).thenReturn(printer); PrinterPreProcessor preProcessor1 = mock(PrinterPreProcessor.class); when(preProcessor1.process(printer)).thenReturn(printer); PrinterPostProcessor postProcessor = mock(PrinterPostProcessor.class); when(postProcessor.process("")).thenReturn(""); PrinterPostProcessor postProcessor1 = mock(PrinterPostProcessor.class); when(postProcessor1.process("")).thenReturn(""); printer.addPreProcessor(preProcessor).addPreProcessor(preProcessor1); printer.addPostProcessor(postProcessor).addPostProcessor(postProcessor1); Object input = new Object(); String string = printer.print(input); verify(preProcessor).process(any()); verify(preProcessor1).process(any()); verify(postProcessor).process(any()); verify(postProcessor1).process(any()); assertThat(string, is("")); }