diff --git a/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java b/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java index cd6badd8e62649cbcdcfadc77c2bd35cc29801fe..89f8ee6c860e11dd7167d474cb93d56b47b8a0ae 100644 --- a/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java +++ b/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java @@ -54,7 +54,7 @@ public class AudienceQuestionController extends AbstractController { @RequestParam final String sessionkey, final HttpServletResponse response ) { - response.addHeader("X-Deprecated-API", "1"); + response.addHeader(X_DEPRECATED_API, "1"); return questionService.getInterposedCount(sessionkey); } @@ -64,7 +64,7 @@ public class AudienceQuestionController extends AbstractController { @RequestParam("sessionkey") final String sessionkey, final HttpServletResponse response ) { - response.addHeader("X-Deprecated-API", "1"); + response.addHeader(X_DEPRECATED_API, "1"); return questionService.getInterposedReadingCount(sessionkey); } diff --git a/src/test/java/de/thm/arsnova/controller/FeedbackControllerTest.java b/src/test/java/de/thm/arsnova/controller/FeedbackControllerTest.java index ee8364a34fb8df444d11893660bb04deb08b53c7..e0eab60599a4dc1831110e9eba9b9c39e99321f7 100644 --- a/src/test/java/de/thm/arsnova/controller/FeedbackControllerTest.java +++ b/src/test/java/de/thm/arsnova/controller/FeedbackControllerTest.java @@ -2,6 +2,7 @@ package de.thm.arsnova.controller; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.junit.Before; @@ -68,6 +69,15 @@ public class FeedbackControllerTest { public void testShouldReturnFeedback() throws Exception { userService.setUserAuthenticated(true); mockMvc.perform(get("/session/87654321/feedback").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); + .andExpect(status().isOk()) + .andExpect(content().string("{\"values\":[0,0,0,0]}")); + } + + @Test + public void testShouldReturnXDeprecatedApiHeaderForFeedback() throws Exception { + userService.setUserAuthenticated(true); + mockMvc.perform(get("/session/87654321/feedback").accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(header().string(AbstractController.X_DEPRECATED_API, "1")); } } diff --git a/src/test/java/de/thm/arsnova/controller/LecturerQuestionControllerTest.java b/src/test/java/de/thm/arsnova/controller/LecturerQuestionControllerTest.java index cd68100c7aa493a3e0fed60d24b7a3043f0e1cb2..23833aede024d4dfe03a662e0e5d46920371506d 100644 --- a/src/test/java/de/thm/arsnova/controller/LecturerQuestionControllerTest.java +++ b/src/test/java/de/thm/arsnova/controller/LecturerQuestionControllerTest.java @@ -1,6 +1,8 @@ package de.thm.arsnova.controller; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.util.ArrayList; @@ -83,4 +85,22 @@ public class LecturerQuestionControllerTest { mockMvc.perform(get("/lecturerquestion/").param("sessionkey", "12345678").param("preparationquestionsonly", "true")) .andExpect(status().isUnauthorized()); } + + @Test + public void testShouldReturnQuestionCount() throws Exception { + setAuthenticated(true, "somebody"); + + mockMvc.perform(get("/lecturerquestion/count").param("sessionkey", "12345678").param("lecturequestionsonly", "true")) + .andExpect(status().isOk()) + .andExpect(content().string("0")); + } + + @Test + public void testShouldReturnXDeprecatedApiHeaderForQuestionCount() throws Exception { + setAuthenticated(true, "somebody"); + + mockMvc.perform(get("/lecturerquestion/count").param("sessionkey", "12345678").param("lecturequestionsonly", "true")) + .andExpect(status().isOk()) + .andExpect(header().string(AbstractController.X_DEPRECATED_API, "1")); + } } diff --git a/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java b/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java index 61668ec38cd63b1ba5b08a1a75208f50edc56f86..a6e46b1c38d5942db4a35d5b2062233e89395d09 100644 --- a/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java +++ b/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java @@ -2,6 +2,8 @@ package de.thm.arsnova.controller; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import java.util.ArrayList; @@ -117,4 +119,22 @@ public class SessionControllerTest { mockMvc.perform(get("/session/")) .andExpect(status().isNotImplemented()); } + + @Test + public void testShouldReturnActiveUserCount() throws Exception { + setAuthenticated(false, "ptsr00"); + + mockMvc.perform(get("/session/12345678/activeusercount")) + .andExpect(status().isOk()) + .andExpect(content().string("0")); + } + + @Test + public void testShouldReturnXDeprecatedApiHeaderForActiveUserCount() throws Exception { + setAuthenticated(false, "ptsr00"); + + mockMvc.perform(get("/session/12345678/activeusercount")) + .andExpect(status().isOk()) + .andExpect(header().string(AbstractController.X_DEPRECATED_API, "1")); + } }