Merge branch 'development' of git@git.bfh.ch:/staff/due1/sed-hs15-srs-purple.git...
authorMatthias <matthias.balmer@gmx.ch>
Wed, 18 Nov 2015 09:15:26 +0000 (10:15 +0100)
committerMatthias <matthias.balmer@gmx.ch>
Wed, 18 Nov 2015 09:15:26 +0000 (10:15 +0100)
src/main/java/ch/bfh/ti/srs/dataschema/Reservation.java
src/main/java/ch/bfh/ti/srs/dataschema/Resource.java
src/test/java/ch/bfh/ti/srs/dataschema/ReservationTest.java
src/test/java/ch/bfh/ti/srs/dataschema/ResourceTest.java

index 8ad99e9..fe84e7f 100644 (file)
@@ -20,20 +20,33 @@ public class Reservation {
        private DateRange dateRange;\r
        private String remark;\r
 \r
-       public Reservation(User user, Resource resource, DateRange DateRange, String remark) {\r
-//             if (user == null)\r
+       public Reservation(UUID groupId, User user, Resource resource, DateRange DateRange, String remark) {\r
+//             // if (groupId == null)\r
+//             // throw new IllegalArgumentException("GroupID must not be null");\r
+//             if (user.getUserName() == null)\r
 //                     throw new IllegalArgumentException("User must not be null");\r
-//             if (resource == null)\r
+//             if (resource.getId() == null)\r
 //                     throw new IllegalArgumentException("Resource must not be null");\r
-//             if (dateRange == null)\r
+//             if (dateRange.isEmpty())\r
 //                     throw new IllegalArgumentException("DateRange must not be null");\r
 \r
+               this.groupId = groupId;\r
                this.user = user;\r
                this.resource = resource;\r
                this.dateRange = DateRange;\r
                this.remark = remark;\r
+               \r
+               this.id = UUID.randomUUID();\r
        }\r
 \r
+       public UUID getId() {\r
+               return id;\r
+       }\r
+       \r
+       public UUID getGroupId() {\r
+               return groupId;\r
+       }\r
+       \r
        public User getUser() {\r
                return user;\r
        }\r
@@ -49,7 +62,7 @@ public class Reservation {
        public String getRemark() {\r
                return remark;\r
        }\r
-\r
+       \r
        public void setUser(User user) {\r
                this.user = user;\r
        }\r
@@ -65,8 +78,4 @@ public class Reservation {
        public void setRemark(String remark) {\r
                this.remark = remark;\r
        }\r
-       \r
-       private UUID createUUID() {\r
-               return null;\r
-       }\r
 }\r
index e9913eb..f97941e 100644 (file)
@@ -7,8 +7,11 @@
  */\r
 package ch.bfh.ti.srs.dataschema;\r
 \r
+import java.util.UUID;\r
+\r
 public class Resource {\r
 \r
+       private UUID id;\r
        private String name;\r
        private String type;\r
 \r
@@ -20,12 +23,18 @@ public class Resource {
         * @throws Exception\r
         */\r
 \r
-       public Resource(String name, String type) throws Exception{\r
+       public Resource(String name, String type) throws Exception {\r
                if (name == null)\r
                        throw new IllegalArgumentException("Name must not be null");\r
 \r
                this.name = name;\r
                this.type = type;\r
+\r
+               this.id = UUID.randomUUID();\r
+       }\r
+\r
+       public UUID getId() {\r
+               return id;\r
        }\r
 \r
        public String getName() {\r
index 12225b6..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(testUser, testResource, testDr, "TestReservation");\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
+               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
                assertEquals("TestReservation", testReservation.getRemark());\r
-       }       \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(testUser, testResource, testDr, "TestReservation");\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
                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(testUser, testResource, testDr, "TestReservation");\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(testUser, testResource, testDr, "TestReservation");\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(testUser, testResource, testDr, "TestReservation");\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
index b0e44f5..73af912 100644 (file)
@@ -8,6 +8,7 @@
 package ch.bfh.ti.srs.dataschema;\r
 \r
 import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertNotEquals;\r
 \r
 import org.junit.Test;\r
 \r
@@ -18,6 +19,7 @@ public class ResourceTest {
        @Test\r
        public void createResurceTest() throws Exception {\r
                Resource testResource = new Resource("N321", "class room");\r
+               assertNotEquals(null, testResource.getId());\r
                assertEquals("N321", testResource.getName());\r
                assertEquals("class room", testResource.getType());\r
        }\r