### Question:
JacksonJsonMessageSerializer extends StdScalarSerializer<Message> { @Override public void serialize(final Message value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException { jgen.writeRaw(value.getFormattedMessage()); } JacksonJsonMessageSerializer(); @Override void serialize(final Message value, final JsonGenerator jgen, final SerializerProvider provider);  }### Answer:
@Test public void serializerUsesFormatedMesage() throws IOException { JsonSerializer<Message> serializer = new JacksonJsonMessageSerializer(); Message message = mock(Message.class); serializer.serialize(message, mock(JsonGenerator.class), mock(SerializerProvider.class)); verify(message).getFormattedMessage(); }
@Test public void serializerWritesRawValue() throws IOException { JsonSerializer<Message> serializer = new JacksonJsonMessageSerializer(); Message message = mock(Message.class); String expectedValue = UUID.randomUUID().toString(); when(message.getFormattedMessage()).thenReturn(expectedValue); JsonGenerator jsonGenerator = mock(JsonGenerator.class); serializer.serialize(message, jsonGenerator, mock(SerializerProvider.class)); verify(jsonGenerator).writeRaw(eq(expectedValue)); }