-
-
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
e03eaf0
commit ae77a0c
Showing
5 changed files
with
141 additions
and
38 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
102 changes: 102 additions & 0 deletions
102
src/test/java/com/fasterxml/jackson/databind/ser/filter/JsonValueIgnore3647Test.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,102 @@ | ||
package com.fasterxml.jackson.databind.ser.filter; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
// [databind#3647] : Support @JsonIgnoreProperties to work with @JsonValue | ||
public class JsonValueIgnore3647Test extends BaseMapTest | ||
{ | ||
static class Foo3647 { | ||
public String p1 = "hello"; | ||
public String p2 = "world"; | ||
} | ||
|
||
static class Bar3647 { | ||
@JsonValue | ||
@JsonIgnoreProperties("p1") | ||
public Foo3647 getFoo() { | ||
return new Foo3647(); | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties({"a"}) | ||
static class Bean3647 { | ||
public String a = "hello"; | ||
public String b = "world"; | ||
} | ||
|
||
static class Container3647 { | ||
@JsonValue | ||
@JsonIgnoreProperties("b") | ||
public Bean3647 getBean() { | ||
return new Bean3647(); | ||
} | ||
} | ||
|
||
static class Base3647 { | ||
public String a = "hello"; | ||
public String b = "world"; | ||
} | ||
|
||
static class BaseContainer3647 { | ||
@JsonValue | ||
public Base3647 getBean() { | ||
return new Base3647(); | ||
} | ||
} | ||
|
||
static class MixinContainer3647 { | ||
@JsonIgnoreProperties("b") | ||
public Base3647 getBean() { | ||
return new Base3647(); | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties({"a", "b"}) | ||
static class Mixin3647 { | ||
public String a = "hello"; | ||
public String b = "world"; | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
public void testIgnorePropsAndJsonValueAtSameLevel() throws Exception | ||
{ | ||
assertEquals("{\"p2\":\"world\"}", | ||
MAPPER.writeValueAsString(new Bar3647())); | ||
} | ||
|
||
public void testUnionOfIgnorals() throws Exception | ||
{ | ||
assertEquals("{}", | ||
MAPPER.writeValueAsString(new Container3647())); | ||
} | ||
|
||
public void testMixinContainerAndJsonValue() throws Exception | ||
{ | ||
ObjectMapper mapper = jsonMapperBuilder() | ||
.addMixIn(BaseContainer3647.class, MixinContainer3647.class) | ||
.build(); | ||
|
||
assertEquals("{\"a\":\"hello\"}", | ||
mapper.writeValueAsString(new BaseContainer3647())); | ||
} | ||
|
||
public void testMixinAndJsonValue() throws Exception | ||
{ | ||
ObjectMapper mapper = jsonMapperBuilder() | ||
.addMixIn(Base3647.class, Mixin3647.class) | ||
.build(); | ||
|
||
assertEquals("{}", | ||
mapper.writeValueAsString(new Base3647())); | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
src/test/java/com/fasterxml/jackson/failing/JsonValueIgnore3647Test.java
This file was deleted.
Oops, something went wrong.