### Question:
XmlParser { public String readErrorFromResultXml(InputStream errorResultXml, String bookIdentifier) throws IOException { String error = null; XMLInputFactory factory = XMLInputFactory.newInstance(); try { XMLStreamReader xmlStreamReader = factory.createXMLStreamReader(errorResultXml); while (xmlStreamReader.hasNext()) { int event = xmlStreamReader.next(); if (event == XMLStreamConstants.START_ELEMENT) { if (xmlStreamReader.getName().toString().equals("Error")) { error = xmlStreamReader.getElementText(); break; } } } xmlStreamReader.close(); } catch (XMLStreamException e) { throw new IOException(e); } logger.error("Book: " + bookIdentifier + ", Error: " + error); return error; }  String readErrorFromResultXml(InputStream errorResultXml, String bookIdentifier);  }### Answer:
@Test public void shouldParseOutErrorMessage() throws IOException { XmlParser parserSut = new XmlParser(); String errorXml = "<XmlResult><Error>An error has occurred</Error></XmlResult>"; ByteArrayInputStream baos = new ByteArrayInputStream(errorXml.getBytes()); String errorMessage = parserSut.readErrorFromResultXml(baos, "testId"); assertEquals("Message", "An error has occurred", errorMessage); }