-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6188e2d
commit 73e0067
Showing
2 changed files
with
43 additions
and
49 deletions.
There are no files selected for viewing
36 changes: 0 additions & 36 deletions
36
src/test/java/com/fasterxml/jackson/databind/deser/creators/jdk8/Person.java
This file was deleted.
Oops, something went wrong.
56 changes: 43 additions & 13 deletions
56
src/test/java/com/fasterxml/jackson/databind/deser/creators/jdk8/PersonTest.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 |
---|---|---|
@@ -1,26 +1,56 @@ | ||
package com.fasterxml.jackson.databind.deser.creators.jdk8; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.Test; | ||
|
||
public class PersonTest | ||
public class PersonTest extends BaseMapTest | ||
{ | ||
@Test | ||
public void shouldBeAbleToDeserializePerson() throws IOException | ||
static class Person { | ||
|
||
// mandatory fields | ||
private final String name; | ||
private final String surname; | ||
|
||
// optional fields | ||
private String nickname; | ||
|
||
// 29-Jan-2018, tatu: Should (apparently?! nice) work without annotation, as long as | ||
// parameter names exist | ||
// @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) | ||
public Person(String name, String surname) { | ||
|
||
this.name = name; | ||
this.surname = surname; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getSurname() { | ||
return surname; | ||
} | ||
|
||
public String getNickname() { | ||
|
||
return nickname; | ||
} | ||
|
||
public void setNickname(String nickname) { | ||
|
||
this.nickname = nickname; | ||
} | ||
} | ||
public void testPersonDeserialization() throws IOException | ||
{ | ||
final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
// when | ||
Person actual = mapper.readValue("{\"name\":\"joe\",\"surname\":\"smith\",\"nickname\":\"joey\"}", Person.class); | ||
|
||
// then | ||
Person expected = new Person("joe", "smith"); | ||
expected.setNickname("joey"); | ||
then(actual).isEqualToComparingFieldByField(expected); | ||
|
||
assertEquals("joe", actual.getName()); | ||
assertEquals("smith", actual.getSurname()); | ||
assertEquals("joey", actual.getNickname()); | ||
} | ||
} |