From 5b88a7355c554e500199d6c233ae891459b602ac Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 24 Oct 2018 00:31:28 +0300 Subject: Fix deserialisation and tests --- .../main/java/com/juick/server/api/activity/model/Context.java | 2 ++ .../java/com/juick/server/api/activity/model/objects/Mention.java | 6 +++++- .../java/com/juick/server/api/activity/model/objects/Note.java | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/api') diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java index dd67fa64..544f1aa2 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java @@ -28,6 +28,8 @@ import java.util.List; @JsonSubTypes.Type(value = Image.class, name = "Image"), @JsonSubTypes.Type(value = Key.class, name = "Key"), @JsonSubTypes.Type(value = Link.class, name = "Link"), + @JsonSubTypes.Type(value = Hashtag.class, name = "Hashtag"), + @JsonSubTypes.Type(value = Mention.class, name = "Mention"), @JsonSubTypes.Type(value = Note.class, name = "Note"), @JsonSubTypes.Type(value = OrderedCollection.class, name = "OrderedCollection"), @JsonSubTypes.Type(value = OrderedCollectionPage.class, name = "OrderedCollectionPage"), diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java index dbf3bec9..bcb52d37 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java @@ -1,7 +1,11 @@ package com.juick.server.api.activity.model.objects; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + public class Mention extends Link { - public Mention(String href, String name) { + @JsonCreator + public Mention(@JsonProperty("href") String href, @JsonProperty("name") String name) { this.setHref(href); this.setName(name); } diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java index 458b925c..baad2d3b 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java @@ -1,5 +1,6 @@ package com.juick.server.api.activity.model.objects; +import com.fasterxml.jackson.annotation.JsonFormat; import com.juick.server.api.activity.model.Context; import java.util.List; @@ -8,7 +9,7 @@ public class Note extends Context { private String content; private String attributedTo; private String inReplyTo; - private Image attachment; + private List attachment; private List to; private List cc; @@ -28,11 +29,12 @@ public class Note extends Context { this.attributedTo = attributedTo; } - public Image getAttachment() { + @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) + public List getAttachment() { return attachment; } - public void setAttachment(Image attachment) { + public void setAttachment(List attachment) { this.attachment = attachment; } -- cgit v1.2.3