From a1f9fe5ea28ec28d7cda704d8ef79ca2bd890195 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 18 Oct 2018 12:45:58 +0300 Subject: last message in pm groups --- .../test/java/com/juick/server/tests/ServerTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'juick-server/src/test') diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index 4d93470d..2d55b047 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -29,6 +29,7 @@ import com.jayway.jsonpath.JsonPath; import com.juick.*; import com.juick.model.AnonymousUser; import com.juick.model.CommandResult; +import com.juick.model.PrivateChats; import com.juick.model.TagStats; import com.juick.server.*; import com.juick.server.api.activity.model.Context; @@ -1730,4 +1731,19 @@ public class ServerTests { .andExpect(status().isOk()).andReturn(); String xrd = result.getResponse().getContentAsString(); } + @Test + public void pms() throws Exception { + jdbcTemplate.execute("DELETE FROM pm"); + jdbcTemplate.execute("DELETE FROM pm_streams"); + CommandResult res = commandsManager.processCommand(ugnich, "@freefd DICK", emptyUri); + assertThat(res.getNewMessage(), is(Optional.empty())); + assertThat(res.getText(), is("Private message sent")); + MvcResult result = mockMvc.perform(get("/api/groups_pms") + .with(httpBasic(freefdName, freefdPassword))) + .andExpect(status().isOk()) + .andReturn(); + PrivateChats chats = jsonMapper.readValue(result.getResponse().getContentAsString(), PrivateChats.class); + assertThat(chats.getUsers().size(), is(1)); + assertThat(chats.getUsers().get(0).getUnreadCount(), is(1)); + } } -- cgit v1.2.3