Search in sources :

Example 1 with IntRange

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}");
}
Also used : Path(java.nio.file.Path) IntRange(kotlin.ranges.IntRange) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Path (java.nio.file.Path)1 IntRange (kotlin.ranges.IntRange)1 Test (org.junit.jupiter.api.Test)1