Update Reservation and ReservationTest classes.
authorMoritz Trittibach <tritm3@bfh.ch>
Wed, 11 Nov 2015 10:48:48 +0000 (11:48 +0100)
committerMoritz Trittibach <tritm3@bfh.ch>
Wed, 11 Nov 2015 10:48:48 +0000 (11:48 +0100)
src/main/java/ch/bfh/ti/srs/dataschema/Reservation.java
src/test/java/ch/bfh/ti/srs/dataschema/ReservationTest.java

index 2aa7c0d..b2bef3d 100644 (file)
@@ -7,24 +7,31 @@
  */\r
 package ch.bfh.ti.srs.dataschema;\r
 \r
+import java.util.UUID;\r
+\r
 import ch.bfh.ti.daterange.DateRange;\r
 \r
 public class Reservation {\r
 \r
-       private String name;\r
+       private UUID id;\r
+       private UUID groupId;\r
        private User user;\r
        private Resource resource;\r
        private DateRange dateRange;\r
+       private String remark;\r
+\r
+       public Reservation(User user, Resource resource, DateRange DateRange, String remark) {\r
+               if (user == null)\r
+                       throw new IllegalArgumentException("User must not be null");\r
+               if (resource == null)\r
+                       throw new IllegalArgumentException("Resource must not be null");\r
+               if (dateRange == null)\r
+                       throw new IllegalArgumentException("DateRange must not be null");\r
 \r
-       public Reservation(String name, User user, Resource resource, DateRange DateRange) {\r
-               this.name = name;\r
                this.user = user;\r
                this.resource = resource;\r
                this.dateRange = DateRange;\r
-       }\r
-\r
-       public String getName() {\r
-               return name;\r
+               this.remark = remark;\r
        }\r
 \r
        public User getUser() {\r
@@ -39,14 +46,14 @@ public class Reservation {
                return dateRange;\r
        }\r
 \r
-       public void setName(String name) {\r
-               this.name = name;\r
+       public String getRemark() {\r
+               return remark;\r
        }\r
 \r
        public void setUser(User user) {\r
                this.user = user;\r
        }\r
-\r
\r
        public void setResource(Resource resource) {\r
                this.resource = resource;\r
        }\r
@@ -54,4 +61,12 @@ public class Reservation {
        public void setDateRange(DateRange dateRange) {\r
                this.dateRange = dateRange;\r
        }\r
+\r
+       public void setRemark(String remark) {\r
+               this.remark = remark;\r
+       }\r
+       \r
+       private UUID createUUID() {\r
+               return null;\r
+       }\r
 }\r
index a860f60..12225b6 100644 (file)
@@ -36,12 +36,12 @@ public class ReservationTest {
                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
+               Reservation testReservation = new Reservation(testUser, testResource, testDr, "TestReservation");\r
                \r
-               assertEquals("TestReservation", testReservation.getName());\r
                assertEquals(testUser, testReservation.getUser());\r
                assertEquals(testResource, testReservation.getResource());\r
                assertEquals(testDr, testReservation.getDateRange());\r
+               assertEquals("TestReservation", testReservation.getRemark());\r
        }       \r
        \r
        @Test\r
@@ -49,10 +49,10 @@ public class ReservationTest {
                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
+               Reservation testReservation = new Reservation(testUser, testResource, testDr, "TestReservation");\r
                \r
-               testReservation.setName("otherTestReservation");\r
-               assertEquals("otherTestReservation", testReservation.getName());\r
+               testReservation.setRemark("otherTestReservation");\r
+               assertEquals("otherTestReservation", testReservation.getRemark());\r
        }\r
        \r
        @Test\r
@@ -60,7 +60,7 @@ public class ReservationTest {
                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
+               Reservation testReservation = new Reservation(testUser, testResource, testDr, "TestReservation");\r
                \r
                User otherTestUser = new User("otherTestUser", "pass");\r
                testReservation.setUser(otherTestUser);\r
@@ -72,7 +72,7 @@ public class ReservationTest {
                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
+               Reservation testReservation = new Reservation(testUser, testResource, testDr, "TestReservation");\r
                \r
                Resource OtherTestResource = new Resource("N421", "lecture hall");\r
                testReservation.setResource(OtherTestResource);\r
@@ -84,7 +84,7 @@ public class ReservationTest {
                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
+               Reservation testReservation = new Reservation(testUser, testResource, testDr, "TestReservation");\r
                \r
                DateRange otherTestDr = factory.createDateRange(DateFactory.createDate(2015, 12, 9), DateFactory.createDate(2015, 12, 13));\r
                testReservation.setDateRange(otherTestDr);\r