JacksonJsonSerializer implements JsonSerializer<T> { @Override public String apply(final T t) { try { return mapper.writeValueAsString(t); } catch (final JsonProcessingException e) { throw new JacksonConversionException("Could not serialize entity=" + t.getClass(), e); } }  @Override String apply(final T t);  }
@Test(expected=JacksonConversionException.class) public void shouldThrow() throws JsonProcessingException { when(mapper.writeValueAsString(entity)).thenThrow(mock(JsonProcessingException.class)); serializer.apply(entity); }