### Question:
ErrorMessage { public String getMessage() { return message; } ErrorMessage();  ErrorMessage(final Throwable t); String getException(); void setException(final String exception); String getMessage(); void setMessage(final String message); JacksonRepresentation<ErrorMessage> toEntity();  }### Answer:
@Test public void should_encode_message_when_using_constructor() throws Exception { ErrorMessage errorMessage = new ErrorMessage(new RuntimeException("<script>alert('bad')</script>")); assertThat(errorMessage.getMessage()).isEqualTo("\\u003cscript\\u003ealert(\\u0027bad\\u0027)\\u003c\\/script\\u003e"); }