aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-06-19 19:14:27 +0300
committerGravatar Vitaly Takmazov2019-06-19 19:14:27 +0300
commitf5136502fd12ec88af216001774d6128d8e6cdaf (patch)
tree9152895316155aca730f40ae7dfaabdf1241b91d /src/test
parent993b4665b11e04ee1b67e16f14292491fbb380bb (diff)
API: add tag stats to /me endpoint
Diffstat (limited to 'src/test')
-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));
+ }
}