CommandLineIO { public List<String> getErrorStringList() { String errorString = errorStream.toString(); String[] errorStringArray = errorString.split("\n"); return Arrays.asList(errorStringArray); } CommandLineIO(ByteArrayOutputStream outputStream, ByteArrayOutputStream errorStream);  CommandLineIO(ByteArrayOutputStream outputStream, ByteArrayOutputStream errorStream, CommandLineResultHandler resultHandler); List<String> getOutputStringList(); List<String> getErrorStringList(); ByteArrayOutputStream getOutputStream(); ByteArrayOutputStream getErrorStream(); CommandLineResultHandler getResultHandler();  }
@Test public void canGetErrorStringList() throws Exception { when(mockErrorStream.toString()).thenReturn("ERROR: user \"test111\" already exists\n" + "Connection to auth closed."); commandLineIO = new CommandLineIO(mockOutputStream, mockErrorStream); List<String> errorStringList = commandLineIO.getErrorStringList(); assertThat(errorStringList.size(), equalTo(2)); assertThat(errorStringList.get(0), equalTo("ERROR: user \"test111\" already exists")); assertThat(errorStringList.get(1), equalTo("Connection to auth closed.")); }