diff options
author | Vitaly Takmazov | 2016-12-01 13:56:53 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-12-01 13:56:53 +0300 |
commit | 3d7f60c1c0b48dad2f58bffe3352d1c5c1b93f00 (patch) | |
tree | ab311d5d6102b2c76c03b266fc1b794108cba0fc /src | |
parent | 92d6700919e87c81db4a42a4b286257f62566cbf (diff) |
juick-api: Tags controller from perl, refactoring
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java index 727447e0..1d777d62 100644 --- a/src/test/java/com/juick/tests/ApiTests.java +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -11,6 +11,7 @@ import com.juick.server.MessagesQueries; import com.juick.server.SubscriptionsQueries; import com.juick.server.TagQueries; import com.juick.server.UserQueries; +import com.juick.server.helpers.TagStats; import com.juick.server.protocol.JuickProtocol; import com.juick.server.protocol.ProtocolReply; import com.juick.www.PageTemplates; @@ -26,6 +27,7 @@ import java.lang.reflect.InvocationTargetException; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; @@ -93,11 +95,13 @@ public class ApiTests { MessagesQueries.deleteMessage(jdbc, user_id, mid2); String htmlTagName = ">_<"; Tag htmlTag = TagQueries.getTag(jdbc, htmlTagName, true); + TagStats htmlTagStats = new TagStats(); + htmlTagStats.setTag(htmlTag); String dbTagName = jdbc.queryForObject("select name from tags where name=?", String.class, StringEscapeUtils.escapeHtml4(htmlTagName)); assertNotEquals("db tags should be escaped", dbTagName, htmlTag.getName()); 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>", PageTemplates.formatTags(new ArrayList<Tag>() {{ add(htmlTag); }} )); + "<a href=\"/tag/%3E_%3C\" rel=\"nofollow\">>_<</a>", PageTemplates.formatTags(Collections.singletonList(htmlTagStats))); } @Test @@ -115,7 +119,7 @@ public class ApiTests { assertEquals("text should match", "yoyo", MessagesQueries.getMessage(jdbc, mid).getText()); assertEquals("tag should match", "yo", - MessagesQueries.getMessageTags(jdbc, mid).get(0).getName()); + MessagesQueries.getMessageTags(jdbc, mid).get(0).getTag().getName()); assertNotEquals("should not be error", "Error", protocol.getReply(user, "#" + mid).getDescription()); assertEquals("should be PONG", "PONG", protocol.getReply(user, " ping \n ").getDescription()); int readerUid = UserQueries.createUser(jdbc, "dummyReader", "dummySecret"); |