GitLab wurde aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Vielen Dank für Ihre Geduld.

Commit a0f995f5 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Added stub database DAO that should be used in tests instead of real db

parent 072b033c
package de.thm.arsnova.dao;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import de.thm.arsnova.entities.Feedback;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.User;
public class StubDatabaseDao implements IDatabaseDao {
private Map<String, Session> stubSessions = new ConcurrentHashMap<String, Session>();
private Map<String, Feedback> stubFeedbacks = new ConcurrentHashMap<String, Feedback>();
public void cleanFeedbackVotes(int cleanupFeedbackDelay) {
public Session getSession(String keyword) {
return stubSessions.get(keyword);
public Session saveSession(Session session) {
stubSessions.put(session.getKeyword(), session);
return session;
public Feedback getFeedback(String keyword) {
return stubFeedbacks.get(keyword);
public boolean saveFeedback(String keyword, int value, User user) {
if (stubFeedbacks.get(keyword) == null) {
stubFeedbacks.put(keyword, new Feedback(0, 0, 0, 0));
Feedback sessionFeedback = stubFeedbacks.get(keyword);
List<Integer> values = sessionFeedback.getValues();
values.set(value, values.get(value) + 1);
sessionFeedback = new Feedback(values.get(0), values.get(1), values.get(2), values.get(3));
return true;
public boolean sessionKeyAvailable(String keyword) {
return (stubSessions.get(keyword) != null);
Markdown is supported
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