Skip to content

Commit 24b280b

Browse files
committed
Add #518: test any-getter entries are sorted before bean fields
1 parent f787e88 commit 24b280b

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/test/java/tools/jackson/databind/tofix/AnyGetterSorting518Test.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ public Bean(int a, int b, Map<String,Object> x) {
3636
public Map<String,Object> getExtra() { return extra; }
3737
}
3838

39+
@JsonPropertyOrder(alphabetic = true)
40+
static class AnyGetterBeforeFieldsBean
41+
{
42+
public int x;
43+
44+
protected Map<String,Object> extra = new HashMap<>();
45+
46+
public int y;
47+
48+
public AnyGetterBeforeFieldsBean(int x, int y, Map<String,Object> a) {
49+
this.x = x;
50+
this.y = y;
51+
extra = a;
52+
}
53+
54+
@JsonAnyGetter
55+
public Map<String,Object> getExtra() { return extra; }
56+
}
57+
3958
/*
4059
/**********************************************************
4160
/* Test methods
@@ -44,7 +63,6 @@ public Bean(int a, int b, Map<String,Object> x) {
4463

4564
private final ObjectMapper MAPPER = newJsonMapper();
4665

47-
@JacksonTestFailureExpected
4866
@Test
4967
void anyBeanWithSort() throws Exception
5068
{
@@ -54,4 +72,14 @@ void anyBeanWithSort() throws Exception
5472
String json = MAPPER.writeValueAsString(new Bean(1, 2, extra));
5573
assertEquals(a2q("{'a':1,'b':2,'x':3,'y':4}"), json);
5674
}
75+
76+
@Test
77+
void anyGetterSortingBeforeFields() throws Exception
78+
{
79+
Map<String,Object> extra = new LinkedHashMap<>();
80+
extra.put("b", 4);
81+
extra.put("a", 3);
82+
String json = MAPPER.writeValueAsString(new AnyGetterBeforeFieldsBean(1, 2, extra));
83+
assertEquals(a2q("{'a':3,'b':4,'x':1,'y':2}"), json);
84+
}
5785
}

0 commit comments

Comments
 (0)