Fix SimpleMM test
This commit is contained in:
@@ -2,10 +2,19 @@ package org.jeudego.pairgoth.store
|
||||
|
||||
import org.jeudego.pairgoth.model.ID
|
||||
import org.jeudego.pairgoth.model.Tournament
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class MemoryStore: Store {
|
||||
object MemoryStore: Store {
|
||||
private val tournaments = mutableMapOf<ID, Tournament<*>>()
|
||||
|
||||
// for tests
|
||||
fun reset() {
|
||||
tournaments.clear()
|
||||
_nextTournamentId.set(0)
|
||||
_nextPlayerId.set(0)
|
||||
_nextGameId.set(0)
|
||||
}
|
||||
|
||||
override fun getTournaments(): Map<ID, Map<String, String>> = tournaments.mapValues {
|
||||
mapOf("name" to it.value.shortName)
|
||||
}
|
||||
|
@@ -28,14 +28,12 @@ interface Store {
|
||||
fun deleteTournament(tournament: Tournament<*>)
|
||||
}
|
||||
|
||||
private val memoryStore: Store = MemoryStore()
|
||||
|
||||
fun getStore(request: HttpServletRequest): Store {
|
||||
val storeType = WebappManager.getMandatoryProperty("store")
|
||||
return when (val auth = WebappManager.getMandatoryProperty("auth")) {
|
||||
"none", "sesame" ->
|
||||
when (storeType) {
|
||||
"memory" -> memoryStore
|
||||
"memory" -> MemoryStore
|
||||
"file" -> {
|
||||
val filePath = WebappManager.properties.getProperty("store.file.path") ?: "."
|
||||
FileStore(filePath)
|
||||
|
Reference in New Issue
Block a user