-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23f3b7a
commit 9e005ef
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/test/java/com/fasterxml/jackson/failing/EnumDefaultRead4403Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.ObjectReader; | ||
|
||
import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.newJsonMapper; | ||
import static com.fasterxml.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"))); | ||
assertEquals(Brand4403.OTHER, r.readValue(q("001"))); | ||
} | ||
|
||
} |