forked from FasterXML/jackson-databind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for FasterXML#3647 - @JsonIgnoreProperties does not …
…work with @JsonValue
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/test/java/com/fasterxml/jackson/failing/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,61 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
// for [databind#3647] | ||
public class JsonValueIgnore3647Test extends BaseMapTest | ||
{ | ||
// for [databind#3647] | ||
static class Foo { | ||
String p1 = "hello"; | ||
String p2 = "world"; | ||
|
||
public String getP1() { | ||
return p1; | ||
} | ||
|
||
public void setP1(String p1) { | ||
this.p1 = p1; | ||
} | ||
|
||
public String getP2() { | ||
return p2; | ||
} | ||
|
||
public void setP2(String p2) { | ||
this.p2 = p2; | ||
} | ||
} | ||
|
||
// for [databind#3647] | ||
static class Bar { | ||
@JsonValue | ||
@JsonIgnoreProperties("p1") | ||
Foo foo = new Foo(); | ||
public Foo getFoo() { | ||
return foo; | ||
} | ||
public void setFoo(Foo foo) { | ||
this.foo = foo; | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
// [databind#3647] | ||
public void testIgnorePropsAnnotatedJsonValue() throws Exception | ||
{ | ||
final String result = "{\"p2\":\"world\"}"; | ||
final String jsonStringWithIgnoredProps = MAPPER.writeValueAsString(new Bar()); | ||
assertEquals(result, jsonStringWithIgnoredProps); | ||
} | ||
} |