-
-
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
35bd198
commit 7d8692c
Showing
8 changed files
with
116 additions
and
64 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
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
46 changes: 46 additions & 0 deletions
46
...test/java/com/fasterxml/jackson/databind/deser/enums/EnumSetPolymorphicDeser4214Test.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,46 @@ | ||
package com.fasterxml.jackson.databind.deser.enums; | ||
|
||
import java.util.EnumSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; | ||
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator; | ||
|
||
// For [databind#4214] | ||
public class EnumSetPolymorphicDeser4214Test extends BaseMapTest | ||
{ | ||
static enum MyEnum { | ||
ITEM_A, ITEM_B; | ||
} | ||
|
||
static class EnumSetHolder { | ||
public Set<MyEnum> enumSet; // use Set instead of EnumSet for type of this | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (!(o instanceof EnumSetHolder)) { | ||
return false; | ||
} | ||
EnumSetHolder eh = (EnumSetHolder) o; | ||
return Objects.equals(enumSet, eh.enumSet); | ||
} | ||
} | ||
|
||
public void testPolymorphicDeserialization4214() throws Exception | ||
{ | ||
// Need to use Default Typing to trigger issue | ||
ObjectMapper mapper = jsonMapperBuilder() | ||
.activateDefaultTyping(BasicPolymorphicTypeValidator.builder().allowIfBaseType(Object.class).build(), | ||
DefaultTyping.NON_FINAL_AND_ENUMS) | ||
.build(); | ||
|
||
EnumSetHolder enumSetHolder = new EnumSetHolder(); | ||
enumSetHolder.enumSet = EnumSet.allOf(MyEnum.class); | ||
String json = mapper.writeValueAsString(enumSetHolder); | ||
EnumSetHolder result = mapper.readValue(json, EnumSetHolder.class); | ||
assertEquals(result, enumSetHolder); | ||
} | ||
} |
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: 0 additions & 49 deletions
49
src/test/java/com/fasterxml/jackson/failing/EnumSetSerialization4214Test.java
This file was deleted.
Oops, something went wrong.