From 3d7f60c1c0b48dad2f58bffe3352d1c5c1b93f00 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 1 Dec 2016 13:56:53 +0300 Subject: juick-api: Tags controller from perl, refactoring --- src/test/java/com/juick/tests/ApiTests.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/test') 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", - ">_<", PageTemplates.formatTags(new ArrayList() {{ add(htmlTag); }} )); + ">_<", 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"); -- cgit v1.2.3