diff options
author | Vitaly Takmazov | 2017-11-02 17:26:31 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-11-02 17:26:31 +0300 |
commit | 3bbf2004183058d0476c25b5ff2a3f50c80165c9 (patch) | |
tree | 4fc8f2507694e239ea6c86817ee0415d36ff11cd | |
parent | d95a1d019b08a5eebe674e68a1692513d7d16991 (diff) |
reorganize tests
3 files changed, 162 insertions, 306 deletions
diff --git a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java index 0577e009..23e01fd2 100644 --- a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java +++ b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java @@ -22,6 +22,8 @@ import com.juick.Tag; import com.juick.User; import com.juick.configuration.RepositoryConfiguration; import com.juick.server.helpers.AnonymousUser; +import com.juick.server.helpers.TagStats; +import org.apache.commons.lang3.StringUtils; import org.junit.*; import org.junit.runner.RunWith; import org.springframework.jdbc.core.JdbcTemplate; @@ -30,11 +32,13 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.inject.Inject; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; /** * Created by aalexeev on 11/25/16. @@ -122,4 +126,48 @@ public class MessageServiceTest extends AbstractJUnit4SpringContextTests { assertThat(pm.getText(), equalTo("hello")); assertThat(pm.getUser().getUid(), equalTo(freefdId)); } + + @Test + public void messageTests() { + int user_id = userService.createUser("mmmme", "secret"); + User user = userService.getUserByUID(user_id).orElse(new User()); + assertEquals("it should be me", "mmmme", user.getName()); + int mid = messagesService.createMessage(user_id, "yo", null, new ArrayList<>()); + Message msg = messagesService.getMessage(mid); + assertEquals("yo", msg.getText()); + User me = msg.getUser(); + assertEquals("mmmme", me.getName()); + assertEquals("mmmme", messagesService.getMessageAuthor(mid).getName()); + int tagID = tagService.createTag("weather"); + Tag tag = tagService.getTag(tagID); + List<Tag> tagList = new ArrayList<>(); + tagList.add(tag); + int mid2 = messagesService.createMessage(user_id, "yo2", null, tagList); + Message msg2 = messagesService.getMessage(mid2); + assertEquals(1, msg2.getTags().size()); + assertEquals("we already have ugnich", -1, userService.createUser("ugnich", "x")); + int ugnich_id = userService.createUser("hugnich", "x"); + User ugnich = userService.getUserByUID(ugnich_id).orElse(new User()); + int rid = messagesService.createReply(msg2.getMid(), 0, ugnich.getUid(), "bla-bla", null); + assertEquals(1, rid); + Message msg3 = messagesService.getMessage(mid2); + assertEquals(1, msg3.getReplies()); + assertEquals("weather", msg3.getTags().get(0).getName()); + assertEquals(ugnich.getUid(), userService.checkPassword(ugnich.getName(), "x")); + assertEquals(-1, userService.checkPassword(ugnich.getName(), "xy")); + subscriptionService.subscribeMessage(msg.getMid(), ugnich.getUid()); + assertEquals(1, subscriptionService.getUsersSubscribedToComments(msg.getMid(), user.getUid()).size()); + messagesService.deleteMessage(user_id, mid); + messagesService.deleteMessage(user_id, mid2); + String htmlTagName = ">_<"; + Tag htmlTag = tagService.getTag(htmlTagName, true); + TagStats htmlTagStats = new TagStats(); + htmlTagStats.setTag(htmlTag); + String dbTagName = jdbcTemplate.queryForObject("select name from tags where name=?", String.class, htmlTagName); + assertEquals("db tags should not be escaped", dbTagName, htmlTag.getName()); + 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); + } } diff --git a/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java b/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java index 11ca75cf..dca09189 100644 --- a/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java +++ b/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java @@ -1,17 +1,21 @@ package com.juick.xmpp.server; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.juick.Message; import com.juick.User; import com.juick.components.JuickBot; import com.juick.components.XMPPServer; import com.juick.components.configuration.XmppAppConfiguration; -import com.juick.configuration.MockDataConfiguration; +import com.juick.configuration.RepositoryConfiguration; import com.juick.server.configuration.BaseWebConfiguration; -import com.juick.service.UserService; +import com.juick.service.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; @@ -24,24 +28,32 @@ import rocks.xmpp.core.stanza.model.server.ServerMessage; import javax.inject.Inject; import java.lang.reflect.InvocationTargetException; +import java.text.ParseException; +import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@ContextConfiguration +@ContextConfiguration(classes = { + BaseWebConfiguration.class, XmppAppConfiguration.class, RepositoryConfiguration.class +}) public class XMPPServerTests { @Configuration - @Import(value = { - BaseWebConfiguration.class, XmppAppConfiguration.class, MockDataConfiguration.class - }) - static class Config { } - + @ComponentScan(basePackages = "com.juick.www.controllers") + static class Config { + @Bean + public ImagesService imagesService() { + return new MockImagesService(); + } + } @Inject private WebApplicationContext wac; @Inject @@ -50,6 +62,14 @@ public class XMPPServerTests { private JuickBot bot; @Inject private UserService userService; + @Inject + private MessagesService messagesService; + @Inject + private TagService tagService; + @Inject + private SubscriptionService subscriptionService; + @Inject + private JdbcTemplate jdbcTemplate; private MockMvc mockMvc; @@ -76,4 +96,89 @@ public class XMPPServerTests { // tag help have two lines, others have 1 assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(17)); } + + @Test + public void protocolTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, ParseException, JsonProcessingException { + int uid = userService.createUser("me", "secret"); + User user = userService.getUserByUID(uid).orElse(new User()); + int mid = messagesService.createMessage(uid, "*yo yoyo", null, null); + assertEquals("should be message", true, + bot.processCommand(user, Jid.of("test@localhost"), String.format("#%d", mid)).get().startsWith("@me")); + mid = messagesService.getUserBlog(user.getUid(), -1, 0).stream().reduce((first, second) -> second).get(); + assertEquals("text should match", "yoyo", + messagesService.getMessage(mid).getText()); + assertEquals("tag should match", "yo", + tagService.getMessageTags(mid).get(0).getTag().getName()); + int readerUid = userService.createUser("dummyReader", "dummySecret"); + User readerUser = userService.getUserByUID(readerUid).orElse(new User()); + assertEquals("should be subscribed", "Subscribed", + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "S #" + mid).get()); + /* TODO: move from juick-legacy + assertEquals("should be favorited", "Message added to your recommendations", + juickProtocol.getReply(readerUser, "! #" + mid)); + */ + assertEquals("number of subscribed users should match", 1, + subscriptionService.getUsersSubscribedToComments(mid, uid).size()); + assertEquals("should be subscribed", "Subscribed", + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "S @" + user.getName()).get()); + List<User> friends = userService.getUserFriends(readerUid); + assertEquals("number of friend users should match", 2, + friends.size()); + assertEquals("number of reader users should match", 1, + userService.getUserReaders(uid).size()); + String expectedReply = "Reply posted.\n#" + mid + "/1 " + + "http://juick.com/" + mid + "#1"; + String expectedSecondReply = "Reply posted.\n#" + mid + "/2 " + + "http://juick.com/" + mid + "#2"; + assertEquals("should be reply", expectedReply, + bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + " yoyo").get()); + assertEquals("should be second reply", expectedSecondReply, + bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + "/1 yoyo").get()); + Message reply = messagesService.getReplies(mid).stream().filter(m -> m.getRid() == 2).findFirst() + .orElse(new Message()); + assertEquals("should be reply to first comment", 1, reply.getReplyto()); + assertNotEquals("tags should NOT be updated", "Tags are updated", + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "#" + mid + " *yo *there").get()); + assertEquals("tags should be updated", "Tags are updated", + bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there").get()); + assertEquals("number of tags should match", 2, + tagService.getMessageTags(mid).size()); + assertEquals("should be blacklisted", "Tag added to your blacklist", + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "BL *there").get()); + assertEquals("number of subscribed users should match", 0, + subscriptionService.getSubscribedUsers(uid, mid).size()); + assertEquals("tags should be updated", "Tags are updated", + bot.processCommand(user, Jid.of("test@localhost"), "#" + mid + " *there").get()); + assertEquals("number of tags should match", 1, + tagService.getMessageTags(mid).size()); + int taggerUid = userService.createUser("dummyTagger", "dummySecret"); + User taggerUser = userService.getUserByUID(taggerUid).orElse(new User()); + assertEquals("should be subscribed", "Subscribed", + bot.processCommand(taggerUser, Jid.of("tagger@localhost"), "S *yo").get()); + assertEquals("number of subscribed users should match", 2, + subscriptionService.getSubscribedUsers(uid, mid).size()); + assertEquals("should be unsubscribed", "Unsubscribed from yo", + bot.processCommand(taggerUser, Jid.of("tagger@localhost"), "U *yo").get()); + assertEquals("number of subscribed users should match", 1, + subscriptionService.getSubscribedUsers(uid, mid).size()); + assertEquals("number of readers should match", 1, + userService.getUserReaders(uid).size()); + String readerFeed = bot.processCommand(readerUser, Jid.of("dummy@localhost"), "#").get(); + assertEquals("description should match", true, readerFeed.startsWith("Your feed")); + assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getName(), + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "U @" + user.getName()).get()); + assertEquals("number of readers should match", 0, + userService.getUserReaders(uid).size()); + assertEquals("number of friends should match", 1, + userService.getUserFriends(uid).size()); + assertEquals("should be unsubscribed", "Unsubscribed from #" + mid, + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "u #" + mid).get()); + assertEquals("number of subscribed users should match", 0, + subscriptionService.getUsersSubscribedToComments(mid, uid).size()); + assertNotEquals("should NOT be deleted", String.format("Message %s deleted", mid), + bot.processCommand(readerUser, Jid.of("dummy@localhost"), "D #" + mid).get()); + assertEquals("should be deleted", String.format("Message %s deleted", mid), + bot.processCommand(user, Jid.of("test@localhost"), "D #" + mid).get()); + assertEquals("should not have messages", 0, messagesService.getAll(user.getUid(), 0).size()); + } } diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java deleted file mode 100644 index 44827ce6..00000000 --- a/src/test/java/com/juick/tests/ApiTests.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (C) 2008-2017, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package com.juick.tests; - -import ch.vorburger.exec.ManagedProcessException; -import ch.vorburger.mariadb4j.DB; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.juick.Message; -import com.juick.Tag; -import com.juick.User; -import com.juick.server.helpers.TagStats; -import com.juick.server.protocol.JuickProtocol; -import com.juick.server.protocol.ProtocolListener; -import com.juick.service.*; -import com.juick.service.search.SearchService; -import com.juick.www.WebApp; -import org.apache.commons.dbcp2.BasicDataSource; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.DependsOn; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.TransactionManagementConfigurer; -import ru.sape.Sape; - -import javax.inject.Inject; -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; -import static org.junit.Assert.assertNotEquals; - -/** - * Created by vt on 14.01.2016. - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -public class ApiTests { - @Configuration - @ComponentScan(basePackages = {"com.juick.service", "com.juick.server.protocol"}) - static class Config implements TransactionManagementConfigurer { - @Bean - public BasicDataSource dataSource() { - try { - DB db = DB.newEmbeddedDB(33306); - db.start(); - db.createDB("juick"); - db.source("schema.sql"); - BasicDataSource dataSource = new BasicDataSource(); - dataSource.setDriverClassName("com.mysql.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://localhost:33306/juick?autoReconnect=true&user=root"); - - dataSource.setValidationQuery("select 1"); - - return dataSource; - } catch (ManagedProcessException e) { - return null; - } - } - - @Bean - public PlatformTransactionManager transactionManager() { - return new DataSourceTransactionManager(dataSource()); - } - - @Override - public PlatformTransactionManager annotationDrivenTransactionManager() { - return transactionManager(); - } - - @Bean - @DependsOn("dataSource") - public JdbcTemplate jdbcTemplate() { - return new JdbcTemplate(dataSource()); - } - @Bean - public SearchService emptySearchService() { - return new SearchService() { - @Override - public void setMaxResult(int maxResult) { - } - - @Override - public List<Integer> searchInAllMessages(String searchString, int messageIdBefore) { - return Collections.emptyList(); - } - - @Override - public List<Integer> searchByStringAndUser(String searchString, int userId, int messageIdBefore) { - return Collections.emptyList(); - } - }; - } - @Bean - public JuickProtocol juickProtocol() { - return new JuickProtocol("http://localhost:8080/"); - } - @Bean - public Sape sape() { - return Mockito.mock(Sape.class); - } - @Bean - public WebApp webApp() { - return Mockito.mock(WebApp.class); - } - @Bean - public ImagesService imagesService() { - return Mockito.mock(ImagesService.class); - } - } - - @Inject - UserService userService; - @Inject - MessagesService messagesService; - @Inject - TagService tagService; - @Inject - SubscriptionService subscriptionService; - @Inject - JdbcTemplate jdbcTemplate; - @Inject - JuickProtocol juickProtocol; - - @Mock - ProtocolListener listener; - - @Before - public void setup() { - userService.createUser("ugnich", "secret"); - userService.createUser("juick", "secret"); - MockitoAnnotations.initMocks(this); - } - @Test - public void messageTests() { - int user_id = userService.createUser("mmmme", "secret"); - User user = userService.getUserByUID(user_id).orElse(new User()); - assertEquals("it should be me", "mmmme", user.getName()); - int mid = messagesService.createMessage(user_id, "yo", null, new ArrayList<>()); - Message msg = messagesService.getMessage(mid); - assertEquals("yo", msg.getText()); - User me = msg.getUser(); - assertEquals("mmmme", me.getName()); - assertEquals("mmmme", messagesService.getMessageAuthor(mid).getName()); - int tagID = tagService.createTag("weather"); - Tag tag = tagService.getTag(tagID); - List<Tag> tagList = new ArrayList<>(); - tagList.add(tag); - int mid2 = messagesService.createMessage(user_id, "yo2", null, tagList); - Message msg2 = messagesService.getMessage(mid2); - assertEquals(1, msg2.getTags().size()); - assertEquals("we already have ugnich", -1, userService.createUser("ugnich", "x")); - int ugnich_id = userService.createUser("hugnich", "x"); - User ugnich = userService.getUserByUID(ugnich_id).orElse(new User()); - int rid = messagesService.createReply(msg2.getMid(), 0, ugnich.getUid(), "bla-bla", null); - assertEquals(1, rid); - Message msg3 = messagesService.getMessage(mid2); - assertEquals(1, msg3.getReplies()); - assertEquals("weather", msg3.getTags().get(0).getName()); - assertEquals(ugnich.getUid(), userService.checkPassword(ugnich.getName(), "x")); - assertEquals(-1, userService.checkPassword(ugnich.getName(), "xy")); - subscriptionService.subscribeMessage(msg.getMid(), ugnich.getUid()); - assertEquals(1, subscriptionService.getUsersSubscribedToComments(msg.getMid(), user.getUid()).size()); - messagesService.deleteMessage(user_id, mid); - messagesService.deleteMessage(user_id, mid2); - String htmlTagName = ">_<"; - Tag htmlTag = tagService.getTag(htmlTagName, true); - TagStats htmlTagStats = new TagStats(); - htmlTagStats.setTag(htmlTag); - String dbTagName = jdbcTemplate.queryForObject("select name from tags where name=?", String.class, htmlTagName); - assertEquals("db tags should not be escaped", dbTagName, htmlTag.getName()); - 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 - public void protocolTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, ParseException, JsonProcessingException { - juickProtocol.setListener(listener); - assertEquals("juick user should have uid 2", 2, userService.getUIDbyName("juick")); - int uid = userService.createUser("me", "secret"); - User user = userService.getUserByUID(uid).orElse(new User()); - String expectedMessage = "New message posted"; - assertEquals("should be message", true, - juickProtocol.getReply(user, "*yo yoyo").startsWith(expectedMessage)); - int mid = messagesService.getUserBlog(user.getUid(), -1, 0).stream().reduce((first, second) -> second).get(); - assertEquals("text should match", "yoyo", - messagesService.getMessage(mid).getText()); - assertEquals("tag should match", "yo", - tagService.getMessageTags(mid).get(0).getTag().getName()); - assertNotEquals("should not be error", "Error", juickProtocol.getReply(user, "#" + mid)); - assertEquals("should be PONG", "PONG", juickProtocol.getReply(user, "ping")); - int readerUid = userService.createUser("dummyReader", "dummySecret"); - User readerUser = userService.getUserByUID(readerUid).orElse(new User()); - assertEquals("should be subscribed", "Subscribed", - juickProtocol.getReply(readerUser, "S #" + mid)); - /* TODO: move from juick-legacy - assertEquals("should be favorited", "Message added to your recommendations", - juickProtocol.getReply(readerUser, "! #" + mid)); - */ - assertEquals("number of subscribed users should match", 1, - subscriptionService.getUsersSubscribedToComments(mid, uid).size()); - assertEquals("should be subscribed", "Subscribed", - juickProtocol.getReply(readerUser, "S @" + user.getName())); - List<User> friends = userService.getUserFriends(readerUid); - assertEquals("number of friend users should match", 2, - friends.size()); - assertEquals("number of reader users should match", 1, - userService.getUserReaders(uid).size()); - String expectedReply = "Reply posted.\n#" + mid + "/1 " - + juickProtocol.getBaseUri() + mid + "#1"; - String expectedSecondReply = "Reply posted.\n#" + mid + "/2 " - + juickProtocol.getBaseUri() + mid + "#2"; - assertEquals("should be reply", expectedReply, - juickProtocol.getReply(user, "#" + mid + " yoyo")); - assertEquals("should be second reply", expectedSecondReply, - juickProtocol.getReply(user, "#" + mid + "/1 yoyo")); - Message reply = messagesService.getReplies(mid).stream().filter(m -> m.getRid() == 2).findFirst() - .orElse(new Message()); - assertEquals("should be reply to first comment", 1, reply.getReplyto()); - assertNotEquals("tags should NOT be updated", "Tags are updated", - juickProtocol.getReply(readerUser, "#" + mid + " *yo *there")); - assertEquals("tags should be updated", "Tags are updated", - juickProtocol.getReply(user, "#" + mid + " *there")); - assertEquals("number of tags should match", 2, - tagService.getMessageTags(mid).size()); - assertEquals("should be blacklisted", "Tag added to your blacklist", - juickProtocol.getReply(readerUser, "BL *there")); - assertEquals("number of subscribed users should match", 0, - subscriptionService.getSubscribedUsers(uid, mid).size()); - assertEquals("tags should be updated", "Tags are updated", - juickProtocol.getReply(user, "#" + mid + " *there")); - assertEquals("number of tags should match", 1, - tagService.getMessageTags(mid).size()); - int taggerUid = userService.createUser("dummyTagger", "dummySecret"); - User taggerUser = userService.getUserByUID(taggerUid).orElse(new User()); - assertEquals("should be subscribed", "Subscribed", - juickProtocol.getReply(taggerUser, "S *yo")); - assertEquals("number of subscribed users should match", 2, - subscriptionService.getSubscribedUsers(uid, mid).size()); - assertEquals("should be unsubscribed", "Unsubscribed from yo", - juickProtocol.getReply(taggerUser, "U *yo")); - assertEquals("number of subscribed users should match", 1, - subscriptionService.getSubscribedUsers(uid, mid).size()); - assertEquals("number of readers should match", 1, - userService.getUserReaders(uid).size()); - String readerFeed = juickProtocol.getReply(readerUser, "#"); - assertEquals("description should match", true, readerFeed.startsWith("Your feed")); - assertEquals("should be unsubscribed", "Unsubscribed from @" + user.getName(), - juickProtocol.getReply(readerUser, "U @" + user.getName())); - assertEquals("number of readers should match", 0, - userService.getUserReaders(uid).size()); - assertEquals("number of friends should match", 1, - userService.getUserFriends(uid).size()); - assertEquals("should be unsubscribed", "Unsubscribed from #" + mid, - juickProtocol.getReply(readerUser, "u #" + mid)); - assertEquals("number of subscribed users should match", 0, - subscriptionService.getUsersSubscribedToComments(mid, uid).size()); - assertNotEquals("should NOT be deleted", String.format("Message %s deleted", mid), - juickProtocol.getReply(readerUser, "D #" + mid)); - assertEquals("should be deleted", String.format("Message %s deleted", mid), - juickProtocol.getReply(user, "D #" + mid)); - assertEquals("should not have messages", 0, messagesService.getAll(user.getUid(), 0).size()); - } - -} |