Skip to content

Commit

Permalink
Add tests related to #4409
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 4, 2024
1 parent 9fb5b8d commit d03fb71
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.fasterxml.jackson.databind.deser.enums;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

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

// for [databind#4409
public class EnumDeserDupName4409Test extends DatabindTestUtil
{
// for [databind#4409
enum ColorMode4409Snake {
// Will become "rgb"
RGB,
// Will become "rgba"
RGBa,
// Will become "rgba" as well unless overriden, so:
@JsonProperty("RGBA")
RGBA
}

private final ObjectMapper MAPPER = jsonMapperBuilder()
.propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
.build();

// for [databind#4409
@Test
public void dupNameConflict4409() throws Exception
{
assertEquals(ColorMode4409Snake.RGBa,
MAPPER.readValue(q("RGBa"), ColorMode4409Snake.class));

assertEquals(q("RGBA"),
MAPPER.writeValueAsString(ColorMode4409Snake.RGBA));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ public void setUtcZone(String utcZone) {
{"uId", "u_id" },
// [databind#2267]
{"xCoordinate", "x_coordinate" },
// [databind#4409]
{"RGBA", "rgba"},
{"RGBa", "rgba"},
});

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

0 comments on commit d03fb71

Please sign in to comment.