use of kotlin.ranges.IntRange in project spring-framework by spring-projects.
the class Jackson2ObjectMapperBuilderTests method wellKnownModules.
@Test
void wellKnownModules() throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
Path file = Paths.get("foo");
assertThat(new String(objectMapper.writeValueAsBytes(file), "UTF-8").endsWith("foo\"")).isTrue();
Optional<String> optional = Optional.of("test");
assertThat(new String(objectMapper.writeValueAsBytes(optional), "UTF-8")).isEqualTo("\"test\"");
// Kotlin module
IntRange range = new IntRange(1, 3);
assertThat(new String(objectMapper.writeValueAsBytes(range), "UTF-8")).isEqualTo("{\"start\":1,\"end\":3}");
}
Aggregations