diff options
author | Vitaly Takmazov | 2016-11-30 16:49:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-30 16:49:11 +0300 |
commit | 1a2830588131173d8fbfeb1fe03c466b4cf30e46 (patch) | |
tree | 53889640b356f22e6620acffed0bda1e56babcf6 /src/test/java/com/juick/tests | |
parent | f5fd9c7bea380eb4c0c2d58f2167ad3f07c45c33 (diff) |
juick-core: fix attachment serialization
Diffstat (limited to 'src/test/java/com/juick/tests')
-rw-r--r-- | src/test/java/com/juick/tests/SerializationTests.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/test/java/com/juick/tests/SerializationTests.java b/src/test/java/com/juick/tests/SerializationTests.java index dd2812c7..61b86c5f 100644 --- a/src/test/java/com/juick/tests/SerializationTests.java +++ b/src/test/java/com/juick/tests/SerializationTests.java @@ -49,17 +49,10 @@ public class SerializationTests { user.setName("ugnich"); user.setUid(1); user.setFullName("Anton Ugnich"); - UserSerializer userSerializer = new UserSerializer(); - JSONObject handmadeJson = userSerializer.serialize(user); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); - User jacksonUser = mapper.readValue(handmadeJson.toString(), User.class); - assertEquals("jackson should deserialize ugnich json", user, jacksonUser); - String jacksonString = mapper.writeValueAsString(user); - JSONObject jacksonJson = new JSONObject(jacksonString); - assertEquals("jackson should serialize as ugnich", handmadeJson.length(), jacksonJson.length()); Message msg = new Message(); msg.setMid(1); msg.setUser(user); @@ -67,11 +60,16 @@ public class SerializationTests { msg.setDate(new Date()); msg.getTags().add(new Tag("test")); msg.getTags().add(new Tag("json")); + msg.setAttachmentType("png"); MessageSerializer messageSerializer = new MessageSerializer(); JSONObject handmadeJsonMessage = messageSerializer.serialize(msg); Message jacksonMessage = mapper.readValue(handmadeJsonMessage.toString(), Message.class); assertEquals("jackson should deserialize ugnich json", msg, jacksonMessage); String jacksonStringMessage = mapper.writeValueAsString(jacksonMessage); + assertEquals("jackson message should have an attachment url", + "http://i.juick.com/photos-1024/1.png", jacksonMessage.getAttachmentURL()); + assertEquals("jackson message should have image previews", + "http://i.juick.com/photos-1024/1.png", jacksonMessage.getPhoto().getMedium()); JSONObject jacksonJsonMessage = new JSONObject(jacksonStringMessage); assertEquals("jackson should serialize as ugnich", handmadeJsonMessage.length(), jacksonJsonMessage.length()); @@ -91,6 +89,7 @@ public class SerializationTests { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(new InputSource(new StringReader(xmlString))); assertEquals("jaxb should marshal as ugnich", 4, doc.getDocumentElement().getChildNodes().getLength()); - assertEquals("jaxb should marshal as ugnich", 7, doc.getDocumentElement().getAttributes().getLength()); + assertEquals("jaxb should marshal as ugnich", 8, doc.getDocumentElement().getAttributes().getLength()); + assertEquals("xmpp message should have an attach attribute", "png", doc.getDocumentElement().getAttribute("attach")); } }
\ No newline at end of file |