Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
a0f995f5
There was an error fetching the commit references. Please try again later.
Commit
a0f995f5
authored
12 years ago
by
Paul-Christian Volkmer
Browse files
Options
Downloads
Patches
Plain Diff
Added stub database DAO that should be used in tests instead of real db
parent
072b033c
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java
+63
-0
63 additions, 0 deletions
src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java
with
63 additions
and
0 deletions
src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java
0 → 100644
+
63
−
0
View file @
a0f995f5
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
>();
@Override
public
void
cleanFeedbackVotes
(
int
cleanupFeedbackDelay
)
{
stubSessions
.
clear
();
}
@Override
public
Session
getSession
(
String
keyword
)
{
return
stubSessions
.
get
(
keyword
);
}
@Override
public
Session
saveSession
(
Session
session
)
{
stubSessions
.
put
(
session
.
getKeyword
(),
session
);
return
session
;
}
@Override
public
Feedback
getFeedback
(
String
keyword
)
{
return
stubFeedbacks
.
get
(
keyword
);
}
@Override
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
));
stubFeedbacks
.
put
(
keyword
,
sessionFeedback
);
return
true
;
}
@Override
public
boolean
sessionKeyAvailable
(
String
keyword
)
{
return
(
stubSessions
.
get
(
keyword
)
!=
null
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment