diff --git a/src/main/java/de/thm/arsnova/entities/Statistics.java b/src/main/java/de/thm/arsnova/entities/Statistics.java index d8d53a2258e38f3b3d45590a9d547f5c181df8ff..d1faaa10c421ad9fba0e13181a73a365860cea98 100644 --- a/src/main/java/de/thm/arsnova/entities/Statistics.java +++ b/src/main/java/de/thm/arsnova/entities/Statistics.java @@ -11,50 +11,50 @@ public class Statistics { public int getAnswers() { return answers; } - public void setAnswers(int answers) { + public void setAnswers(final int answers) { this.answers = answers; } public int getQuestions() { return questions; } - public void setQuestions(int questions) { + public void setQuestions(final int questions) { this.questions = questions; } public int getOpenSessions() { return openSessions; } - public void setOpenSessions(int openSessions) { + public void setOpenSessions(final int openSessions) { this.openSessions = openSessions; } public int getClosedSessions() { return closedSessions; } - public void setClosedSessions(int closedSessions) { + public void setClosedSessions(final int closedSessions) { this.closedSessions = closedSessions; } public int getActiveUsers() { return activeUsers; } - public void setActiveUsers(int activeUsers) { + public void setActiveUsers(final int activeUsers) { this.activeUsers = activeUsers; } @Override public int hashCode() { return (this.getClass().getName() - + this.activeUsers - + this.answers - + this.closedSessions - + this.openSessions - + this.questions).hashCode(); + + activeUsers + + answers + + closedSessions + + openSessions + + questions).hashCode(); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -62,8 +62,8 @@ public class Statistics { return true; } if (obj instanceof Statistics) { - Statistics other = (Statistics) obj; - return this.hashCode() == other.hashCode(); + final Statistics other = (Statistics) obj; + return hashCode() == other.hashCode(); } return false; diff --git a/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml b/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml index 586f28e30963bf90cfa9dc2477ed7d9d3f38a754..c06457d5453f8ad978b86f2346c2428a93d2e76d 100644 --- a/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml +++ b/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml @@ -22,10 +22,12 @@ class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="favorPathExtension" value="false" /> <property name="favorParameter" value="true" /> + <property name="defaultContentType" value="application/json" /> <property name="mediaTypes"> <value> html=text/html json=application/json + xml=application/xml </value> </property> </bean> diff --git a/src/test/java/de/thm/arsnova/controller/StatisticsControllerTest.java b/src/test/java/de/thm/arsnova/controller/StatisticsControllerTest.java index d41bdee6bae23078d94090e5bbbea353a632e4f4..cc9f7dbddc699977127b160e6ca1dbe868e57838 100644 --- a/src/test/java/de/thm/arsnova/controller/StatisticsControllerTest.java +++ b/src/test/java/de/thm/arsnova/controller/StatisticsControllerTest.java @@ -10,6 +10,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; @@ -43,35 +44,35 @@ public class StatisticsControllerTest { @Test public final void testShouldGetCurrentOnlineUsers() throws Exception { - mockMvc.perform(get("/statistics/activeusercount")) + mockMvc.perform(get("/statistics/activeusercount").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) .andExpect(content().string("0")); } @Test public final void testShouldSendXDeprecatedApiForGetCurrentOnlineUsers() throws Exception { - mockMvc.perform(get("/statistics/activeusercount")) + mockMvc.perform(get("/statistics/activeusercount").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) .andExpect(header().string(AbstractController.X_DEPRECATED_API,"1")); } @Test public final void testShouldGetSessionCount() throws Exception { - mockMvc.perform(get("/statistics/sessioncount")) + mockMvc.perform(get("/statistics/sessioncount").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) .andExpect(content().string("3")); } @Test public final void testShouldSendXDeprecatedApiForGetSessionCount() throws Exception { - mockMvc.perform(get("/statistics/sessioncount")) + mockMvc.perform(get("/statistics/sessioncount").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) .andExpect(header().string(AbstractController.X_DEPRECATED_API,"1")); } @Test public final void testShouldGetStatistics() throws Exception { - mockMvc.perform(get("/statistics")) + mockMvc.perform(get("/statistics").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.answers").value(0)) .andExpect(jsonPath("$.questions").value(0)) @@ -82,7 +83,7 @@ public class StatisticsControllerTest { @Test public final void testShouldGetCacheControlHeaderForStatistics() throws Exception { - mockMvc.perform(get("/statistics")) + mockMvc.perform(get("/statistics").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(header().string("cache-control", "public, max-age=60")); }