aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/juick/server')
-rw-r--r--src/test/java/com/juick/server/MockNotificationListener.java6
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java24
2 files changed, 19 insertions, 11 deletions
diff --git a/src/test/java/com/juick/server/MockNotificationListener.java b/src/test/java/com/juick/server/MockNotificationListener.java
index 4fc9a1d9..c3a929fd 100644
--- a/src/test/java/com/juick/server/MockNotificationListener.java
+++ b/src/test/java/com/juick/server/MockNotificationListener.java
@@ -1,13 +1,13 @@
package com.juick.server;
-import com.juick.service.component.TopEvent;
+import com.juick.service.component.SystemEvent;
import org.springframework.context.ApplicationListener;
import javax.annotation.Nonnull;
-public class MockNotificationListener implements ApplicationListener<TopEvent> {
+public class MockNotificationListener implements ApplicationListener<SystemEvent> {
@Override
- public void onApplicationEvent(@Nonnull TopEvent event) {
+ public void onApplicationEvent(@Nonnull SystemEvent event) {
}
}
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 901d1501..e5d39743 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -18,6 +18,7 @@
package com.juick.server.tests;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -34,6 +35,7 @@ import com.juick.model.CommandResult;
import com.juick.model.PrivateChats;
import com.juick.model.TagStats;
import com.juick.server.*;
+import com.juick.server.api.SystemActivity;
import com.juick.server.api.Users;
import com.juick.server.api.activity.Profile;
import com.juick.server.api.activity.model.Context;
@@ -46,8 +48,7 @@ import com.juick.server.util.HttpUtils;
import com.juick.server.util.ImageUtils;
import com.juick.server.www.WebApp;
import com.juick.service.*;
-import com.juick.service.component.MessageEvent;
-import com.juick.service.component.TopEvent;
+import com.juick.service.component.SystemEvent;
import com.juick.test.util.MockUtils;
import com.juick.util.DateFormattersHolder;
import com.juick.util.MessageUtils;
@@ -1011,8 +1012,8 @@ public class ServerTests {
assertThat(lastRead.apply(ugnich, mid), is(freefdrid));
privacyQueriesService.blacklistUser(ugnich, freefd);
int newfreefdrid = messagesService.createReply(mid, 0, freefd, "from ban", null);
- serverManager.processMessageEvent(new MessageEvent(this, messagesService.getReply(mid, newfreefdrid),
- Collections.emptyList()));
+ serverManager.processSystemEvent(new SystemEvent(this, SystemActivity.message(juick, messagesService.getReply(mid, newfreefdrid),
+ Collections.emptyList())));
assertThat(userService.isReplyToBL(ugnich, messagesService.getReply(mid, newfreefdrid)), is(true));
// TODO: test event listeners correctly
Thread.sleep(2000L);
@@ -2159,16 +2160,16 @@ public class ServerTests {
@MockBean
private MockNotificationListener notificationListener;
@Captor
- protected ArgumentCaptor<TopEvent> topEventCaptor;
+ protected ArgumentCaptor<SystemEvent> topEventCaptor;
@Test
public void topEventShouldNotLossUser() {
Message topMessage = MockUtils.mockMessage(1000, ugnich, "top message");
topMessage.setTo(AnonymousUser.INSTANCE);
- TopEvent event = new TopEvent(this, topMessage);
+ SystemEvent event = new SystemEvent(this, SystemActivity.like(juick, topMessage, Collections.emptyList()));
applicationEventPublisher.publishEvent(event);
Mockito.verify(notificationListener, Mockito.times(1)).onApplicationEvent(topEventCaptor.capture());
- TopEvent receivedEvent = topEventCaptor.getValue();
- assertThat(receivedEvent.getMessage().getUser(), is(ugnich));
+ SystemEvent receivedEvent = topEventCaptor.getValue();
+ assertThat(receivedEvent.getActivity().getMessage().getUser(), is(ugnich));
}
@Test
public void tagStatsSpec() throws Exception {
@@ -2221,4 +2222,11 @@ public class ServerTests {
var authorResult = commandsManager.processCommand(ugnich, String.format("#%d PEOPLE", mid), emptyUri);
assertThat(authorResult.getNewMessage().isPresent(), is(true));
}
+ @Test
+ public void activitySerializationTest() throws JsonProcessingException {
+ var freefd = MockUtils.mockUser(10, "freefd", "secret");
+ var like = SystemActivity.like(MockUtils.mockUser(1, "ugnich", "secret"),
+ MockUtils.mockMessage(1, freefd, "txt"), Collections.singletonList(freefd));
+ var likeStr = jsonMapper.writeValueAsString(like);
+ }
}