summaryrefslogtreecommitdiff
path: root/backend/src/test/java/org
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2017-05-16 00:39:12 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2017-05-16 00:39:12 +0200
commit8534e40dba09c06968b5a0e92657457c2e36a8c7 (patch)
treeec20301a15239df80713acb694e6bef74df8af59 /backend/src/test/java/org
parentAdd tests for special abilities in Board (diff)
downloadseven-wonders-8534e40dba09c06968b5a0e92657457c2e36a8c7.tar.gz
seven-wonders-8534e40dba09c06968b5a0e92657457c2e36a8c7.tar.bz2
seven-wonders-8534e40dba09c06968b5a0e92657457c2e36a8c7.zip
Add HomeController test
Diffstat (limited to 'backend/src/test/java/org')
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/controllers/HomeControllerTest.java28
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/controllers/test/TestUtils.java15
2 files changed, 43 insertions, 0 deletions
diff --git a/backend/src/test/java/org/luxons/sevenwonders/controllers/HomeControllerTest.java b/backend/src/test/java/org/luxons/sevenwonders/controllers/HomeControllerTest.java
new file mode 100644
index 00000000..4f2b1a44
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/controllers/HomeControllerTest.java
@@ -0,0 +1,28 @@
+package org.luxons.sevenwonders.controllers;
+
+import java.security.Principal;
+
+import org.junit.Test;
+import org.luxons.sevenwonders.actions.ChooseNameAction;
+import org.luxons.sevenwonders.controllers.test.TestUtils;
+import org.luxons.sevenwonders.repositories.PlayerRepository;
+
+import static org.junit.Assert.assertTrue;
+
+public class HomeControllerTest {
+
+ @Test
+ public void chooseName() {
+ PlayerRepository playerRepository = new PlayerRepository();
+ HomeController homeController = new HomeController(playerRepository);
+
+ ChooseNameAction action = new ChooseNameAction();
+ action.setPlayerName("Test User");
+
+ Principal principal = TestUtils.createPrincipal("testuser");
+
+ homeController.chooseName(action, principal);
+
+ assertTrue(playerRepository.contains("testuser"));
+ }
+}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/controllers/test/TestUtils.java b/backend/src/test/java/org/luxons/sevenwonders/controllers/test/TestUtils.java
new file mode 100644
index 00000000..e5186fcc
--- /dev/null
+++ b/backend/src/test/java/org/luxons/sevenwonders/controllers/test/TestUtils.java
@@ -0,0 +1,15 @@
+package org.luxons.sevenwonders.controllers.test;
+
+import java.security.Principal;
+
+public class TestUtils {
+
+ public static Principal createPrincipal(String username) {
+ return new Principal() {
+ @Override
+ public String getName() {
+ return username;
+ }
+ };
+ }
+}
bgstack15