From ff3d52d99b0f2e7cc769c8fd3384f23b0b13ee6b Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer <github@pcvolkmer.de> Date: Thu, 17 Sep 2015 19:22:01 +0200 Subject: [PATCH] Fixed type and intended value of stubQuestions.get() In getSkillQuestion() a call to stubQuestions.get() contained an argument with an incompatible class. Session will be converted into String using toString() but this is not what was intended to do here. In saveQuestion() the CouchDB document ID was used, but the sessions keyword should have been used instead. --- .../java/de/thm/arsnova/dao/StubDatabaseDao.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java index 7e3972d1..a1f02390 100644 --- a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java +++ b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java @@ -34,9 +34,9 @@ import de.thm.arsnova.entities.LoggedIn; import de.thm.arsnova.entities.Question; import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.SessionInfo; +import de.thm.arsnova.entities.SortOrder; import de.thm.arsnova.entities.Statistics; import de.thm.arsnova.entities.User; -import de.thm.arsnova.entities.SortOrder; import de.thm.arsnova.entities.transport.ImportExportSession; import de.thm.arsnova.exceptions.NoContentException; import de.thm.arsnova.exceptions.NotFoundException; @@ -126,7 +126,7 @@ public class StubDatabaseDao implements IDatabaseDao { @Override public Question saveQuestion(Session session, Question question) { - List<Question> questions = stubQuestions.get(session.get_id()); + List<Question> questions = stubQuestions.get(session.getKeyword()); questions.add(question); stubQuestions.put(session.get_id(), questions); @@ -141,11 +141,13 @@ public class StubDatabaseDao implements IDatabaseDao { @Override public List<Question> getSkillQuestions(User user, Session session) { - if (session == null) + if (session == null) { throw new NotFoundException(); - List<Question> questions = stubQuestions.get(session); - if (questions == null) + } + List<Question> questions = stubQuestions.get(session.getKeyword()); + if (questions == null) { throw new NoContentException(); + } return questions; } @@ -245,12 +247,12 @@ public class StubDatabaseDao implements IDatabaseDao { @Override public InterposedQuestion getInterposedQuestion(String questionId) { - return this.interposedQuestion; + return interposedQuestion; } @Override public void markInterposedQuestionAsRead(InterposedQuestion question) { - this.interposedQuestion.setRead(true); + interposedQuestion.setRead(true); } @Override -- GitLab