summaryrefslogtreecommitdiff
path: root/sw-server/src/test/kotlin
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2019-05-31 20:19:34 +0200
committerjbion <joffrey.bion@amadeus.com>2019-07-08 19:21:15 +0200
commitc3fc62e7117b2e970eea4eb84137b6624063fb6d (patch)
treebd9a29c611f78227519729e54ec18b7ac530740e /sw-server/src/test/kotlin
parentRemove useless Travis CI config (diff)
downloadseven-wonders-c3fc62e7117b2e970eea4eb84137b6624063fb6d.tar.gz
seven-wonders-c3fc62e7117b2e970eea4eb84137b6624063fb6d.tar.bz2
seven-wonders-c3fc62e7117b2e970eea4eb84137b6624063fb6d.zip
Create multiplatform SevenWondersClient based on Krossbow
Diffstat (limited to 'sw-server/src/test/kotlin')
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/SevenWondersTest.kt145
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt146
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt)18
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/HomeControllerTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt)6
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt)24
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/TestPrincipal.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/TestPrincipal.kt)2
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt)17
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt)4
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt)2
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/test/TestUtils.kt)2
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/validation/DestinationAccessValidatorTest.kt (renamed from sw-server/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt)10
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersClient.kt31
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersSession.kt70
13 files changed, 189 insertions, 288 deletions
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/SevenWondersTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/SevenWondersTest.kt
deleted file mode 100644
index 01de366a..00000000
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/SevenWondersTest.kt
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.luxons.sevenwonders
-
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.luxons.sevenwonders.test.api.SevenWondersClient
-import org.luxons.sevenwonders.test.api.SevenWondersSession
-import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
-import org.springframework.boot.web.server.LocalServerPort
-import org.springframework.test.context.junit4.SpringRunner
-import java.util.concurrent.TimeUnit
-import kotlin.test.assertEquals
-import kotlin.test.assertNotNull
-import kotlin.test.assertNull
-
-@RunWith(SpringRunner::class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-class SevenWondersTest {
-
- @LocalServerPort
- private val randomServerPort: Int = 0
-
- private lateinit var client: SevenWondersClient
-
- private lateinit var serverUrl: String
-
- @Before
- fun setUpClientAndUrl() {
- client = SevenWondersClient()
- serverUrl = "ws://localhost:$randomServerPort"
- }
-
- private fun disconnect(vararg sessions: SevenWondersSession) {
- for (session in sessions) {
- session.disconnect()
- }
- }
-
- @Test
- fun chooseName() {
- val session = client.connect(serverUrl)
- val playerName = "Test User"
- val player = session.chooseName(playerName)
- assertNotNull(player)
- assertEquals(playerName, player.displayName)
- session.disconnect()
- }
-
- private fun newPlayer(name: String): SevenWondersSession {
- val otherSession = client.connect(serverUrl)
- otherSession.chooseName(name)
- return otherSession
- }
-
- @Test
- fun lobbySubscription_ignoredForOutsiders() {
- val ownerSession = newPlayer("GameOwner")
- val session1 = newPlayer("Player1")
- val session2 = newPlayer("Player2")
- val gameName = "Test Game"
- val lobby = ownerSession.createGame(gameName)
- session1.joinGame(lobby.id)
- session2.joinGame(lobby.id)
-
- val outsiderSession = newPlayer("Outsider")
- val session = outsiderSession.jackstompSession
- val started = session.subscribeEmptyMsgs("/topic/lobby/" + lobby.id + "/started")
-
- ownerSession.startGame(lobby.id)
- val nothing = started.next(1, TimeUnit.SECONDS)
- assertNull(nothing)
- disconnect(ownerSession, session1, session2, outsiderSession)
- }
-
- @Test
- fun createGame_success() {
- val ownerSession = newPlayer("GameOwner")
-
- val gameName = "Test Game"
- val lobby = ownerSession.createGame(gameName)
- assertNotNull(lobby)
- assertEquals(gameName, lobby.name)
-
- disconnect(ownerSession)
- }
-
- @Test
- fun createGame_seenByConnectedPlayers() {
- val otherSession = newPlayer("OtherPlayer")
- val games = otherSession.watchGames()
-
- var receivedLobbies = games.next()
- assertNotNull(receivedLobbies)
- assertEquals(0, receivedLobbies.size)
-
- val ownerSession = newPlayer("GameOwner")
- val gameName = "Test Game"
- val createdLobby = ownerSession.createGame(gameName)
-
- receivedLobbies = games.next()
- assertNotNull(receivedLobbies)
- assertEquals(1, receivedLobbies.size)
- val receivedLobby = receivedLobbies[0]
- assertEquals(createdLobby.id, receivedLobby.id)
- assertEquals(createdLobby.name, receivedLobby.name)
-
- disconnect(ownerSession, otherSession)
- }
-
- @Test
- fun startGame_3players() {
- val session1 = newPlayer("Player1")
- val session2 = newPlayer("Player2")
-
- val lobby = session1.createGame("Test Game")
- session2.joinGame(lobby.id)
-
- val session3 = newPlayer("Player3")
- session3.joinGame(lobby.id)
-
- session1.startGame(lobby.id)
-
- val turns1 = session1.watchTurns()
- val turns2 = session2.watchTurns()
- val turns3 = session3.watchTurns()
- session1.sayReady()
- session2.sayReady()
- session3.sayReady()
- val turn1 = turns1.next()
- val turn2 = turns2.next()
- val turn3 = turns3.next()
- assertNotNull(turn1)
- assertNotNull(turn2)
- assertNotNull(turn3)
-
- disconnect(session1, session2, session3)
- }
-
- @After
- fun tearDown() {
- client.stop()
- }
-}
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
new file mode 100644
index 00000000..4771076d
--- /dev/null
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt
@@ -0,0 +1,146 @@
+package org.luxons.sevenwonders.server
+
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withTimeout
+import kotlinx.coroutines.withTimeoutOrNull
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.client.SevenWondersClient
+import org.luxons.sevenwonders.client.SevenWondersSession
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
+import org.springframework.boot.web.server.LocalServerPort
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+import kotlin.test.assertNull
+
+@RunWith(SpringRunner::class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+class SevenWondersTest {
+
+ @LocalServerPort
+ private val randomServerPort: Int = 0
+
+ private lateinit var client: SevenWondersClient
+
+ private lateinit var serverUrl: String
+
+ @Before
+ fun setUpClientAndUrl() {
+ client = SevenWondersClient()
+ serverUrl = "ws://localhost:$randomServerPort"
+ }
+
+ private suspend fun disconnect(vararg sessions: SevenWondersSession) {
+ for (session in sessions) {
+ session.disconnect()
+ }
+ }
+
+ @Test
+ fun chooseName() {
+ runBlocking {
+ val session = client.connect(serverUrl)
+ val playerName = "Test User"
+ val player = session.chooseName(playerName)
+ assertNotNull(player)
+ assertEquals(playerName, player.displayName)
+ session.disconnect()
+ }
+ }
+
+ private suspend fun newPlayer(name: String): SevenWondersSession = client.connect(serverUrl).apply {
+ chooseName(name)
+ }
+
+ @Test
+ fun lobbySubscription_ignoredForOutsiders() {
+ runBlocking {
+ val ownerSession = newPlayer("GameOwner")
+ val session1 = newPlayer("Player1")
+ val session2 = newPlayer("Player2")
+ val gameName = "Test Game"
+ val lobby = ownerSession.createGame(gameName)
+ session1.joinGame(lobby.id)
+ session2.joinGame(lobby.id)
+
+ val outsiderSession = newPlayer("Outsider")
+ val (started) = outsiderSession.watchGameStart(lobby.id)
+
+ ownerSession.startGame(lobby.id)
+ val nothing = withTimeoutOrNull(30) { started.receive() }
+ assertNull(nothing)
+ disconnect(ownerSession, session1, session2, outsiderSession)
+ }
+ }
+
+ @Test
+ fun createGame_success() {
+ runBlocking {
+ val ownerSession = newPlayer("GameOwner")
+
+ val gameName = "Test Game"
+ val lobby = ownerSession.createGame(gameName)
+ assertNotNull(lobby)
+ assertEquals(gameName, lobby.name)
+
+ disconnect(ownerSession)
+ }
+ }
+
+ @Test
+ fun createGame_seenByConnectedPlayers() {
+ runBlocking {
+ val otherSession = newPlayer("OtherPlayer")
+ val (games) = otherSession.watchGames()
+
+ var receivedLobbies = withTimeout(500) { games.receive() }
+ assertNotNull(receivedLobbies)
+ assertEquals(0, receivedLobbies.size)
+
+ val ownerSession = newPlayer("GameOwner")
+ val gameName = "Test Game"
+ val createdLobby = ownerSession.createGame(gameName)
+
+ receivedLobbies = withTimeout(500) { games.receive() }
+ assertNotNull(receivedLobbies)
+ assertEquals(1, receivedLobbies.size)
+ val receivedLobby = receivedLobbies[0]
+ assertEquals(createdLobby.id, receivedLobby.id)
+ assertEquals(createdLobby.name, receivedLobby.name)
+
+ disconnect(ownerSession, otherSession)
+ }
+ }
+
+ @Test
+ fun startGame_3players() = runBlocking {
+ val session1 = newPlayer("Player1")
+ val session2 = newPlayer("Player2")
+
+ val lobby = session1.createGame("Test Game")
+ session2.joinGame(lobby.id)
+
+ val session3 = newPlayer("Player3")
+ session3.joinGame(lobby.id)
+
+ session1.startGame(lobby.id)
+
+ val (turns1) = session1.watchTurns()
+ val (turns2) = session2.watchTurns()
+ val (turns3) = session3.watchTurns()
+ session1.sayReady()
+ session2.sayReady()
+ session3.sayReady()
+ val turn1 = turns1.receive()
+ val turn2 = turns2.receive()
+ val turn3 = turns3.receive()
+ assertNotNull(turn1)
+ assertNotNull(turn2)
+ assertNotNull(turn3)
+
+ disconnect(session1, session2, session3)
+ }
+}
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt
index 343b7f34..804b5f6e 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt
@@ -1,15 +1,15 @@
-package org.luxons.sevenwonders.controllers
+package org.luxons.sevenwonders.server.controllers
import org.junit.Before
import org.junit.Test
-import org.luxons.sevenwonders.actions.CreateGameAction
-import org.luxons.sevenwonders.actions.JoinGameAction
-import org.luxons.sevenwonders.api.toDTO
-import org.luxons.sevenwonders.controllers.GameBrowserController.UserAlreadyInGameException
-import org.luxons.sevenwonders.repositories.LobbyRepository
-import org.luxons.sevenwonders.repositories.PlayerNotFoundException
-import org.luxons.sevenwonders.repositories.PlayerRepository
-import org.luxons.sevenwonders.test.mockSimpMessagingTemplate
+import org.luxons.sevenwonders.model.api.actions.CreateGameAction
+import org.luxons.sevenwonders.model.api.actions.JoinGameAction
+import org.luxons.sevenwonders.server.api.toDTO
+import org.luxons.sevenwonders.server.controllers.GameBrowserController.UserAlreadyInGameException
+import org.luxons.sevenwonders.server.repositories.LobbyRepository
+import org.luxons.sevenwonders.server.repositories.PlayerNotFoundException
+import org.luxons.sevenwonders.server.repositories.PlayerRepository
+import org.luxons.sevenwonders.server.test.mockSimpMessagingTemplate
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/HomeControllerTest.kt
index 3374a025..c2c3c05d 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/HomeControllerTest.kt
@@ -1,8 +1,8 @@
-package org.luxons.sevenwonders.controllers
+package org.luxons.sevenwonders.server.controllers
import org.junit.Test
-import org.luxons.sevenwonders.actions.ChooseNameAction
-import org.luxons.sevenwonders.repositories.PlayerRepository
+import org.luxons.sevenwonders.model.api.actions.ChooseNameAction
+import org.luxons.sevenwonders.server.repositories.PlayerRepository
import kotlin.test.assertEquals
class HomeControllerTest {
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
index 90db48f5..e8b2a9c0 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
@@ -1,20 +1,20 @@
-package org.luxons.sevenwonders.controllers
+package org.luxons.sevenwonders.server.controllers
import org.junit.Before
import org.junit.Test
-import org.luxons.sevenwonders.actions.ReorderPlayersAction
-import org.luxons.sevenwonders.actions.UpdateSettingsAction
+import org.luxons.sevenwonders.model.api.actions.ReorderPlayersAction
+import org.luxons.sevenwonders.model.api.actions.UpdateSettingsAction
import org.luxons.sevenwonders.model.CustomizableSettings
import org.luxons.sevenwonders.model.WonderSidePickMethod.ALL_A
-import org.luxons.sevenwonders.lobby.Lobby
-import org.luxons.sevenwonders.lobby.Player
-import org.luxons.sevenwonders.lobby.PlayerIsNotOwnerException
-import org.luxons.sevenwonders.lobby.PlayerNotInLobbyException
-import org.luxons.sevenwonders.lobby.State
-import org.luxons.sevenwonders.repositories.LobbyRepository
-import org.luxons.sevenwonders.repositories.PlayerNotFoundException
-import org.luxons.sevenwonders.repositories.PlayerRepository
-import org.luxons.sevenwonders.test.mockSimpMessagingTemplate
+import org.luxons.sevenwonders.server.lobby.Lobby
+import org.luxons.sevenwonders.server.lobby.Player
+import org.luxons.sevenwonders.server.lobby.PlayerIsNotOwnerException
+import org.luxons.sevenwonders.server.lobby.PlayerNotInLobbyException
+import org.luxons.sevenwonders.model.api.State
+import org.luxons.sevenwonders.server.repositories.LobbyRepository
+import org.luxons.sevenwonders.server.repositories.PlayerNotFoundException
+import org.luxons.sevenwonders.server.repositories.PlayerRepository
+import org.luxons.sevenwonders.server.test.mockSimpMessagingTemplate
import java.util.HashMap
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/TestPrincipal.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/TestPrincipal.kt
index 76b0f8fa..6a57c570 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/controllers/TestPrincipal.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/TestPrincipal.kt
@@ -1,4 +1,4 @@
-package org.luxons.sevenwonders.controllers
+package org.luxons.sevenwonders.server.controllers
import java.security.Principal
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt
index bf1ea4bf..80f5e866 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/lobby/LobbyTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt
@@ -1,4 +1,4 @@
-package org.luxons.sevenwonders.lobby
+package org.luxons.sevenwonders.server.lobby
import org.junit.Assume.assumeTrue
import org.junit.Before
@@ -8,14 +8,15 @@ import org.junit.experimental.theories.DataPoints
import org.junit.experimental.theories.Theories
import org.junit.experimental.theories.Theory
import org.junit.runner.RunWith
-import org.luxons.sevenwonders.model.CustomizableSettings
import org.luxons.sevenwonders.engine.data.GameDefinition
-import org.luxons.sevenwonders.lobby.Lobby.GameAlreadyStartedException
-import org.luxons.sevenwonders.lobby.Lobby.PlayerListMismatchException
-import org.luxons.sevenwonders.lobby.Lobby.PlayerNameAlreadyUsedException
-import org.luxons.sevenwonders.lobby.Lobby.PlayerOverflowException
-import org.luxons.sevenwonders.lobby.Lobby.PlayerUnderflowException
-import org.luxons.sevenwonders.lobby.Lobby.UnknownPlayerException
+import org.luxons.sevenwonders.model.CustomizableSettings
+import org.luxons.sevenwonders.model.api.State
+import org.luxons.sevenwonders.server.lobby.Lobby.GameAlreadyStartedException
+import org.luxons.sevenwonders.server.lobby.Lobby.PlayerListMismatchException
+import org.luxons.sevenwonders.server.lobby.Lobby.PlayerNameAlreadyUsedException
+import org.luxons.sevenwonders.server.lobby.Lobby.PlayerOverflowException
+import org.luxons.sevenwonders.server.lobby.Lobby.PlayerUnderflowException
+import org.luxons.sevenwonders.server.lobby.Lobby.UnknownPlayerException
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt
index 446feee6..c59dc49f 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/repositories/LobbyRepositoryTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt
@@ -1,8 +1,8 @@
-package org.luxons.sevenwonders.repositories
+package org.luxons.sevenwonders.server.repositories
import org.junit.Before
import org.junit.Test
-import org.luxons.sevenwonders.lobby.Player
+import org.luxons.sevenwonders.server.lobby.Player
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
import kotlin.test.assertSame
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt
index aeedc54c..fc016903 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/repositories/PlayerRepositoryTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt
@@ -1,4 +1,4 @@
-package org.luxons.sevenwonders.repositories
+package org.luxons.sevenwonders.server.repositories
import org.junit.Before
import org.junit.Test
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/TestUtils.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt
index 9f328c5f..6eaa7e49 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/TestUtils.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt
@@ -1,4 +1,4 @@
-package org.luxons.sevenwonders.test
+package org.luxons.sevenwonders.server.test
import org.springframework.messaging.Message
import org.springframework.messaging.MessageChannel
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/validation/DestinationAccessValidatorTest.kt
index 85d03e99..c5ef3f44 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/validation/DestinationAccessValidatorTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/validation/DestinationAccessValidatorTest.kt
@@ -1,11 +1,11 @@
-package org.luxons.sevenwonders.validation
+package org.luxons.sevenwonders.server.validation
import org.junit.Before
import org.junit.Test
-import org.luxons.sevenwonders.lobby.Lobby
-import org.luxons.sevenwonders.lobby.Player
-import org.luxons.sevenwonders.repositories.LobbyNotFoundException
-import org.luxons.sevenwonders.repositories.LobbyRepository
+import org.luxons.sevenwonders.server.lobby.Lobby
+import org.luxons.sevenwonders.server.lobby.Player
+import org.luxons.sevenwonders.server.repositories.LobbyNotFoundException
+import org.luxons.sevenwonders.server.repositories.LobbyRepository
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersClient.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersClient.kt
deleted file mode 100644
index 95384e06..00000000
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersClient.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.luxons.sevenwonders.test.api
-
-import com.fasterxml.jackson.module.kotlin.KotlinModule
-import org.hildan.jackstomp.JackstompClient
-import org.luxons.sevenwonders.config.SEVEN_WONDERS_WS_ENDPOINT
-import org.springframework.messaging.converter.MappingJackson2MessageConverter
-import java.util.concurrent.ExecutionException
-import java.util.concurrent.TimeoutException
-
-class SevenWondersClient {
-
- private val client: JackstompClient
-
- init {
- val mappingJackson2MessageConverter = MappingJackson2MessageConverter()
- mappingJackson2MessageConverter.objectMapper.registerModule(KotlinModule())
-
- client = JackstompClient()
- client.webSocketClient.messageConverter = mappingJackson2MessageConverter
- }
-
- @Throws(InterruptedException::class, ExecutionException::class, TimeoutException::class)
- fun connect(serverUrl: String): SevenWondersSession {
- val session = client.syncConnect(serverUrl + SEVEN_WONDERS_WS_ENDPOINT)
- return SevenWondersSession(session)
- }
-
- fun stop() {
- client.stop()
- }
-}
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersSession.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersSession.kt
deleted file mode 100644
index f02a5c3b..00000000
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/test/api/SevenWondersSession.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.luxons.sevenwonders.test.api
-
-import org.hildan.jackstomp.Channel
-import org.hildan.jackstomp.JackstompSession
-import org.luxons.sevenwonders.actions.ChooseNameAction
-import org.luxons.sevenwonders.actions.CreateGameAction
-import org.luxons.sevenwonders.actions.JoinGameAction
-import org.luxons.sevenwonders.api.LobbyDTO
-import org.luxons.sevenwonders.api.PlayerDTO
-import org.luxons.sevenwonders.errors.ErrorDTO
-import org.luxons.sevenwonders.model.PlayerTurnInfo
-import kotlin.test.assertEquals
-import kotlin.test.assertNotNull
-import kotlin.test.assertTrue
-
-class SevenWondersSession(val jackstompSession: JackstompSession) {
-
- fun disconnect() {
- jackstompSession.disconnect()
- }
-
- fun watchErrors(): Channel<ErrorDTO> = jackstompSession.subscribe("/user/queue/errors", ErrorDTO::class.java)
-
- @Throws(InterruptedException::class)
- fun chooseName(displayName: String): PlayerDTO {
- val action = ChooseNameAction(displayName)
- return jackstompSession.request(action, PlayerDTO::class.java, "/app/chooseName", "/user/queue/nameChoice")
- }
-
- fun watchGames(): Channel<Array<LobbyDTO>> {
- return jackstompSession.subscribe("/topic/games", Array<LobbyDTO>::class.java)
- }
-
- @Throws(InterruptedException::class)
- fun createGame(gameName: String): LobbyDTO {
- val action = CreateGameAction(gameName)
- return jackstompSession.request(action, LobbyDTO::class.java, "/app/lobby/create", "/user/queue/lobby/joined")
- }
-
- @Throws(InterruptedException::class)
- fun joinGame(gameId: Long): LobbyDTO {
- val action = JoinGameAction(gameId)
- val lobby =
- jackstompSession.request(action, LobbyDTO::class.java, "/app/lobby/join", "/user/queue/lobby/joined")
- assertNotNull(lobby)
- assertEquals(gameId, lobby.id)
- return lobby
- }
-
- fun watchLobbyUpdates(gameId: Long): Channel<LobbyDTO> =
- jackstompSession.subscribe("/topic/lobby/$gameId/updated", LobbyDTO::class.java)
-
- fun watchLobbyStart(gameId: Long): Channel<LobbyDTO> =
- jackstompSession.subscribe("/topic/lobby/$gameId/started", LobbyDTO::class.java)
-
- @Throws(InterruptedException::class)
- fun startGame(gameId: Long) {
- val sendDestination = "/app/lobby/startGame"
- val receiveDestination = "/topic/lobby/$gameId/started"
- val received = jackstompSession.request(null, sendDestination, receiveDestination)
- assertTrue(received)
- }
-
- fun sayReady() {
- jackstompSession.send("/app/game/sayReady", "")
- }
-
- fun watchTurns(): Channel<PlayerTurnInfo> =
- jackstompSession.subscribe("/user/queue/game/turn", PlayerTurnInfo::class.java)
-}
bgstack15