added id, groupid
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / dataschema / ReservationTest.java
index a860f60..a48b593 100644 (file)
@@ -8,6 +8,9 @@
 package ch.bfh.ti.srs.dataschema;\r
 \r
 import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertNotEquals;\r
+\r
+import java.util.UUID;\r
 \r
 import org.junit.Before;\r
 import org.junit.Test;\r
@@ -22,7 +25,7 @@ import ch.bfh.ti.srs.dataschema.User;
 public class ReservationTest {\r
 \r
        private DateRangeFactory factory;\r
-       \r
+\r
        @Before\r
        public void setUp() throws Exception {\r
                String className = System.getProperty("daterangefactory.name",\r
@@ -30,63 +33,71 @@ public class ReservationTest {
                Class<?> clazz = Class.forName(className);\r
                factory = (DateRangeFactory) clazz.newInstance();\r
        }\r
-       \r
+\r
        @Test\r
        public void createReservationTest() throws Exception {\r
                User testUser = new User("TestUser", "pass");\r
                Resource testResource = new Resource("N321", "class room");\r
-               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9), DateFactory.createDate(2015, 11, 13));\r
-               Reservation testReservation = new Reservation("TestReservation", testUser, testResource, testDr);\r
+               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
+                               DateFactory.createDate(2015, 11, 13));\r
+               Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr, "TestReservation");\r
                \r
-               assertEquals("TestReservation", testReservation.getName());\r
+               assertNotEquals(null, testReservation.getId());\r
+               assertNotEquals(null, testReservation.getGroupId());\r
                assertEquals(testUser, testReservation.getUser());\r
                assertEquals(testResource, testReservation.getResource());\r
                assertEquals(testDr, testReservation.getDateRange());\r
-       }       \r
+               assertEquals("TestReservation", testReservation.getRemark());\r
+       }\r
        \r
        @Test\r
        public void setAndGetNameTest() throws Exception {\r
                User testUser = new User("TestUser", "pass");\r
                Resource testResource = new Resource("N321", "class room");\r
-               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9), DateFactory.createDate(2015, 11, 13));\r
-               Reservation testReservation = new Reservation("TestReservation", testUser, testResource, testDr);\r
-               \r
-               testReservation.setName("otherTestReservation");\r
-               assertEquals("otherTestReservation", testReservation.getName());\r
+               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
+                               DateFactory.createDate(2015, 11, 13));\r
+               Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr, "TestReservation");\r
+\r
+               testReservation.setRemark("otherTestReservation");\r
+               assertEquals("otherTestReservation", testReservation.getRemark());\r
        }\r
-       \r
+\r
        @Test\r
        public void setAndGetUserTest() throws Exception {\r
                User testUser = new User("TestUser", "pass");\r
                Resource testResource = new Resource("N321", "class room");\r
-               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9), DateFactory.createDate(2015, 11, 13));\r
-               Reservation testReservation = new Reservation("TestReservation", testUser, testResource, testDr);\r
-               \r
+               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
+                               DateFactory.createDate(2015, 11, 13));\r
+               Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr, "TestReservation");\r
+\r
                User otherTestUser = new User("otherTestUser", "pass");\r
                testReservation.setUser(otherTestUser);\r
                assertEquals(otherTestUser, testReservation.getUser());\r
        }\r
-       \r
+\r
        @Test\r
        public void setAndGetResourceTest() throws Exception {\r
                User testUser = new User("TestUser", "pass");\r
                Resource testResource = new Resource("N321", "class room");\r
-               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9), DateFactory.createDate(2015, 11, 13));\r
-               Reservation testReservation = new Reservation("TestReservation", testUser, testResource, testDr);\r
-               \r
+               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
+                               DateFactory.createDate(2015, 11, 13));\r
+               Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr, "TestReservation");\r
+\r
                Resource OtherTestResource = new Resource("N421", "lecture hall");\r
                testReservation.setResource(OtherTestResource);\r
                assertEquals(OtherTestResource, testReservation.getResource());\r
        }\r
-       \r
+\r
        @Test\r
        public void setAndGetDateRangeTest() throws Exception {\r
                User testUser = new User("TestUser", "pass");\r
                Resource testResource = new Resource("N321", "class room");\r
-               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9), DateFactory.createDate(2015, 11, 13));\r
-               Reservation testReservation = new Reservation("TestReservation", testUser, testResource, testDr);\r
-               \r
-               DateRange otherTestDr = factory.createDateRange(DateFactory.createDate(2015, 12, 9), DateFactory.createDate(2015, 12, 13));\r
+               DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
+                               DateFactory.createDate(2015, 11, 13));\r
+               Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr, "TestReservation");\r
+\r
+               DateRange otherTestDr = factory.createDateRange(DateFactory.createDate(2015, 12, 9),\r
+                               DateFactory.createDate(2015, 12, 13));\r
                testReservation.setDateRange(otherTestDr);\r
                assertEquals(otherTestDr, testReservation.getDateRange());\r
        }\r