diff options
-rw-r--r-- | juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java | 5 | ||||
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java index 736919a4..41f7cefc 100644 --- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -70,11 +70,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ } msg.setLikes(rs.getInt(16)); msg.Hidden = rs.getBoolean(17); - // parse tags string String tagsStr = rs.getString(18); - if (tagsStr != null) { - Arrays.stream(tagsStr.split(" ")).forEach(t -> msg.getTags().add(new Tag(t))); - } + msg.parseTags(tagsStr); msg.setRepliesBy(rs.getString(19)); msg.setText(rs.getString(20)); msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(21))); diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java index c1a1bb35..0317dbb4 100644 --- a/src/test/java/com/juick/tests/ApiTests.java +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -18,6 +18,7 @@ import com.juick.service.search.SearchService; import com.juick.www.controllers.PageTemplates; import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -185,6 +186,10 @@ public class ApiTests { assertEquals("object tags should unescaped", htmlTag.getName(), StringEscapeUtils.unescapeHtml4(dbTagName)); assertEquals("template should encode escaped tag in url and show escaped tag in name", "<a href=\"/tag/%3E_%3C\" rel=\"nofollow\">>_<</a>", templates.formatTags(Collections.singletonList(htmlTagStats))); + int mid4 = messagesService.createMessage(user_id, "yoyoyo", null, null); + Message msg4 = messagesService.getMessage(mid4); + assertEquals("tags string should be empty", StringUtils.EMPTY, msg4.getTagsString()); + messagesService.deleteMessage(user_id, mid4); } @Test |