Skip to content

Commit 8956915

Browse files
authored
Add tests related to #4409 (#4411)
1 parent 9fb5b8d commit 8956915

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.fasterxml.jackson.databind.deser.enums;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import com.fasterxml.jackson.databind.ObjectMapper;
8+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
9+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
10+
11+
import static org.junit.jupiter.api.Assertions.assertEquals;
12+
13+
// for [databind#4409
14+
public class EnumDeserDupName4409Test extends DatabindTestUtil
15+
{
16+
// for [databind#4409
17+
enum ColorMode4409Snake {
18+
// Will become "rgb"
19+
RGB,
20+
// Will become "rgba"
21+
RGBa,
22+
// Will become "rgba" as well unless overriden, so:
23+
@JsonProperty("RGBA")
24+
RGBA
25+
}
26+
27+
private final ObjectMapper MAPPER = jsonMapperBuilder()
28+
.propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
29+
.build();
30+
31+
// for [databind#4409
32+
@Test
33+
public void dupNameConflict4409() throws Exception
34+
{
35+
assertEquals(ColorMode4409Snake.RGBa,
36+
MAPPER.readValue(q("RGBa"), ColorMode4409Snake.class));
37+
38+
assertEquals(q("RGBA"),
39+
MAPPER.writeValueAsString(ColorMode4409Snake.RGBA));
40+
}
41+
}

src/test/java/com/fasterxml/jackson/databind/introspect/TestNamingStrategyStd.java

+3
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ public void setUtcZone(String utcZone) {
238238
{"uId", "u_id" },
239239
// [databind#2267]
240240
{"xCoordinate", "x_coordinate" },
241+
// [databind#4409]
242+
{"RGBA", "rgba"},
243+
{"RGBa", "rgba"},
241244
});
242245

243246
final static List<Object[]> UPPER_SNAKE_CASE_NAME_TRANSLATIONS = Arrays.asList(new Object[][] {

0 commit comments

Comments
 (0)