-
Notifications
You must be signed in to change notification settings - Fork 18
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
8c19755
commit 75864ba
Showing
4 changed files
with
85 additions
and
15 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
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
35 changes: 35 additions & 0 deletions
35
jsr-353/src/test/java/com/fasterxml/jackson/datatype/jsr353/DeserViaCreatorTest.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,35 @@ | ||
package com.fasterxml.jackson.datatype.jsr353; | ||
|
||
import javax.json.JsonObject; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class DeserViaCreatorTest extends TestBase | ||
{ | ||
static class Pojo { | ||
String text; | ||
JsonObject object; | ||
|
||
@JsonCreator | ||
public Pojo(@JsonProperty("s") String s, @JsonProperty("o") JsonObject o) { | ||
text = s; | ||
object = o; | ||
} | ||
} | ||
|
||
public void testCreatorDeser() throws Exception | ||
{ | ||
final ObjectMapper mapper = sharedMapper(); | ||
Pojo p = mapper.readerFor(Pojo.class) | ||
.readValue( "{\"s\": \"String\", \"o\": { \"a\": 1, \"b\": \"2\" } }"); | ||
assertNotNull(p); | ||
assertNotNull(p.object); | ||
|
||
p = mapper.readerFor(Pojo.class).readValue("{\"s\": \"String\"}"); | ||
assertNotNull(p); | ||
// has to remain `null` as JsonValue.NULL is not JsonObject | ||
assertNull(p.object); | ||
} | ||
} |
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