File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
main/java/io/getstream/core/models
test/java/io/getstream/core/utils Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ public <T> Data from(T data) {
5151
5252 public Data from (Map <String , Object > map ) {
5353 checkNotNull (data , "Can't extract data from null" );
54+ if (map == null || map .isEmpty ()) {
55+ return this ;
56+ }
5457
5558 for (Map .Entry <String , Object > entry : map .entrySet ()) {
5659 set (entry .getKey (), entry .getValue ());
Original file line number Diff line number Diff line change 22
33import static io .getstream .core .utils .Serialization .*;
44import static org .junit .Assert .assertEquals ;
5+ import static org .junit .Assert .assertNotNull ;
56
67import com .fasterxml .jackson .core .type .TypeReference ;
78import com .google .common .collect .ImmutableMap ;
1314import io .getstream .core .models .CollectionData ;
1415import io .getstream .core .models .EnrichedActivity ;
1516import io .getstream .core .models .FeedID ;
17+ import io .getstream .core .models .Reaction ;
1618import java .io .ByteArrayInputStream ;
1719import java .nio .charset .Charset ;
1820import java .text .SimpleDateFormat ;
@@ -209,6 +211,16 @@ public void emptyMapDeserialization() throws Exception {
209211 fromJSON (new ByteArrayInputStream (activity .getBytes (Charset .forName ("UTF-8" ))), type );
210212 }
211213
214+ @ Test
215+ public void emptyDataDeserialization () throws Exception {
216+ String reaction = "{ \" data\" : {} }" ;
217+ TypeReference <Reaction > type = new TypeReference <Reaction >() {};
218+
219+ Reaction result =
220+ fromJSON (new ByteArrayInputStream (reaction .getBytes (Charset .forName ("UTF-8" ))), type );
221+ assertNotNull (result );
222+ }
223+
212224 @ Test
213225 public void creatorAndAnySetterDeserialization () throws Exception {
214226 String data = "{\" id\" :\" id-thing\" ,\" value\" :1,\" extra\" :{\" test\" :\" test\" }}" ;
You can’t perform that action at this time.
0 commit comments