Skip to content
Snippets Groups Projects
Commit 3fbef75d authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Fixed possible NullPointerException in CouchDBDao/QuestionService

parent ecb22709
Branches
Tags
No related merge requests found
......@@ -1026,7 +1026,7 @@ public class CouchDBDao implements IDatabaseDao {
);
ViewResults results = this.getDatabase().view(view);
List<Answer> answers = new ArrayList<Answer>();
if (results.getResults().isEmpty()) {
if (results == null || results.getResults() == null || results.getResults().isEmpty()) {
return answers;
}
for (Document d : results.getResults()) {
......
......@@ -18,7 +18,6 @@
*/
package de.thm.arsnova.dao;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -274,8 +273,7 @@ public class StubDatabaseDao implements IDatabaseDao {
@Override
public List<Answer> getMyAnswers(String sessionKey) {
// TODO Auto-generated method stub
return null;
return new ArrayList<Answer>();
}
@Override
......
......@@ -101,4 +101,10 @@ public class QuestionServiceTest {
assertFalse(theQ.isRead());
}
@Test
public void testShouldNotThrowExceptionInMyAnsersCall() {
userService.setUserAuthenticated(true);
assertNotNull(questionService.getMyAnswers("12345678"));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment