-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from mincong-h/readme
Update serialization/deserialization in README
- Loading branch information
Showing
2 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/java/io/vavr/jackson/datatype/docs/ReadmeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.vavr.jackson.datatype.docs; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.vavr.collection.List; | ||
import io.vavr.jackson.datatype.BaseTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class ReadmeTest extends BaseTest { | ||
|
||
@Test | ||
void testDeser() throws Exception { | ||
ObjectMapper mapper = mapper(); | ||
|
||
// readme: Serialization/deserialization | ||
String json = mapper.writeValueAsString(List.of(1)); | ||
List<Integer> restored = mapper.readValue(json, new TypeReference<List<Integer>>() {}); | ||
// end of readme | ||
|
||
assertEquals("[1]", json); | ||
assertEquals(List.of(1), restored); | ||
assertEquals("List(1)", restored.toString()); | ||
} | ||
} |