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/tests/ServerTests.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 9b905319..4c72913e 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -2103,4 +2103,22 @@ public class ServerTests {
TopEvent receivedEvent = topEventCaptor.getValue();
assertThat(receivedEvent.getMessage().getUser(), is(ugnich));
}
+ @Test
+ public void tagStatsSpec() throws Exception {
+ String newUserName = "tagger";
+ String newUserSecret = "secret";
+ User newUser = userService.createUser(newUserName, newUserSecret)
+ .orElseThrow(IllegalStateException::new);
+ commandsManager.processCommand(newUser, "*test yo", emptyUri);
+ commandsManager.processCommand(newUser, "*test yo2", emptyUri);
+ commandsManager.processCommand(newUser, "*rare yo3", emptyUri);
+ MvcResult userResponse = mockMvc.perform(get("/api/me").with(httpBasic(newUserName, newUserSecret)))
+ .andExpect(status().isOk()).andReturn();
+ User userData = jsonMapper.readValue(userResponse.getResponse().getContentAsString(), User.class);
+ List<TagStats> userTags = userData.getTagStats();
+ assertThat(userTags.size(), is(2));
+ TagStats rareTagStats = userTags.stream().filter(tagStats -> tagStats.getTag().getName().equals("rare"))
+ .findFirst().orElseThrow(IllegalStateException::new);
+ assertThat(rareTagStats.getUsageCount(), is(1));
+ }
}