ElmTransport { public String sendDataAndReadResponse(String data) { sendData(data); return readData(); } ElmTransport(InputStream inputStream, OutputStream outputStream); String sendDataAndReadResponse(String data); void sendData(String data); String readData();  }
@Test public void testSendDataAndReadResponse() throws Exception { String expectedData = getRandomStreamData(); String expectedResponseData = getRandomStreamData(); String expectedResponseStreamData = " " + expectedResponseData + ">"; when(isMock.read()).thenAnswer(new InputStreamAnswer(expectedResponseStreamData)); String readData = sut.sendDataAndReadResponse(expectedData); InOrder inOrder = inOrder(isMock, osMock); inOrder.verify(osMock).write(expectedData.getBytes()); inOrder.verify(osMock).flush(); inOrder.verify(isMock, atLeastOnce()).read(); assertThat(readData).isEqualTo(expectedResponseData); }