@Test public void testSerializationDeserialization() throws IOException { ErrorDetail detail = new AdapterUnauthorizedErrorDetail("Unauthorized adapter access", "vdr", "Basic"); HttpError error = new HttpError(401, "Unauthorized", detail); String jsonError = mapper.writeValueAsString(error); System.out.println(jsonError); Assert.assertTrue( "Serialization should be successful", jsonError.contains("Unauthorized") && jsonError.contains("Basic")); HttpError readError = mapper.readValue(jsonError, HttpError.class); Assert.assertEquals( "Deserialization of the HttpError should be successful", "Unauthorized", readError.getMessage()); Assert.assertEquals( "Deserialization of the AdapterUnauthorizedErrorDetail should be successful", "Basic", ((AdapterUnauthorizedErrorDetail) readError.getDetails().get(0)).getAuthorization()); }