-
-
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
002a9a3
commit d44600d
Showing
3 changed files
with
75 additions
and
24 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
43 changes: 43 additions & 0 deletions
43
src/test/java/com/fasterxml/jackson/databind/creators/Creator1476Test.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,43 @@ | ||
package com.fasterxml.jackson.databind.creators; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
public class Creator1476Test extends BaseMapTest | ||
{ | ||
static final class SimplePojo { | ||
private final int intField; | ||
private final String stringField; | ||
|
||
public SimplePojo(@JsonProperty("intField") int intField) { | ||
this(intField, "empty"); | ||
} | ||
|
||
public SimplePojo(@JsonProperty("stringField") String stringField) { | ||
this(-1, stringField); | ||
} | ||
|
||
@JsonCreator | ||
public SimplePojo(@JsonProperty("intField") int intField, @JsonProperty("stringField") String stringField) { | ||
this.intField = intField; | ||
this.stringField = stringField; | ||
} | ||
|
||
public int getIntField() { | ||
return intField; | ||
} | ||
|
||
public String getStringField() { | ||
return stringField; | ||
} | ||
} | ||
|
||
public void testConstructorChoice() throws Exception { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
SimplePojo pojo = mapper.readValue("{ \"intField\": 1, \"stringField\": \"foo\" }", SimplePojo.class); | ||
|
||
assertEquals(1, pojo.getIntField()); | ||
assertEquals("foo", pojo.getStringField()); | ||
} | ||
} |