### Question:
BuildHttpMessageConverter implements HttpMessageConverter<Build> { @Override public Build read(Class<? extends Build> clazz, HttpInputMessage inputMessage) throws IOException { XmlResponse xml = new XmlResponse(inputMessage.getBody()); Build build = new Build(); build.setNumber(xml.evaluateAsLong("url")); build.setDuration(xml.evaluateAsLong("building"); if (building) { build.setStatus(Build.Status.PENDING); } else { build.setStatus(Build.Status.valueOf(xml.evaluateAsString("/*/result"))); } return build; }  @Override boolean canRead(Class<?> clazz); @Override boolean canWrite(Class<?> clazz); @Override Build read(Class<? extends Build> clazz, HttpInputMessage inputMessage); @Override void write(Build t, String contentType, HttpOutputMessage outputMessage);  }### Answer:
@Test public void read_WithSuccessfulBuild() throws Exception { HttpInputMessage inputMessage = new MockHttpInputMessage("" + "<freeStyleBuild>" + "<building>false</building>" + "<duration>1450</duration>" + "<number>6</number>" + "<result>SUCCESS</result>" + "<url>http: + "</freeStyleBuild>" ); Build build = converter.read(Build.class, inputMessage); assertEquals(new Long(6), build.getNumber()); assertEquals(Build.Status.SUCCESS, build.getStatus()); assertEquals(new Long(1450), build.getDuration()); assertEquals("http: }
@Test public void read_WithPendingBuild() throws Exception { HttpInputMessage inputMessage = new MockHttpInputMessage("" + "<freeStyleBuild>" + "<building>true</building>" + "<duration>150</duration>" + "<number>45</number>" + "<url>http: + "</freeStyleBuild>" ); Build build = converter.read(Build.class, inputMessage); assertEquals(new Long(45), build.getNumber()); assertEquals(Build.Status.PENDING, build.getStatus()); assertEquals(new Long(150), build.getDuration()); assertEquals("http: }