Skip to content

Commit

Permalink
Add failing test for FasterXML#3647 - @JsonIgnoreProperties does not …
Browse files Browse the repository at this point in the history
…work with @JsonValue
  • Loading branch information
mukham12 committed Apr 18, 2023
1 parent 280b616 commit a338333
Showing 1 changed file with 61 additions and 0 deletions.
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);
}
}

0 comments on commit a338333

Please sign in to comment.