Controller Struktur angepasst
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / controller / UserControllerTest.java
index 5b06f2a..d818d2b 100644 (file)
@@ -13,19 +13,14 @@ import static org.junit.Assert.assertTrue;
 \r
 import java.util.ArrayList;\r
 import java.util.Date;\r
-import java.util.HashSet;\r
-import java.util.Iterator;\r
 import java.util.List;\r
 import java.util.Map;\r
-import java.util.Set;\r
 import java.util.UUID;\r
 \r
-import org.junit.Ignore;\r
 import org.junit.Test;\r
 \r
 import ch.bfh.ti.daterange.DateRange;\r
 import ch.bfh.ti.daterange.impl.pojo.DateRangeImpl;\r
-import ch.bfh.ti.srs.controller.UserController;\r
 import ch.bfh.ti.srs.datahandler.DataHandler;\r
 import ch.bfh.ti.srs.datahandler.DataHandlerForTests;\r
 import ch.bfh.ti.srs.dataschema.Reservation;\r
@@ -40,9 +35,9 @@ public class UserControllerTest {
        @Test\r
        public void addUserTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
@@ -52,7 +47,8 @@ public class UserControllerTest {
        @Test(expected = Exception.class)\r
        public void addUserExceptionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
 \r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
        }\r
@@ -60,9 +56,9 @@ public class UserControllerTest {
        @Test\r
        public void logInTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
@@ -74,16 +70,17 @@ public class UserControllerTest {
        @Test(expected = Exception.class)\r
        public void logInException1Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
                uc.logIn("TestUser3", "pass3");\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void logInException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
 \r
@@ -94,9 +91,9 @@ public class UserControllerTest {
        @Test\r
        public void logInInvalidCredetialsTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
 \r
@@ -105,12 +102,13 @@ public class UserControllerTest {
                assertTrue(uc.logIn("TestUser1", "pass1"));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedUserNameTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
@@ -120,18 +118,22 @@ public class UserControllerTest {
                assertEquals("TestUser1", uc.getLoggedUserName());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedUserNameExceptionTest() throws Exception {\r
-               UserController uc = new UserController();\r
-               String currentUserName = uc.getLoggedUserName();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
+               uc.getLoggedUserName();\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedUserMailTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "hanfli@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
@@ -141,18 +143,22 @@ public class UserControllerTest {
                assertEquals("hanfli@bfh.ch", uc.getLoggedMail());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedMailExceptionTest() throws Exception {\r
-               UserController uc = new UserController();\r
-               String currentMail = uc.getLoggedMail();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
+               uc.getLoggedMail();\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedNameTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Hanfli", null);\r
@@ -162,18 +168,22 @@ public class UserControllerTest {
                assertEquals("Hanfli", uc.getLoggedName());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedNameExceptionTest() throws Exception {\r
-               UserController uc = new UserController();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
                uc.getLoggedName();\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedLastnameTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
@@ -183,18 +193,21 @@ public class UserControllerTest {
                assertEquals("User", uc.getLoggedLastname());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedLastnameExceptionTest() throws Exception {\r
-               UserController uc = new UserController();\r
-               String currentLastName = uc.getLoggedLastname();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
+               uc.getLoggedLastname();\r
        }\r
 \r
        @Test\r
        public void getLoggedUserTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                assertEquals(null, uc.getLoggedUser());\r
                uc.logIn("TestUser1", "pass1");\r
@@ -204,7 +217,7 @@ public class UserControllerTest {
        // @Test(expected=Exception.class)\r
        // public void getLoggedUserExceptionTest() throws Exception{\r
        // DataHandler dh = new DataHandlerForTests();\r
-       // UserController uc = new UserController();\r
+       // UserController uc = new UserController(dh);\r
        //\r
        // uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
        // uc.logIn("TestUser1", "pass1");\r
@@ -214,9 +227,9 @@ public class UserControllerTest {
        @Test\r
        public void getUserTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
                assertEquals("grosm9@bfh.ch", uc.getUser("TestUser1").getMail());\r
@@ -225,19 +238,21 @@ public class UserControllerTest {
        @Test(expected = Exception.class)\r
        public void getUserExceptionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
 \r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
                assertEquals("grosm9@bfh.ch", uc.getUser("TestUser1").getMail());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void logOutTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
@@ -251,7 +266,8 @@ public class UserControllerTest {
        @Test(expected = Exception.class)\r
        public void logOutException1Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
 \r
                uc.logOut();\r
        }\r
@@ -259,23 +275,26 @@ public class UserControllerTest {
        @Test(expected = Exception.class)\r
        public void logOutException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(dh);\r
 \r
-               uc.setDataHandler(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.logOut();\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getUserExpectionTest() throws Exception {\r
-               UserController uc = new UserController();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
                uc.getUser(null);\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getReservationTests() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -292,7 +311,6 @@ public class UserControllerTest {
                dh.addResource(resource2);\r
                dh.addResource(resource3);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
                User testUser2 = uc.getUser("TestUser2");\r
 \r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
@@ -330,65 +348,71 @@ public class UserControllerTest {
 \r
        @Test(expected = Exception.class)\r
        public void getReservationGroupException1Test() throws Exception {\r
-               UserController uc = new UserController();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
                uc.getReservationGroup(null);\r
        }\r
 \r
        @Test(expected = IllegalArgumentException.class)\r
        public void getReservationGroupException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.getReservationGroup(null);\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getUserReservationException1Test() throws Exception {\r
-               UserController uc = new UserController();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
+               uc.setDataHandler(null);\r
                uc.getUserReservations(null);\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getUserReservationException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.getUserReservations(null);\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getReservationException1Test() throws Exception {\r
-               UserController uc = new UserController();\r
+               DataHandler dh = new DataHandlerForTests();\r
+               UserController uc = new UserController(dh);\r
                uc.getReservation(null);\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getReservationException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.getReservation(null);\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getReservationsInDateRangeException1Test() throws Exception {\r
-               UserController uc = new UserController();\r
+               UserController uc = new UserController(null);\r
                uc.getReservationsInDateRange(null);\r
        }\r
 \r
        @Test(expected = Exception.class)\r
        public void getReservationsInDateRangeException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.getReservationsInDateRange(null);\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void makeReservationTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -409,11 +433,12 @@ public class UserControllerTest {
                assertEquals(null, uc.makeReservation(null, resource2, dtList, "remark"));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void makeInvalidReservationTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -445,11 +470,12 @@ public class UserControllerTest {
                assertEquals(4, uc.makeReservation(uc.getLoggedUser(), resource1, conflictingList, null).size());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = IllegalArgumentException.class)\r
        public void makeReservationException1Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -470,11 +496,12 @@ public class UserControllerTest {
                assertEquals(null, uc.makeReservation(null, resource1, dtList, "remark"));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = IllegalArgumentException.class)\r
        public void makeReservationException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -494,11 +521,12 @@ public class UserControllerTest {
                assertEquals(null, uc.makeReservation(null, null, dtList, "remark"));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = IllegalArgumentException.class)\r
        public void makeReservationException3Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -521,8 +549,8 @@ public class UserControllerTest {
        @Test(expected = IllegalArgumentException.class)\r
        public void makeReservationException4Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -539,11 +567,12 @@ public class UserControllerTest {
                assertEquals(null, uc.makeReservation(null, resource1, dtList, "remark"));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void changeReservationTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -554,9 +583,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -570,11 +596,12 @@ public class UserControllerTest {
                assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void changeReservationException1Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -589,9 +616,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -608,11 +632,12 @@ public class UserControllerTest {
                assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void changeReservationException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -627,9 +652,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -646,11 +668,12 @@ public class UserControllerTest {
                assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = IllegalArgumentException.class)\r
        public void changeReservationException3Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -665,9 +688,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -683,11 +703,12 @@ public class UserControllerTest {
                assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void changeReservationException4Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -702,9 +723,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -722,11 +740,12 @@ public class UserControllerTest {
                assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void deleteReservationTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -741,9 +760,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -753,11 +769,12 @@ public class UserControllerTest {
                assertEquals(null, uc.getReservation(reservation1.getId()));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void deleteReservationException1Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -772,9 +789,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -785,11 +799,12 @@ public class UserControllerTest {
                assertEquals(null, uc.getReservation(reservation1.getId()));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void deleteReservationException2Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -804,9 +819,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -817,11 +829,12 @@ public class UserControllerTest {
                assertEquals(null, uc.getReservation(reservation1.getId()));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = IllegalArgumentException.class)\r
        public void deleteReservationException3Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -836,9 +849,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -848,11 +858,12 @@ public class UserControllerTest {
                assertEquals(null, uc.getReservation(reservation1.getId()));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void deleteReservationException4Test() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -867,9 +878,6 @@ public class UserControllerTest {
                Resource resource1 = new Resource("Room101", "Class room");\r
                dh.addResource(resource1);\r
 \r
-               User loggedUser = uc.getLoggedUser();\r
-               User testUser2 = uc.getUser("TestUser2");\r
-\r
                Reservation reservation1 = new Reservation(groupId, uc.getLoggedUser(), resource1, dateRange,\r
                                "Test reservation1");\r
                dh.addReservation(reservation1);\r
@@ -881,11 +889,12 @@ public class UserControllerTest {
                assertEquals(null, uc.getReservation(reservation1.getId()));\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getResourcesTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r
@@ -907,11 +916,12 @@ public class UserControllerTest {
                assertEquals(3, resList.size());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getResourcesExceptionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController();\r
-               uc.setDataHandler(dh);\r
+               UserController uc = new UserController(dh);\r
+               //uc.setDataHandler(dh);\r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
                uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
                uc.logIn("TestUser1", "pass1");\r