-
-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c100ed5
commit c7a4b0c
Showing
6 changed files
with
157 additions
and
49 deletions.
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
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
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
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
72 changes: 72 additions & 0 deletions
72
src/test/java/com/fasterxml/jackson/databind/deser/jdk/EnumDeserFromIntJsonValueTest.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,72 @@ | ||
package com.fasterxml.jackson.databind.deser.jdk; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
public class EnumDeserFromIntJsonValueTest extends BaseMapTest | ||
{ | ||
// [databind#1850] | ||
|
||
enum Bean1850IntMethod { | ||
A(101); | ||
final int x; | ||
Bean1850IntMethod(int x) { this.x = x; } | ||
@JsonValue | ||
public int code() { return x; } | ||
} | ||
|
||
enum Bean1850IntField { | ||
A(202); | ||
@JsonValue | ||
public final int x; | ||
Bean1850IntField(int x) { this.x = x; } | ||
} | ||
|
||
enum Bean1850LongMethod { | ||
A(-13L); | ||
final long x; | ||
Bean1850LongMethod(long x) { this.x = x; } | ||
@JsonValue | ||
public long code() { return x; } | ||
} | ||
|
||
enum Bean1850LongField { | ||
A(29L); | ||
@JsonValue | ||
public final long x; | ||
Bean1850LongField(long x) { this.x = x; } | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
// [databind#1850] pass tests | ||
|
||
public void testEnumFromInt1850Method() throws Exception | ||
{ | ||
String json = MAPPER.writeValueAsString(Bean1850IntMethod.A); | ||
Bean1850IntMethod e1 = MAPPER.readValue(json, Bean1850IntMethod.class); | ||
assertEquals(Bean1850IntMethod.A, e1); | ||
} | ||
|
||
public void testEnumFromInt1850Field() throws Exception | ||
{ | ||
String json = MAPPER.writeValueAsString(Bean1850IntField.A); | ||
Bean1850IntField e2 = MAPPER.readValue(json, Bean1850IntField.class); | ||
assertEquals(Bean1850IntField.A, e2); | ||
} | ||
|
||
public void testEnumFromLong1850Method() throws Exception | ||
{ | ||
String json = MAPPER.writeValueAsString(Bean1850LongMethod.A); | ||
Bean1850LongMethod e1 = MAPPER.readValue(json, Bean1850LongMethod.class); | ||
assertEquals(Bean1850LongMethod.A, e1); | ||
} | ||
|
||
public void testEnumFromLong1850Field() throws Exception | ||
{ | ||
String json = MAPPER.writeValueAsString(Bean1850LongField.A); | ||
Bean1850LongField e2 = MAPPER.readValue(json, Bean1850LongField.class); | ||
assertEquals(Bean1850LongField.A, e2); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
src/test/java/com/fasterxml/jackson/failing/EnumDeserializationFromInt1850Test.java
This file was deleted.
Oops, something went wrong.