### Question:
WisitOutputStream extends OutputStream { private void publish(String buffer){ CommandResult out = new CommandResult(myType); out.setContent(buffer); synchronized (lock) { publisher.publish(topic, out.toString()); } } WisitOutputStream(final Publisher publisher, final String topic);  WisitOutputStream(final Publisher publisher, final String topic,OutputType outputType); @Override void write(int i); @Override void write(byte[] b); @Override void write(byte[] buf, int off, int len); OutputType getType();  }### Answer:
@Test public void shouldPublishAResultWhenWritingAResultString(){ String droids = "This is not the test you are looking for."; PrintStream ps = new PrintStream(new WisitOutputStream(mockpub,"default")); ps.print(droids); ps.close(); CommandResult result = new CommandResult(RESULT); result.setContent(droids); verify(mockpub).publish("default", result.toString()); verifyNoMoreInteractions(mockpub); }