### Question:
ConnectorUtils { static String readConfig(InputStream inputStream) throws IOException { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { pw.println(line); } pw.close(); } catch (IOException e) { LOGGER.error("IOException reading mappings :: {}", e.getMessage()); throw (e); } return sw.toString(); }    }### Answer:
@Test(expected = IOException.class) public void readConfigThrowsException_whenStreamBreaks() throws IOException { InputStream fileStream = mock(InputStream.class); when(fileStream.read(any(), anyInt(), anyInt())).thenThrow(new IOException("Error")); ConnectorUtils.readConfig(fileStream); }
@Test public void readConfigReturnsString_whenStreamExists() throws IOException { final String content = "content,\nmore content"; InputStream stringStream = new ByteArrayInputStream(content.getBytes()); final String output = ConnectorUtils.readConfig(stringStream); assertThat(output).isEqualToIgnoringWhitespace(content); }