aboutsummaryrefslogtreecommitdiff
path: root/juick-www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-10 15:52:27 +0300
committerGravatar Vitaly Takmazov2018-05-10 15:52:27 +0300
commitf2715b10d4f0c2d9fe69b12b96a385e4b845b1d5 (patch)
treec6a3cb1bcd2542df0ced2c835ad8c20d05e739c8 /juick-www
parent62f8b32dc5c1d046ca85232be60e37c05b660a5e (diff)
www: drop event test
Diffstat (limited to 'juick-www')
-rw-r--r--juick-www/src/test/java/com/juick/WebAppTests.java44
1 files changed, 0 insertions, 44 deletions
diff --git a/juick-www/src/test/java/com/juick/WebAppTests.java b/juick-www/src/test/java/com/juick/WebAppTests.java
index 4f6a5057..1041596a 100644
--- a/juick-www/src/test/java/com/juick/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/WebAppTests.java
@@ -23,7 +23,6 @@ import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.css.StyleElement;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.juick.server.component.MessageReadEvent;
import com.juick.service.*;
import com.juick.util.MessageUtils;
import com.juick.www.WebApp;
@@ -40,9 +39,6 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Import;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -53,7 +49,6 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.FileSystemUtils;
-import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.servlet.http.Cookie;
import java.io.FileInputStream;
@@ -62,7 +57,6 @@ import java.io.StringWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -81,7 +75,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@AutoConfigureMockMvc
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = { Application.class})
@TestPropertySource(properties = {"ios_app_id=12345678.com.juick.ExampleApp"})
-@Import(WebAppTests.EventListenerConfig.class)
public class WebAppTests {
@MockBean
private ImagesService imagesService;
@@ -104,8 +97,6 @@ public class WebAppTests {
@Inject
private SubscriptionService subscriptionService;
@Inject
- private MessageReadListener listener;
- @Inject
private ApplicationEventPublisher applicationEventPublisher;
@Inject
@@ -404,7 +395,6 @@ public class WebAppTests {
}
@Test
public void notificationsTests() throws Exception {
- listener.clear();
MvcResult loginResult = mockMvc.perform(post("/login")
.param("username", freefdName)
.param("password", freefdPassword)).andReturn();
@@ -421,39 +411,5 @@ public class WebAppTests {
assertThat(discussionsPage.querySelectorAll("#global a .badge").size(), is(1));
HtmlPage unreadThread = webClient.getPage(String.format("http://localhost:8080/ugnich/%d", mid));
assertThat(unreadThread.querySelectorAll("#global a .badge").size(), is(0));
- assertThat(listener.getUnreadCounts().size(), is(1));
- assertThat(listener.getUnreadCounts().get(0), is(0));
- messagesService.createReply(mid, 0, ugnich, "new reply", null);
- assertThat(messagesService.getUnread(freefd).size(), is(1));
- unreadThread.refresh();
- assertThat(listener.getUnreadCounts().size(), is(2));
- assertThat(listener.getUnreadCounts().get(1), is(0));
- assertThat(freefd.isAnonymous(), is(false));
- }
-
- public static class EventListenerConfig {
- @Bean
- public MessageReadListener listener() {
- return new MessageReadListener();
- }
- }
-
- private static class MessageReadListener implements ApplicationListener<MessageReadEvent> {
- @Inject
- private MessagesService messagesService;
- private List<Integer> unreadCounts = new ArrayList<>();
- @Override
- public void onApplicationEvent(@Nonnull MessageReadEvent event) {
- if (event.getUser().equals(freefd)) {
- unreadCounts.add(messagesService.getUnread(event.getUser()).size());
- }
- }
-
- public List<Integer> getUnreadCounts() {
- return unreadCounts;
- }
- public void clear() {
- unreadCounts.clear();
- }
}
}