Skip to content

Commit

Permalink
Add failing test (reproduction) for #562 (#4347)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 28, 2024
1 parent 62aac6b commit e984a98
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.fasterxml.jackson.failing;

import java.util.Collections;
import java.util.Map;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.*;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class AnySetterForCreator562Test extends DatabindTestUtil
{
// [databind#562]
static class POJO562
{
String a;

Map<String,Object> stuff;

@JsonCreator
public POJO562(@JsonProperty("a") String a,
@JsonAnySetter Map<String, Object>
leftovers) {
this.a = a;
stuff = leftovers;
}
}

private final ObjectMapper MAPPER = newJsonMapper();

// [databind#562]
@Test
public void testAnySetterViaCreator562() throws Exception
{
POJO562 pojo = MAPPER.readValue(a2q(
"{'a':'value', 'b':42}"
),
POJO562.class);
assertEquals(pojo.a, "value");
assertEquals(Collections.singletonMap("b", Integer.valueOf(42)),
pojo.stuff);
}
}

0 comments on commit e984a98

Please sign in to comment.