summaryrefslogtreecommitdiff
path: root/backend/src/test
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2018-07-14 03:36:03 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2018-07-14 03:36:18 +0200
commit85544d85ec23b3827c9f37a33266d9096da9a07e (patch)
tree907f13b397bbf4aeef64dd175f5a94d9f7e62fc5 /backend/src/test
parentKotlin migration: Spring server (diff)
downloadseven-wonders-85544d85ec23b3827c9f37a33266d9096da9a07e.tar.gz
seven-wonders-85544d85ec23b3827c9f37a33266d9096da9a07e.tar.bz2
seven-wonders-85544d85ec23b3827c9f37a33266d9096da9a07e.zip
Add DTO classes for webservice output
Diffstat (limited to 'backend/src/test')
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt11
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt7
-rw-r--r--backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt2
3 files changed, 10 insertions, 10 deletions
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
index 96d4bc85..97873bc1 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/GameBrowserControllerTest.kt
@@ -5,6 +5,7 @@ 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
@@ -47,8 +48,8 @@ class GameBrowserControllerTest {
val games = gameBrowserController.listGames(principal)
assertFalse(games.isEmpty())
val lobby = games.iterator().next()
- assertSame(lobby, createdLobby)
- assertSame(player, lobby.getPlayers()[0])
+ assertEquals(lobby, createdLobby)
+ assertEquals(player.toDTO(principal.name), lobby.players[0])
}
@Test(expected = PlayerNotFoundException::class)
@@ -82,6 +83,7 @@ class GameBrowserControllerTest {
val createGameAction = CreateGameAction("Test Game")
val createdLobby = gameBrowserController.createGame(createGameAction, ownerPrincipal)
+ assertEquals(owner.toDTO(ownerPrincipal.name), createdLobby.players[0])
val joiner = playerRepository.createOrUpdate("testjoiner", "Test User Joiner")
val joinerPrincipal = TestPrincipal("testjoiner")
@@ -89,9 +91,8 @@ class GameBrowserControllerTest {
val joinedLobby = gameBrowserController.joinGame(joinGameAction, joinerPrincipal)
- assertSame(createdLobby, joinedLobby)
- assertSame(owner, joinedLobby.getPlayers()[0])
- assertSame(joiner, joinedLobby.getPlayers()[1])
+ assertEquals(owner.toDTO(joinerPrincipal.name), joinedLobby.players[0])
+ assertEquals(joiner.toDTO(joinerPrincipal.name), joinedLobby.players[1])
}
@Test(expected = UserAlreadyInGameException::class)
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt
index b11ef878..65989db6 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/HomeControllerTest.kt
@@ -1,6 +1,6 @@
package org.luxons.sevenwonders.controllers
-import org.junit.Assert.*
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.luxons.sevenwonders.actions.ChooseNameAction
import org.luxons.sevenwonders.repositories.PlayerRepository
@@ -17,10 +17,9 @@ class HomeControllerTest {
val player = homeController.chooseName(action, principal)
- assertSame(player, playerRepository.find("testuser"))
assertEquals("testuser", player.username)
assertEquals("Test User", player.displayName)
- assertFalse(player.isInLobby)
- assertFalse(player.isInGame)
+ assertEquals(false, player.isGameOwner)
+ assertEquals(true, player.isUser)
}
}
diff --git a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
index 6269ae40..e366048f 100644
--- a/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
+++ b/backend/src/test/kotlin/org/luxons/sevenwonders/controllers/LobbyControllerTest.kt
@@ -42,7 +42,7 @@ class LobbyControllerTest {
assertTrue(lobby.getPlayers().contains(owner))
assertSame(lobby, owner.lobby)
- assertEquals(owner.username, lobby.owner)
+ assertEquals(owner, lobby.owner)
assertTrue(owner.isInLobby)
assertFalse(owner.isInGame)
}
bgstack15