Skip to content

Commit 95d9ce0

Browse files
committed
Test refactoring
1 parent 6244aa0 commit 95d9ce0

File tree

2 files changed

+43
-56
lines changed

2 files changed

+43
-56
lines changed

src/test/java/tools/jackson/databind/ser/AnyGetterOrdering4388Test.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.jupiter.api.Test;
88

99
import com.fasterxml.jackson.annotation.*;
10+
1011
import tools.jackson.databind.ObjectMapper;
1112
import tools.jackson.databind.testutil.DatabindTestUtil;
1213

@@ -16,7 +17,31 @@
1617
* Test to verify that the order of properties is preserved when using @JsonPropertyOrder
1718
* with @JsonUnwrapped and @JsonAnyGetter
1819
*/
19-
public class AnyGetterOrdering4388Test extends DatabindTestUtil {
20+
public class AnyGetterOrdering4388Test extends DatabindTestUtil
21+
{
22+
// For [databind#518]
23+
24+
@JsonPropertyOrder(alphabetic = true)
25+
static class Bean518
26+
{
27+
public int b;
28+
29+
protected Map<String,Object> extra = new HashMap<>();
30+
31+
public int a;
32+
33+
public Bean518(int a, int b, Map<String,Object> x) {
34+
this.a = a;
35+
this.b = b;
36+
extra = x;
37+
}
38+
39+
@JsonAnyGetter
40+
public Map<String,Object> getExtra() { return extra; }
41+
}
42+
43+
// For [databind#4388]
44+
2045
// Base class with properties
2146
static class BaseWithProperties {
2247
public String entityName;
@@ -136,8 +161,25 @@ public Map<String, Object> getSecondProperties() {
136161
}
137162
}
138163

164+
/*
165+
/**********************************************************************
166+
/* Test methods
167+
/**********************************************************************
168+
*/
169+
139170
private final ObjectMapper MAPPER = newJsonMapper();
140171

172+
// For [databind#518]
173+
@Test
174+
void anyBeanWithSort518() throws Exception
175+
{
176+
Map<String,Object> extra = new LinkedHashMap<>();
177+
extra.put("y", 4);
178+
extra.put("x", 3);
179+
String json = MAPPER.writeValueAsString(new Bean518(2, 1, extra));
180+
assertEquals(a2q("{'a':2,'b':1,'y':4,'x':3}"), json);
181+
}
182+
141183
// For [databind#4388]
142184
@Test
143185
public void testSerializationOrderVersion1() throws Exception {

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

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)