JsonConverter implements Serializable { public String writeValueAsString(Object value) { try { return jsonMapper.writeValueAsString(value); } catch (JsonProcessingException e) { throw new UncheckedIOException(e); } } JsonConverter(ObjectMapper jsonMapper); T readValue(String src, Class<T> valueType); T readValue(InputStream src, Class<T> valueType); T readValue(String src, TypeReference<T> valueTypeRef); T readValue(InputStream src, TypeReference<T> valueTypeRef); byte[] writeValueAsBytes(Object value); String writeValueAsString(Object value);  }
@Test void writeValueAsString_test() { ConverterTestDto converterTestDto = new ConverterTestDto(); converterTestDto.setValue("dummy"); String str = jsonConverter.writeValueAsString(converterTestDto); assertThat(str).isEqualTo("{\"value\":\"dummy\"}"); }
@Test void writeValueAsString_with_invalid_dto_test() { ConverterTestInvalidDto converterTestInvalidDto = new ConverterTestInvalidDto(); converterTestInvalidDto.setValue(new Object()); assertThrows(UncheckedIOException.class, () -> jsonConverter.writeValueAsString(converterTestInvalidDto) ); }