### Question:
ErrorMap { public static String from(String rawMsg) { if (rawMsg.matches("^\\s*\\<.*")) { return parseWith(rawMsg, new XmlMapper()); } if (rawMsg.matches("^\\s*\\{.*")) { return parseWith(rawMsg, new ObjectMapper()); } return rawMsg; } private  ErrorMap(); static String from(String rawMsg);  }### Answer:
@Test public void testUnmarshalXML() { String rawMsg = read("/HttpClientErrorException.xml"); assertThat(ErrorMap.from(rawMsg)).isEqualTo("Desktop applications only support the oauth_callback value 'oob'"); }
@Test public void testUnmarshalJSON() { String rawMsg = read("/HttpClientErrorException.json"); assertThat(ErrorMap.from(rawMsg)).isEqualTo("Could not authenticate you."); }
@Test public void testUnmarshalJSONVaryingFormats() { assertThat(ErrorMap.from("{\"error\": \"some error\"}")).isEqualTo("some error"); assertThat(ErrorMap.from("{\"message\": \"some message\"}")).isEqualTo("some message"); }
@Test public void testUnmarshalImpossible() { String rawMsg = "This is just some other error format"; assertThat(ErrorMap.from(rawMsg)).isEqualTo(rawMsg); }