removed all checkstyle errors, updated sprint backlog
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / dataschema / ReservationTest.java
CommitLineData
9a78ca13
MT
1/*\r
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.\r
3 *\r
4 * Project Smart Reservation System.\r
5 *\r
6 * Distributable under GPL license. See terms of license at gnu.org.\r
7 */\r
496127a5 8package ch.bfh.ti.srs.dataschema;\r
9a78ca13
MT
9\r
10import static org.junit.Assert.assertEquals;\r
a49c468f
MT
11import static org.junit.Assert.assertNotEquals;\r
12\r
13import java.util.UUID;\r
9a78ca13
MT
14\r
15import org.junit.Before;\r
16import org.junit.Test;\r
17\r
18import ch.bfh.ti.daterange.DateFactory;\r
19import ch.bfh.ti.daterange.DateRange;\r
20import ch.bfh.ti.daterange.DateRangeFactory;\r
21import ch.bfh.ti.srs.dataschema.Reservation;\r
22import ch.bfh.ti.srs.dataschema.Resource;\r
23import ch.bfh.ti.srs.dataschema.User;\r
24\r
25public class ReservationTest {\r
26\r
27 private DateRangeFactory factory;\r
a49c468f 28\r
9a78ca13
MT
29 @Before\r
30 public void setUp() throws Exception {\r
31 String className = System.getProperty("daterangefactory.name",\r
32 "ch.bfh.ti.daterange.impl.pojo.DateRangeFactory");\r
33 Class<?> clazz = Class.forName(className);\r
34 factory = (DateRangeFactory) clazz.newInstance();\r
35 }\r
a49c468f 36\r
9a78ca13
MT
37 @Test\r
38 public void createReservationTest() throws Exception {\r
39 User testUser = new User("TestUser", "pass");\r
40 Resource testResource = new Resource("N321", "class room");\r
a49c468f
MT
41 DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
42 DateFactory.createDate(2015, 11, 13));\r
66cc653d
D
43 Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr,\r
44 "TestReservation");\r
45\r
a49c468f
MT
46 assertNotEquals(null, testReservation.getId());\r
47 assertNotEquals(null, testReservation.getGroupId());\r
9a78ca13
MT
48 assertEquals(testUser, testReservation.getUser());\r
49 assertEquals(testResource, testReservation.getResource());\r
50 assertEquals(testDr, testReservation.getDateRange());\r
81c3aac6 51 assertEquals("TestReservation", testReservation.getRemark());\r
a49c468f 52 }\r
66cc653d 53\r
9a78ca13
MT
54 @Test\r
55 public void setAndGetNameTest() throws Exception {\r
56 User testUser = new User("TestUser", "pass");\r
57 Resource testResource = new Resource("N321", "class room");\r
a49c468f
MT
58 DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
59 DateFactory.createDate(2015, 11, 13));\r
66cc653d
D
60 Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr,\r
61 "TestReservation");\r
a49c468f 62\r
81c3aac6
MT
63 testReservation.setRemark("otherTestReservation");\r
64 assertEquals("otherTestReservation", testReservation.getRemark());\r
9a78ca13 65 }\r
a49c468f 66\r
9a78ca13
MT
67 @Test\r
68 public void setAndGetUserTest() throws Exception {\r
69 User testUser = new User("TestUser", "pass");\r
70 Resource testResource = new Resource("N321", "class room");\r
a49c468f
MT
71 DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
72 DateFactory.createDate(2015, 11, 13));\r
66cc653d
D
73 Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr,\r
74 "TestReservation");\r
a49c468f 75\r
9a78ca13
MT
76 User otherTestUser = new User("otherTestUser", "pass");\r
77 testReservation.setUser(otherTestUser);\r
78 assertEquals(otherTestUser, testReservation.getUser());\r
79 }\r
a49c468f 80\r
9a78ca13
MT
81 @Test\r
82 public void setAndGetResourceTest() throws Exception {\r
83 User testUser = new User("TestUser", "pass");\r
84 Resource testResource = new Resource("N321", "class room");\r
a49c468f
MT
85 DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
86 DateFactory.createDate(2015, 11, 13));\r
66cc653d
D
87 Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr,\r
88 "TestReservation");\r
a49c468f 89\r
9a78ca13
MT
90 Resource OtherTestResource = new Resource("N421", "lecture hall");\r
91 testReservation.setResource(OtherTestResource);\r
92 assertEquals(OtherTestResource, testReservation.getResource());\r
93 }\r
a49c468f 94\r
9a78ca13
MT
95 @Test\r
96 public void setAndGetDateRangeTest() throws Exception {\r
97 User testUser = new User("TestUser", "pass");\r
98 Resource testResource = new Resource("N321", "class room");\r
a49c468f
MT
99 DateRange testDr = factory.createDateRange(DateFactory.createDate(2015, 11, 9),\r
100 DateFactory.createDate(2015, 11, 13));\r
66cc653d
D
101 Reservation testReservation = new Reservation(UUID.randomUUID(), testUser, testResource, testDr,\r
102 "TestReservation");\r
a49c468f
MT
103\r
104 DateRange otherTestDr = factory.createDateRange(DateFactory.createDate(2015, 12, 9),\r
105 DateFactory.createDate(2015, 12, 13));\r
9a78ca13
MT
106 testReservation.setDateRange(otherTestDr);\r
107 assertEquals(otherTestDr, testReservation.getDateRange());\r
108 }\r
109}\r