-
Notifications
You must be signed in to change notification settings - Fork 53
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
902fa38
commit c3cd1dc
Showing
17 changed files
with
163 additions
and
20 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
2 changes: 2 additions & 0 deletions
2
guava/src/main/java/com/fasterxml/jackson/datatype/guava/deser/HashMultisetDeserializer.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
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
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
guava/src/test/java/com/fasterxml/jackson/datatype/guava/EmptyCollectionsTest.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.datatype.guava; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSetter; | ||
import com.fasterxml.jackson.annotation.Nulls; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
public class EmptyCollectionsTest extends ModuleTestBase | ||
{ | ||
// [datatypes-collections#67] | ||
public static class ImmutableListContainer67 { | ||
public ImmutableList<ImmutableList<String>> lists = ImmutableList.of(); | ||
} | ||
|
||
public static class ImmutableMapContainer67 { | ||
public ImmutableMap<String, ImmutableMap<String, String>> maps = ImmutableMap.of(); | ||
} | ||
|
||
private final ObjectMapper EMPTY_MAPPER = builderWithModule() | ||
.defaultSetterInfo(JsonSetter.Value.forContentNulls(Nulls.AS_EMPTY) | ||
.withValueNulls(Nulls.AS_EMPTY)) | ||
.build(); | ||
|
||
// [datatypes-collections#67] | ||
public void testEmptyForLists() throws Exception | ||
{ | ||
ImmutableListContainer67 result; | ||
|
||
// First, value `null` into empty: | ||
result = EMPTY_MAPPER.readValue(a2q("{'lists':null}"), ImmutableListContainer67.class); | ||
assertNotNull(result.lists); | ||
assertEquals(0, result.lists.size()); | ||
|
||
// then content null: | ||
result = EMPTY_MAPPER.readValue(a2q("{'lists':[ null ]}"), ImmutableListContainer67.class); | ||
assertNotNull(result.lists); | ||
assertEquals(1, result.lists.size()); | ||
assertNotNull(result.lists.get(0)); | ||
assertEquals(0, result.lists.get(0).size()); | ||
|
||
// and finally round-trip too | ||
String json = EMPTY_MAPPER.writeValueAsString(new ImmutableListContainer67()); | ||
result = EMPTY_MAPPER.readValue(json, ImmutableListContainer67.class); | ||
assertNotNull(result.lists); | ||
assertEquals(0, result.lists.size()); | ||
} | ||
|
||
public void testEmptyForMaps() throws Exception | ||
{ | ||
ImmutableMapContainer67 result; | ||
|
||
// First, value `null` into empty: | ||
result = EMPTY_MAPPER.readValue(a2q("{'maps':null}"), ImmutableMapContainer67.class); | ||
assertNotNull(result.maps); | ||
assertEquals(0, result.maps.size()); | ||
|
||
// then content null: | ||
result = EMPTY_MAPPER.readValue(a2q("{'maps':{ 'key' : null }}"), ImmutableMapContainer67.class); | ||
assertNotNull(result.maps); | ||
assertEquals(1, result.maps.size()); | ||
assertNotNull(result.maps.get("key")); | ||
assertEquals(0, result.maps.get("key").size()); | ||
|
||
// and finally round-trip too | ||
String json = EMPTY_MAPPER.writeValueAsString(new ImmutableMapContainer67()); | ||
result = EMPTY_MAPPER.readValue(json, ImmutableMapContainer67.class); | ||
assertNotNull(result.maps); | ||
assertEquals(0, result.maps.size()); | ||
} | ||
} |
Oops, something went wrong.