Controller Struktur angepasst
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / controller / UserControllerTest.java
index 0a29a09..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
@@ -107,6 +102,7 @@ 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
@@ -122,14 +118,16 @@ public class UserControllerTest {
                assertEquals("TestUser1", uc.getLoggedUserName());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedUserNameExceptionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
                UserController uc = new UserController(dh);\r
                uc.setDataHandler(null);\r
-               String currentUserName = uc.getLoggedUserName();\r
+               uc.getLoggedUserName();\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedUserMailTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -145,14 +143,16 @@ 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
                DataHandler dh = new DataHandlerForTests();\r
                UserController uc = new UserController(dh);\r
                uc.setDataHandler(null);\r
-               String currentMail = uc.getLoggedMail();\r
+               uc.getLoggedMail();\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedNameTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -168,6 +168,7 @@ public class UserControllerTest {
                assertEquals("Hanfli", uc.getLoggedName());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedNameExceptionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -176,6 +177,7 @@ public class UserControllerTest {
                uc.getLoggedName();\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getLoggedLastnameTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -191,12 +193,13 @@ public class UserControllerTest {
                assertEquals("User", uc.getLoggedLastname());\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test(expected = Exception.class)\r
        public void getLoggedLastnameExceptionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
                UserController uc = new UserController(dh);\r
                uc.setDataHandler(null);\r
-               String currentLastName = uc.getLoggedLastname();\r
+               uc.getLoggedLastname();\r
        }\r
 \r
        @Test\r
@@ -243,6 +246,7 @@ public class UserControllerTest {
                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
@@ -285,6 +289,7 @@ public class UserControllerTest {
                uc.getUser(null);\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void getReservationTests() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -306,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
@@ -403,6 +407,7 @@ public class UserControllerTest {
                uc.getReservationsInDateRange(null);\r
        }\r
 \r
+       @SuppressWarnings("deprecation")\r
        @Test\r
        public void makeReservationTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -428,6 +433,7 @@ 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
@@ -464,6 +470,7 @@ 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
@@ -489,6 +496,7 @@ 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
@@ -513,6 +521,7 @@ 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
@@ -558,6 +567,7 @@ 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
@@ -573,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
@@ -589,6 +596,7 @@ 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
@@ -608,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
@@ -627,6 +632,7 @@ 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
@@ -646,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
@@ -665,6 +668,7 @@ 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
@@ -684,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
@@ -702,6 +703,7 @@ 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
@@ -721,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
@@ -741,6 +740,7 @@ 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
@@ -760,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
@@ -772,6 +769,7 @@ 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
@@ -791,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
@@ -804,6 +799,7 @@ 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
@@ -823,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
@@ -836,6 +829,7 @@ 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
@@ -855,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
@@ -867,6 +858,7 @@ 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
@@ -886,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
@@ -900,6 +889,7 @@ 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
@@ -926,6 +916,7 @@ 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