-
-
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
9736c47
commit 3749d7c
Showing
7 changed files
with
192 additions
and
52 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
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
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
60 changes: 60 additions & 0 deletions
60
src/test/java/com/fasterxml/jackson/databind/format/BooleanFormatTest.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,60 @@ | ||
package com.fasterxml.jackson.databind.format; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
// [databind#1480] | ||
public class BooleanFormatTest extends BaseMapTest | ||
{ | ||
@JsonPropertyOrder({ "b1", "b2", "b3" }) | ||
static class BeanWithBoolean | ||
{ | ||
@JsonFormat(shape=JsonFormat.Shape.NUMBER) | ||
public boolean b1; | ||
|
||
@JsonFormat(shape=JsonFormat.Shape.NUMBER) | ||
public Boolean b2; | ||
|
||
public boolean b3; | ||
|
||
public BeanWithBoolean() { } | ||
public BeanWithBoolean(boolean b1, Boolean b2, boolean b3) { | ||
this.b1 = b1; | ||
this.b2 = b2; | ||
this.b3 = b3; | ||
} | ||
} | ||
|
||
static class AltBoolean extends BooleanWrapper | ||
{ | ||
public AltBoolean() { } | ||
public AltBoolean(Boolean b) { super(b); } | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final static ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
public void testShapeViaDefaults() throws Exception | ||
{ | ||
assertEquals(aposToQuotes("{'b':true}"), | ||
MAPPER.writeValueAsString(new BooleanWrapper(true))); | ||
ObjectMapper m = new ObjectMapper(); | ||
m.configOverride(Boolean.class) | ||
.setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.NUMBER)); | ||
assertEquals(aposToQuotes("{'b':1}"), | ||
m.writeValueAsString(new BooleanWrapper(true))); | ||
} | ||
|
||
public void testShapeOnProperty() throws Exception | ||
{ | ||
assertEquals(aposToQuotes("{'b1':1,'b2':0,'b3':true}"), | ||
MAPPER.writeValueAsString(new BeanWithBoolean(true, false, true))); | ||
} | ||
} |
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