@Test public void testReadErrorsMessageHeaderFromString() { InputStream inputJsonStream = getClass().getClassLoader().getResourceAsStream("errors/serialization/errorsmessageheader.json"); String inputJson = null; try { inputJson = ReadFile.getFileContents(inputJsonStream).toString(); } catch (IOException e) { e.printStackTrace(); } ErrorsMessageHeader actualErrorsMessageHeader = new ErrorsMessageHeaderReader().readObject(inputJson); List<ErrorMessageHeader> expectedErrorMessageHeaders = new ArrayList<>(); expectedErrorMessageHeaders.add(new ErrorMessageHeader( "microservice-1-uri", 1456485443905L, 404, "Service 1 unavailable")); expectedErrorMessageHeaders.add(new ErrorMessageHeader( "microservice-2-uri", 1456485443906L, 405, "Service 2 unavailable")); expectedErrorMessageHeaders.add(new ErrorMessageHeader( "microservice-3-uri", 1456485443907L, 406, "Service 3 unavailable")); expectedErrorMessageHeaders.add(new ErrorMessageHeader( "microservice-4-uri", 1456485443908L, 407, "Service 4 unavailable")); ErrorsMessageHeader expectedErrorsMessageHeader = new ErrorsMessageHeader(expectedErrorMessageHeaders); Assert.assertTrue( "Unexpected error message header", expectedErrorsMessageHeader .getErrorMessageHeaders() .containsAll(actualErrorsMessageHeader.getErrorMessageHeaders())); }
@Override public ErrorsMessageHeader readObject(InputStream inputStream) throws ErrorMessageHeaderSerializationException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(inputStream, ErrorsMessageHeader.class); } catch (Exception e) { String message = "Could not deserialize input into a List of " + ErrorMessageHeader.class.getName() + " object. Cause: " + e.getMessage(); throw new ErrorMessageHeaderSerializationException(message, e); } }
ErrorsMessageHeaderReader implements SerializationReader<ErrorsMessageHeader> { @Override public ErrorsMessageHeader readObject(InputStream inputStream) throws ErrorMessageHeaderSerializationException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(inputStream, ErrorsMessageHeader.class); } catch (Exception e) { String message = "Could not deserialize input into a List of " + ErrorMessageHeader.class.getName() + " object. Cause: " + e.getMessage(); throw new ErrorMessageHeaderSerializationException(message, e); } } }
ErrorsMessageHeaderReader implements SerializationReader<ErrorsMessageHeader> { @Override public ErrorsMessageHeader readObject(InputStream inputStream) throws ErrorMessageHeaderSerializationException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(inputStream, ErrorsMessageHeader.class); } catch (Exception e) { String message = "Could not deserialize input into a List of " + ErrorMessageHeader.class.getName() + " object. Cause: " + e.getMessage(); throw new ErrorMessageHeaderSerializationException(message, e); } }  }
ErrorsMessageHeaderReader implements SerializationReader<ErrorsMessageHeader> { @Override public ErrorsMessageHeader readObject(InputStream inputStream) throws ErrorMessageHeaderSerializationException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(inputStream, ErrorsMessageHeader.class); } catch (Exception e) { String message = "Could not deserialize input into a List of " + ErrorMessageHeader.class.getName() + " object. Cause: " + e.getMessage(); throw new ErrorMessageHeaderSerializationException(message, e); } }  @Override ErrorsMessageHeader readObject(InputStream inputStream); @Override ErrorsMessageHeader readObject(Reader reader); @NoJavadoc ErrorsMessageHeader readObject(String content); }
ErrorsMessageHeaderReader implements SerializationReader<ErrorsMessageHeader> { @Override public ErrorsMessageHeader readObject(InputStream inputStream) throws ErrorMessageHeaderSerializationException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(inputStream, ErrorsMessageHeader.class); } catch (Exception e) { String message = "Could not deserialize input into a List of " + ErrorMessageHeader.class.getName() + " object. Cause: " + e.getMessage(); throw new ErrorMessageHeaderSerializationException(message, e); } }  @Override ErrorsMessageHeader readObject(InputStream inputStream); @Override ErrorsMessageHeader readObject(Reader reader); @NoJavadoc ErrorsMessageHeader readObject(String content);  }