Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 3, 2024
2 parents 80d3d7a + 9fb5b8d commit 48c5bfe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ enum MixinOverloadedDefault {
/* Test methods
/**********************************************************
*/
private final ObjectMapper MAPPER = new ObjectMapper();

private final ObjectMapper MAPPER = newJsonMapper();

@Test
public void testWithoutCustomFeatures() throws Exception
Expand Down
50 changes: 50 additions & 0 deletions src/test/java/tools/jackson/failing/EnumDefaultRead4403Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package tools.jackson.failing;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
import com.fasterxml.jackson.annotation.JsonProperty;

import tools.jackson.databind.DeserializationFeature;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;

import static tools.jackson.databind.testutil.DatabindTestUtil.newJsonMapper;
import static tools.jackson.databind.testutil.DatabindTestUtil.q;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class EnumDefaultRead4403Test
{
// [databind#4403]
enum Brand4403 {
@JsonProperty("005")
SEAT,
@JsonProperty("006")
HYUNDAI,
@JsonEnumDefaultValue
OTHER
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final ObjectMapper MAPPER = newJsonMapper();

// [databind#4403]
@Test
public void readFromDefault4403() throws Exception
{
ObjectReader r = MAPPER.readerFor(Brand4403.class)
.with(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
assertEquals(Brand4403.SEAT, r.readValue(q("005")));
assertEquals(Brand4403.HYUNDAI, r.readValue(q("006")));
assertEquals(Brand4403.OTHER, r.readValue(q("x")));

// Problem here: "001" taken as "Stringified" index 1
assertEquals(Brand4403.OTHER, r.readValue(q("001")));
}

}

0 comments on commit 48c5bfe

Please sign in to comment.