Merge remote-tracking branch 'origin/development'
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / controller / UserControllerTest.java
CommitLineData
1ec0e01f
M
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
e3535133 8package ch.bfh.ti.srs.controller;\r
1ec0e01f 9\r
9e071834
M
10import static org.junit.Assert.assertEquals;\r
11import static org.junit.Assert.assertFalse;\r
12import static org.junit.Assert.assertTrue;\r
1ec0e01f 13\r
5a196189
M
14import java.util.ArrayList;\r
15import java.util.Date;\r
5a196189
M
16import java.util.List;\r
17import java.util.Map;\r
c1191616 18import java.util.Set;\r
5a196189
M
19import java.util.UUID;\r
20\r
1ec0e01f
M
21import org.junit.Test;\r
22\r
5a196189
M
23import ch.bfh.ti.daterange.DateRange;\r
24import ch.bfh.ti.daterange.impl.pojo.DateRangeImpl;\r
e3535133
M
25import ch.bfh.ti.srs.datahandler.DataHandler;\r
26import ch.bfh.ti.srs.datahandler.DataHandlerForTests;\r
5a196189
M
27import ch.bfh.ti.srs.dataschema.Reservation;\r
28import ch.bfh.ti.srs.dataschema.Resource;\r
29import ch.bfh.ti.srs.dataschema.User;\r
e3535133 30\r
1ec0e01f
M
31/**\r
32 * @author Michael Grossen\r
33 */\r
34public class UserControllerTest {\r
1ec0e01f 35 @Test\r
66cc653d 36 public void addUserTest() throws Exception {\r
1f7b5004 37 DataHandler dh = new DataHandlerForTests();\r
c1191616 38 SessionController sc = new SessionController(dh);\r
66cc653d 39\r
c1191616
M
40 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
41 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
42 sc.registUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
43 sc.registUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
73469283 44\r
b07a6f5c
M
45 UserController uc = new UserController(dh, sc);\r
46 uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
1f7b5004 47 }\r
66cc653d
D
48\r
49 @Test(expected = Exception.class)\r
b07a6f5c 50 public void addUserExceptionTest1() throws Exception {\r
c1191616 51 SessionController sc = new SessionController(null);\r
66cc653d 52\r
c1191616 53 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
1f7b5004 54 }\r
b07a6f5c
M
55\r
56 @Test(expected = Exception.class)\r
57 public void addUserExceptionTest2() throws Exception {\r
58 UserController uc = new UserController(null, null);\r
73469283 59\r
b07a6f5c
M
60 uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
61 }\r
73469283 62\r
5a196189 63 @Test\r
66cc653d 64 public void getUserTest() throws Exception {\r
5a196189 65 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
66 SessionController sc = new SessionController(dh);\r
67 UserController uc = null;\r
68\r
69 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
70 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
71 for (Controller controller : controllers) {\r
73469283
D
72 if (controller.getClass().equals(UserController.class))\r
73 uc = (UserController) controller;\r
c1191616 74 }\r
5a196189
M
75 assertEquals("grosm9@bfh.ch", uc.getUser("TestUser1").getMail());\r
76 }\r
66cc653d
D
77\r
78 @Test(expected = Exception.class)\r
79 public void getUserExceptionTest() throws Exception {\r
5a196189 80 DataHandler dh = new DataHandlerForTests();\r
c1191616 81 SessionController sc = new SessionController(dh);\r
73469283 82 UserController uc = new UserController(null, sc);\r
66cc653d 83\r
5a196189
M
84 assertEquals("grosm9@bfh.ch", uc.getUser("TestUser1").getMail());\r
85 }\r
73469283 86\r
66cc653d
D
87 @Test(expected = Exception.class)\r
88 public void getUserExpectionTest() throws Exception {\r
da277fcf 89 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
90 SessionController sc = new SessionController(dh);\r
91 UserController uc = null;\r
73469283 92\r
c1191616
M
93 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
94 for (Controller controller : controllers) {\r
73469283
D
95 if (controller.getClass().equals(UserController.class))\r
96 uc = (UserController) controller;\r
c1191616 97 }\r
73469283 98\r
da277fcf 99 uc.setDataHandler(null);\r
5a196189
M
100 uc.getUser(null);\r
101 }\r
73469283 102\r
47d70ad5 103 @SuppressWarnings("deprecation")\r
5a196189 104 @Test\r
66cc653d 105 public void getReservationTests() throws Exception {\r
5a196189 106 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
107 SessionController sc = new SessionController(dh);\r
108 UserController uc = null;\r
73469283 109\r
c1191616
M
110 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
111 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
112 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
113 for (Controller controller : controllers) {\r
73469283
D
114 if (controller.getClass().equals(UserController.class))\r
115 uc = (UserController) controller;\r
c1191616 116 }\r
73469283 117\r
5a196189 118 UUID groupId = UUID.randomUUID();\r
66cc653d
D
119 Date start = new Date(2015, 11, 28, 11, 00, 00);\r
120 Date finish = new Date(2015, 11, 28, 11, 30, 00);\r
5a196189 121 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 122\r
5a196189
M
123 Resource resource1 = new Resource("Room101", "Class room");\r
124 Resource resource2 = new Resource("Room101", "Class room");\r
125 Resource resource3 = new Resource("Room101", "Class room");\r
126 dh.addResource(resource1);\r
127 dh.addResource(resource2);\r
128 dh.addResource(resource3);\r
66cc653d 129\r
5a196189 130 User testUser2 = uc.getUser("TestUser2");\r
66cc653d 131\r
c1191616 132 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 133 "Test reservation1");\r
c1191616 134 Reservation reservation2 = new Reservation(groupId, sc.getLoggedUser(), resource2, dateRange,\r
66cc653d 135 "Test reservation2");\r
5a196189 136 Reservation reservation3 = new Reservation(groupId, testUser2, resource3, dateRange, "Test reservation3");\r
73469283
D
137 Reservation reservation4 = new Reservation(UUID.randomUUID(), testUser2, resource3, dateRange,\r
138 "Test reservation3");\r
5a196189
M
139 dh.addReservation(reservation1);\r
140 dh.addReservation(reservation2);\r
141 dh.addReservation(reservation3);\r
e9cb7ca9 142 dh.addReservation(reservation4);\r
66cc653d 143\r
5a196189
M
144 Map<Reservation, Boolean> loggedUserReservation = uc.getUserReservations(null);\r
145 Map<Reservation, Boolean> reservationMap = uc.getUserReservations(testUser2);\r
146 Map<Reservation, Boolean> reservationDateRangeMap = uc.getReservationsInDateRange(dateRange);\r
147 Map<Reservation, Boolean> reservationGroupMap = uc.getReservationGroup(groupId);\r
66cc653d 148\r
5a196189 149 assertEquals(reservationDateRangeMap, reservationGroupMap);\r
73469283 150\r
5a196189
M
151 assertTrue(loggedUserReservation.containsKey(reservation1));\r
152 assertTrue(loggedUserReservation.containsKey(reservation2));\r
153 assertFalse(loggedUserReservation.containsKey(reservation3));\r
154 assertTrue(reservationMap.containsKey(reservation3));\r
66cc653d 155\r
5a196189 156 for (Map.Entry<Reservation, Boolean> entry : reservationDateRangeMap.entrySet()) {\r
66cc653d 157 if (entry.getKey().getUser().getUserName().equals("TestUser1")) {\r
5a196189
M
158 assertTrue(entry.getValue());\r
159 assertEquals(entry.getKey().getId(), uc.getReservation(entry.getKey().getId()).getId());\r
66cc653d 160 } else {\r
5a196189
M
161 assertFalse(entry.getValue());\r
162 assertEquals(entry.getKey().getId(), uc.getReservation(entry.getKey().getId()).getId());\r
163 }\r
164 }\r
165 assertEquals(null, uc.getReservation(UUID.randomUUID()));\r
166 }\r
66cc653d
D
167\r
168 @Test(expected = Exception.class)\r
169 public void getReservationGroupException1Test() throws Exception {\r
da277fcf 170 DataHandler dh = new DataHandlerForTests();\r
c1191616 171 SessionController sc = new SessionController(dh);\r
73469283
D
172 UserController uc = new UserController(dh, sc);\r
173\r
da277fcf 174 uc.setDataHandler(null);\r
5a196189
M
175 uc.getReservationGroup(null);\r
176 }\r
66cc653d
D
177\r
178 @Test(expected = IllegalArgumentException.class)\r
179 public void getReservationGroupException2Test() throws Exception {\r
5a196189 180 DataHandler dh = new DataHandlerForTests();\r
c1191616 181 SessionController sc = new SessionController(dh);\r
73469283
D
182 UserController uc = new UserController(dh, sc);\r
183\r
5a196189
M
184 uc.getReservationGroup(null);\r
185 }\r
66cc653d
D
186\r
187 @Test(expected = Exception.class)\r
188 public void getUserReservationException1Test() throws Exception {\r
da277fcf 189 DataHandler dh = new DataHandlerForTests();\r
c1191616 190 SessionController sc = new SessionController(dh);\r
73469283
D
191 UserController uc = new UserController(dh, sc);\r
192\r
da277fcf 193 uc.setDataHandler(null);\r
5a196189
M
194 uc.getUserReservations(null);\r
195 }\r
66cc653d
D
196\r
197 @Test(expected = Exception.class)\r
198 public void getUserReservationException2Test() throws Exception {\r
5a196189 199 DataHandler dh = new DataHandlerForTests();\r
c1191616 200 SessionController sc = new SessionController(dh);\r
73469283
D
201 UserController uc = new UserController(dh, sc);\r
202\r
5a196189
M
203 uc.getUserReservations(null);\r
204 }\r
66cc653d
D
205\r
206 @Test(expected = Exception.class)\r
207 public void getReservationException1Test() throws Exception {\r
da277fcf 208 DataHandler dh = new DataHandlerForTests();\r
c1191616 209 SessionController sc = new SessionController(dh);\r
73469283
D
210 UserController uc = new UserController(dh, sc);\r
211\r
5a196189
M
212 uc.getReservation(null);\r
213 }\r
66cc653d
D
214\r
215 @Test(expected = Exception.class)\r
216 public void getReservationException2Test() throws Exception {\r
5a196189 217 DataHandler dh = new DataHandlerForTests();\r
c1191616 218 SessionController sc = new SessionController(dh);\r
73469283
D
219 UserController uc = new UserController(dh, sc);\r
220\r
5a196189
M
221 uc.getReservation(null);\r
222 }\r
66cc653d
D
223\r
224 @Test(expected = Exception.class)\r
225 public void getReservationsInDateRangeException1Test() throws Exception {\r
c1191616
M
226 DataHandler dh = new DataHandlerForTests();\r
227 SessionController sc = new SessionController(dh);\r
73469283
D
228 UserController uc = new UserController(dh, sc);\r
229\r
5a196189
M
230 uc.getReservationsInDateRange(null);\r
231 }\r
66cc653d
D
232\r
233 @Test(expected = Exception.class)\r
234 public void getReservationsInDateRangeException2Test() throws Exception {\r
5a196189 235 DataHandler dh = new DataHandlerForTests();\r
c1191616 236 SessionController sc = new SessionController(dh);\r
73469283
D
237 UserController uc = new UserController(dh, sc);\r
238\r
5a196189
M
239 uc.getReservationsInDateRange(null);\r
240 }\r
66cc653d 241\r
47d70ad5 242 @SuppressWarnings("deprecation")\r
b18afc77 243 @Test\r
66cc653d 244 public void makeReservationTest() throws Exception {\r
5a196189 245 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
246 SessionController sc = new SessionController(dh);\r
247 UserController uc = null;\r
73469283 248\r
c1191616
M
249 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
250 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
251 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
252 for (Controller controller : controllers) {\r
73469283
D
253 if (controller.getClass().equals(UserController.class))\r
254 uc = (UserController) controller;\r
c1191616 255 }\r
66cc653d 256\r
5a196189
M
257 Resource resource1 = new Resource("Room101", "Class room");\r
258 Resource resource2 = new Resource("Room101", "Class room");\r
259 Resource resource3 = new Resource("Room101", "Class room");\r
260 dh.addResource(resource1);\r
261 dh.addResource(resource2);\r
262 dh.addResource(resource3);\r
66cc653d 263\r
5a196189 264 List<DateRange> dtList = new ArrayList<DateRange>();\r
66cc653d
D
265 for (int i = 1; i < 10; i++) {\r
266 dtList.add(new DateRangeImpl(new Date(2015, 12, 2 + i, 11, 00, 00), new Date(2015, 12, 2 + i, 11, 00, 00)));\r
5a196189 267 }\r
66cc653d 268\r
c1191616 269 assertEquals(null, uc.makeReservation(sc.getLoggedUser(), resource1, dtList, "remark"));\r
5a196189
M
270 assertEquals(null, uc.makeReservation(null, resource2, dtList, "remark"));\r
271 }\r
66cc653d 272\r
47d70ad5 273 @SuppressWarnings("deprecation")\r
b18afc77 274 @Test\r
66cc653d 275 public void makeInvalidReservationTest() throws Exception {\r
5a196189 276 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
277 SessionController sc = new SessionController(dh);\r
278 UserController uc = null;\r
73469283 279\r
c1191616
M
280 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
281 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
282 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
283 for (Controller controller : controllers) {\r
73469283
D
284 if (controller.getClass().equals(UserController.class))\r
285 uc = (UserController) controller;\r
c1191616 286 }\r
66cc653d 287\r
5a196189
M
288 Resource resource1 = new Resource("Room101", "Class room");\r
289 Resource resource2 = new Resource("Room101", "Class room");\r
290 Resource resource3 = new Resource("Room101", "Class room");\r
291 dh.addResource(resource1);\r
292 dh.addResource(resource2);\r
293 dh.addResource(resource3);\r
66cc653d 294\r
5a196189 295 List<DateRange> dtList = new ArrayList<DateRange>();\r
66cc653d
D
296 for (int i = 1; i < 10; i++) {\r
297 dtList.add(new DateRangeImpl(new Date(2015, 12, 2 + i, 11, 00, 00), new Date(2015, 12, 2 + i, 12, 00, 00)));\r
5a196189 298 }\r
66cc653d 299\r
b18afc77
M
300 List<DateRange> conflictingList = new ArrayList<DateRange>();\r
301 // Conflicts\r
66cc653d
D
302 conflictingList.add(new DateRangeImpl(new Date(2015, 12, 4, 11, 00, 00), new Date(2015, 12, 4, 12, 00, 00)));\r
303 conflictingList.add(new DateRangeImpl(new Date(2015, 12, 4, 11, 15, 00), new Date(2015, 12, 4, 11, 45, 00)));\r
304 conflictingList.add(new DateRangeImpl(new Date(2015, 12, 4, 10, 00, 00), new Date(2015, 12, 4, 17, 00, 00)));\r
305 conflictingList.add(new DateRangeImpl(new Date(2015, 12, 4, 11, 30, 00), new Date(2015, 12, 4, 12, 30, 00)));\r
306\r
b18afc77 307 // OK\r
66cc653d
D
308 conflictingList.add(new DateRangeImpl(new Date(2015, 12, 4, 10, 30, 00), new Date(2015, 12, 4, 10, 59, 59)));\r
309 conflictingList.add(new DateRangeImpl(new Date(2015, 12, 4, 12, 00, 01), new Date(2015, 12, 4, 12, 45, 00)));\r
b18afc77 310\r
c1191616
M
311 assertEquals(null, uc.makeReservation(sc.getLoggedUser(), resource1, dtList, "remark"));\r
312 assertEquals(4, uc.makeReservation(sc.getLoggedUser(), resource1, conflictingList, null).size());\r
5a196189
M
313 }\r
314\r
47d70ad5 315 @SuppressWarnings("deprecation")\r
66cc653d
D
316 @Test(expected = IllegalArgumentException.class)\r
317 public void makeReservationException1Test() throws Exception {\r
5a196189 318 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
319 SessionController sc = new SessionController(dh);\r
320 UserController uc = null;\r
73469283 321\r
c1191616
M
322 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
323 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
324 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
325 for (Controller controller : controllers) {\r
73469283
D
326 if (controller.getClass().equals(UserController.class))\r
327 uc = (UserController) controller;\r
c1191616 328 }\r
66cc653d 329\r
5a196189
M
330 Resource resource1 = new Resource("Room101", "Class room");\r
331 Resource resource2 = new Resource("Room101", "Class room");\r
332 Resource resource3 = new Resource("Room101", "Class room");\r
333 dh.addResource(resource1);\r
334 dh.addResource(resource2);\r
335 dh.addResource(resource3);\r
66cc653d 336\r
5a196189 337 List<DateRange> dtList = new ArrayList<DateRange>();\r
66cc653d
D
338 for (int i = 1; i < 10; i++) {\r
339 dtList.add(new DateRangeImpl(new Date(2015, 12, 2 + i, 11, 00, 00), new Date(2015, 12, 2 + i, 12, 00, 00)));\r
5a196189 340 }\r
66cc653d 341\r
c1191616 342 sc.logOut();\r
5a196189
M
343 assertEquals(null, uc.makeReservation(null, resource1, dtList, "remark"));\r
344 }\r
345\r
47d70ad5 346 @SuppressWarnings("deprecation")\r
66cc653d
D
347 @Test(expected = IllegalArgumentException.class)\r
348 public void makeReservationException2Test() throws Exception {\r
5a196189 349 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
350 SessionController sc = new SessionController(dh);\r
351 UserController uc = null;\r
73469283 352\r
c1191616
M
353 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
354 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
355 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
356 for (Controller controller : controllers) {\r
73469283
D
357 if (controller.getClass().equals(UserController.class))\r
358 uc = (UserController) controller;\r
c1191616 359 }\r
66cc653d 360\r
5a196189
M
361 Resource resource1 = new Resource("Room101", "Class room");\r
362 Resource resource2 = new Resource("Room101", "Class room");\r
363 Resource resource3 = new Resource("Room101", "Class room");\r
364 dh.addResource(resource1);\r
365 dh.addResource(resource2);\r
366 dh.addResource(resource3);\r
66cc653d 367\r
5a196189 368 List<DateRange> dtList = new ArrayList<DateRange>();\r
66cc653d
D
369 for (int i = 1; i < 10; i++) {\r
370 dtList.add(new DateRangeImpl(new Date(2015, 12, 2 + i, 11, 00, 00), new Date(2015, 12, 2 + i, 12, 00, 00)));\r
5a196189 371 }\r
66cc653d 372\r
5a196189
M
373 assertEquals(null, uc.makeReservation(null, null, dtList, "remark"));\r
374 }\r
375\r
47d70ad5 376 @SuppressWarnings("deprecation")\r
c1191616 377 @Test(expected = Exception.class)\r
66cc653d 378 public void makeReservationException3Test() throws Exception {\r
5a196189 379 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
380 SessionController sc = new SessionController(dh);\r
381 UserController uc = null;\r
73469283 382\r
c1191616
M
383 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
384 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
385 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
386 for (Controller controller : controllers) {\r
73469283
D
387 if (controller.getClass().equals(UserController.class))\r
388 uc = (UserController) controller;\r
c1191616 389 }\r
66cc653d 390\r
5a196189
M
391 Resource resource1 = new Resource("Room101", "Class room");\r
392 Resource resource2 = new Resource("Room101", "Class room");\r
393 Resource resource3 = new Resource("Room101", "Class room");\r
394 dh.addResource(resource1);\r
395 dh.addResource(resource2);\r
396 dh.addResource(resource3);\r
66cc653d 397\r
5a196189 398 List<DateRange> dtList = new ArrayList<DateRange>();\r
66cc653d
D
399 for (int i = 1; i < 10; i++) {\r
400 dtList.add(new DateRangeImpl(new Date(2015, 12, 2 + i, 11, 00, 00), new Date(2015, 12, 2 + i, 12, 00, 00)));\r
5a196189 401 }\r
66cc653d 402\r
c1191616 403 assertEquals(null, uc.makeReservation(uc.getUser("TestUser2"), resource1, null, "remark"));\r
5a196189
M
404 }\r
405\r
66cc653d
D
406 @Test(expected = IllegalArgumentException.class)\r
407 public void makeReservationException4Test() throws Exception {\r
5a196189 408 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
409 SessionController sc = new SessionController(dh);\r
410 UserController uc = null;\r
73469283 411\r
c1191616
M
412 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
413 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
414 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
415 for (Controller controller : controllers) {\r
73469283
D
416 if (controller.getClass().equals(UserController.class))\r
417 uc = (UserController) controller;\r
c1191616 418 }\r
66cc653d 419\r
5a196189
M
420 Resource resource1 = new Resource("Room101", "Class room");\r
421 Resource resource2 = new Resource("Room101", "Class room");\r
422 Resource resource3 = new Resource("Room101", "Class room");\r
423 dh.addResource(resource1);\r
424 dh.addResource(resource2);\r
425 dh.addResource(resource3);\r
66cc653d 426\r
5a196189 427 List<DateRange> dtList = new ArrayList<DateRange>();\r
66cc653d 428\r
5a196189
M
429 assertEquals(null, uc.makeReservation(null, resource1, dtList, "remark"));\r
430 }\r
73469283 431\r
b07a6f5c
M
432 @SuppressWarnings("deprecation")\r
433 @Test(expected = Exception.class)\r
434 public void makeReservationException5Test() throws Exception {\r
435 DataHandler dh = new DataHandlerForTests();\r
436 SessionController sc = new SessionController(dh);\r
437 UserController uc = null;\r
73469283 438\r
b07a6f5c
M
439 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
440 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
441 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
442 for (Controller controller : controllers) {\r
73469283
D
443 if (controller.getClass().equals(UserController.class))\r
444 uc = (UserController) controller;\r
b07a6f5c
M
445 }\r
446\r
447 Resource resource1 = new Resource("Room101", "Class room");\r
448 Resource resource2 = new Resource("Room101", "Class room");\r
449 Resource resource3 = new Resource("Room101", "Class room");\r
450 dh.addResource(resource1);\r
451 dh.addResource(resource2);\r
452 dh.addResource(resource3);\r
453\r
454 List<DateRange> dtList = new ArrayList<DateRange>();\r
455 for (int i = 1; i < 10; i++) {\r
456 dtList.add(new DateRangeImpl(new Date(2015, 12, 2 + i, 11, 00, 00), new Date(2015, 12, 2 + i, 12, 00, 00)));\r
457 }\r
66cc653d 458\r
b07a6f5c
M
459 assertEquals(null, uc.makeReservation(null, resource1, null, "remark"));\r
460 }\r
73469283 461\r
47d70ad5 462 @SuppressWarnings("deprecation")\r
5a196189 463 @Test\r
66cc653d 464 public void changeReservationTest() throws Exception {\r
5a196189 465 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
466 SessionController sc = new SessionController(dh);\r
467 UserController uc = null;\r
73469283 468\r
c1191616
M
469 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
470 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
471 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
472 for (Controller controller : controllers) {\r
73469283
D
473 if (controller.getClass().equals(UserController.class))\r
474 uc = (UserController) controller;\r
c1191616 475 }\r
66cc653d 476\r
5a196189 477 UUID groupId = UUID.randomUUID();\r
66cc653d
D
478 DateRange dateRange = new DateRangeImpl(new Date(2015, 12, 7, 14, 00, 00), new Date(2015, 12, 7, 15, 00, 00));\r
479\r
5a196189
M
480 Resource resource1 = new Resource("Room101", "Class room");\r
481 dh.addResource(resource1);\r
66cc653d 482\r
c1191616 483 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 484 "Test reservation1");\r
5a196189 485 dh.addReservation(reservation1);\r
66cc653d 486\r
5a196189 487 Reservation reservationClone = uc.getReservation(reservation1.getId());\r
66cc653d
D
488 DateRange newDateRange = new DateRangeImpl(new Date(2015, 12, 7, 20, 00, 00),\r
489 new Date(2015, 12, 8, 02, 00, 00));\r
5a196189
M
490 reservationClone.setDateRange(newDateRange);\r
491 uc.changeReservation(reservationClone);\r
66cc653d 492\r
5a196189
M
493 assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
494 }\r
66cc653d 495\r
47d70ad5 496 @SuppressWarnings("deprecation")\r
66cc653d
D
497 @Test(expected = Exception.class)\r
498 public void changeReservationException1Test() throws Exception {\r
5a196189 499 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
500 SessionController sc = new SessionController(dh);\r
501 UserController uc = null;\r
73469283 502\r
c1191616
M
503 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
504 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
505 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
506 for (Controller controller : controllers) {\r
73469283
D
507 if (controller.getClass().equals(UserController.class))\r
508 uc = (UserController) controller;\r
c1191616 509 }\r
66cc653d 510\r
5a196189
M
511 UUID groupId = UUID.randomUUID();\r
512 Date start = new Date();\r
513 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 514 Date finish = (Date) start.clone();\r
5a196189
M
515 finish.setMinutes(start.getMinutes() + 30);\r
516 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 517\r
5a196189
M
518 Resource resource1 = new Resource("Room101", "Class room");\r
519 dh.addResource(resource1);\r
66cc653d 520\r
c1191616 521 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 522 "Test reservation1");\r
5a196189 523 dh.addReservation(reservation1);\r
66cc653d 524\r
5a196189
M
525 Reservation reservationClone = uc.getReservation(reservation1.getId());\r
526 start.setDate(start.getDate() + 1);\r
527 finish.setDate(finish.getDate() + 1);\r
528 DateRange newDateRange = new DateRangeImpl(start, finish);\r
529 reservationClone.setDateRange(newDateRange);\r
66cc653d 530\r
5a196189
M
531 uc.setDataHandler(null);\r
532 uc.changeReservation(reservationClone);\r
66cc653d 533\r
5a196189
M
534 assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
535 }\r
66cc653d 536\r
47d70ad5 537 @SuppressWarnings("deprecation")\r
66cc653d
D
538 @Test(expected = Exception.class)\r
539 public void changeReservationException2Test() throws Exception {\r
5a196189 540 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
541 SessionController sc = new SessionController(dh);\r
542 UserController uc = null;\r
73469283 543\r
c1191616
M
544 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
545 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
546 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
547 for (Controller controller : controllers) {\r
73469283
D
548 if (controller.getClass().equals(UserController.class))\r
549 uc = (UserController) controller;\r
c1191616 550 }\r
66cc653d 551\r
5a196189
M
552 UUID groupId = UUID.randomUUID();\r
553 Date start = new Date();\r
554 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 555 Date finish = (Date) start.clone();\r
5a196189
M
556 finish.setMinutes(start.getMinutes() + 30);\r
557 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 558\r
5a196189
M
559 Resource resource1 = new Resource("Room101", "Class room");\r
560 dh.addResource(resource1);\r
66cc653d 561\r
c1191616 562 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 563 "Test reservation1");\r
5a196189 564 dh.addReservation(reservation1);\r
66cc653d 565\r
5a196189
M
566 Reservation reservationClone = uc.getReservation(reservation1.getId());\r
567 start.setDate(start.getDate() + 1);\r
568 finish.setDate(finish.getDate() + 1);\r
569 DateRange newDateRange = new DateRangeImpl(start, finish);\r
570 reservationClone.setDateRange(newDateRange);\r
66cc653d 571\r
c1191616 572 sc.logOut();\r
5a196189 573 uc.changeReservation(reservationClone);\r
66cc653d 574\r
5a196189
M
575 assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
576 }\r
66cc653d 577\r
47d70ad5 578 @SuppressWarnings("deprecation")\r
66cc653d
D
579 @Test(expected = IllegalArgumentException.class)\r
580 public void changeReservationException3Test() throws Exception {\r
5a196189 581 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
582 SessionController sc = new SessionController(dh);\r
583 UserController uc = null;\r
73469283 584\r
c1191616
M
585 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
586 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
587 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
588 for (Controller controller : controllers) {\r
73469283
D
589 if (controller.getClass().equals(UserController.class))\r
590 uc = (UserController) controller;\r
c1191616 591 }\r
66cc653d 592\r
5a196189
M
593 UUID groupId = UUID.randomUUID();\r
594 Date start = new Date();\r
595 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 596 Date finish = (Date) start.clone();\r
5a196189
M
597 finish.setMinutes(start.getMinutes() + 30);\r
598 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 599\r
5a196189
M
600 Resource resource1 = new Resource("Room101", "Class room");\r
601 dh.addResource(resource1);\r
66cc653d 602\r
c1191616 603 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 604 "Test reservation1");\r
5a196189 605 dh.addReservation(reservation1);\r
66cc653d 606\r
5a196189
M
607 Reservation reservationClone = uc.getReservation(reservation1.getId());\r
608 start.setDate(start.getDate() + 1);\r
609 finish.setDate(finish.getDate() + 1);\r
610 DateRange newDateRange = new DateRangeImpl(start, finish);\r
611 reservationClone.setDateRange(newDateRange);\r
66cc653d 612\r
5a196189 613 uc.changeReservation(null);\r
66cc653d 614\r
5a196189
M
615 assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
616 }\r
66cc653d 617\r
47d70ad5 618 @SuppressWarnings("deprecation")\r
66cc653d
D
619 @Test(expected = Exception.class)\r
620 public void changeReservationException4Test() throws Exception {\r
5a196189 621 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
622 SessionController sc = new SessionController(dh);\r
623 UserController uc = null;\r
73469283 624\r
c1191616
M
625 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
626 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
627 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
628 for (Controller controller : controllers) {\r
73469283
D
629 if (controller.getClass().equals(UserController.class))\r
630 uc = (UserController) controller;\r
c1191616 631 }\r
66cc653d 632\r
5a196189
M
633 UUID groupId = UUID.randomUUID();\r
634 Date start = new Date();\r
635 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 636 Date finish = (Date) start.clone();\r
5a196189
M
637 finish.setMinutes(start.getMinutes() + 30);\r
638 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 639\r
5a196189
M
640 Resource resource1 = new Resource("Room101", "Class room");\r
641 dh.addResource(resource1);\r
66cc653d 642\r
c1191616 643 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 644 "Test reservation1");\r
5a196189 645 dh.addReservation(reservation1);\r
66cc653d 646\r
5a196189
M
647 Reservation reservationClone = uc.getReservation(reservation1.getId());\r
648 start.setDate(start.getDate() + 1);\r
649 finish.setDate(finish.getDate() + 1);\r
650 DateRange newDateRange = new DateRangeImpl(start, finish);\r
651 reservationClone.setDateRange(newDateRange);\r
66cc653d 652\r
c1191616
M
653 sc.logOut();\r
654 sc.logIn("TestUser2", "pass2");\r
5a196189 655 uc.changeReservation(reservationClone);\r
66cc653d 656\r
5a196189
M
657 assertEquals(newDateRange, uc.getReservation(reservationClone.getId()).getDateRange());\r
658 }\r
66cc653d 659\r
47d70ad5 660 @SuppressWarnings("deprecation")\r
5a196189 661 @Test\r
66cc653d 662 public void deleteReservationTest() throws Exception {\r
5a196189 663 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
664 SessionController sc = new SessionController(dh);\r
665 UserController uc = null;\r
73469283 666\r
c1191616
M
667 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
668 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
669 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
670 for (Controller controller : controllers) {\r
73469283
D
671 if (controller.getClass().equals(UserController.class))\r
672 uc = (UserController) controller;\r
c1191616 673 }\r
66cc653d 674\r
5a196189
M
675 UUID groupId = UUID.randomUUID();\r
676 Date start = new Date();\r
677 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 678 Date finish = (Date) start.clone();\r
5a196189
M
679 finish.setMinutes(start.getMinutes() + 30);\r
680 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 681\r
5a196189
M
682 Resource resource1 = new Resource("Room101", "Class room");\r
683 dh.addResource(resource1);\r
66cc653d 684\r
c1191616 685 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 686 "Test reservation1");\r
5a196189 687 dh.addReservation(reservation1);\r
66cc653d 688\r
5a196189 689 uc.deleteReservation(reservation1);\r
66cc653d 690\r
5a196189
M
691 assertEquals(null, uc.getReservation(reservation1.getId()));\r
692 }\r
66cc653d 693\r
47d70ad5 694 @SuppressWarnings("deprecation")\r
66cc653d
D
695 @Test(expected = Exception.class)\r
696 public void deleteReservationException1Test() throws Exception {\r
5a196189 697 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
698 SessionController sc = new SessionController(dh);\r
699 UserController uc = null;\r
73469283 700\r
c1191616
M
701 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
702 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
703 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
704 for (Controller controller : controllers) {\r
73469283
D
705 if (controller.getClass().equals(UserController.class))\r
706 uc = (UserController) controller;\r
c1191616 707 }\r
66cc653d 708\r
5a196189
M
709 UUID groupId = UUID.randomUUID();\r
710 Date start = new Date();\r
711 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 712 Date finish = (Date) start.clone();\r
5a196189
M
713 finish.setMinutes(start.getMinutes() + 30);\r
714 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 715\r
5a196189
M
716 Resource resource1 = new Resource("Room101", "Class room");\r
717 dh.addResource(resource1);\r
66cc653d 718\r
c1191616 719 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 720 "Test reservation1");\r
5a196189 721 dh.addReservation(reservation1);\r
66cc653d 722\r
5a196189
M
723 uc.setDataHandler(null);\r
724 uc.deleteReservation(reservation1);\r
66cc653d 725\r
5a196189
M
726 assertEquals(null, uc.getReservation(reservation1.getId()));\r
727 }\r
66cc653d 728\r
47d70ad5 729 @SuppressWarnings("deprecation")\r
66cc653d
D
730 @Test(expected = Exception.class)\r
731 public void deleteReservationException2Test() throws Exception {\r
5a196189 732 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
733 SessionController sc = new SessionController(dh);\r
734 UserController uc = null;\r
73469283 735\r
c1191616
M
736 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
737 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
738 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
739 for (Controller controller : controllers) {\r
73469283
D
740 if (controller.getClass().equals(UserController.class))\r
741 uc = (UserController) controller;\r
c1191616 742 }\r
66cc653d 743\r
5a196189
M
744 UUID groupId = UUID.randomUUID();\r
745 Date start = new Date();\r
746 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 747 Date finish = (Date) start.clone();\r
5a196189
M
748 finish.setMinutes(start.getMinutes() + 30);\r
749 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 750\r
5a196189
M
751 Resource resource1 = new Resource("Room101", "Class room");\r
752 dh.addResource(resource1);\r
66cc653d 753\r
c1191616 754 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 755 "Test reservation1");\r
5a196189 756 dh.addReservation(reservation1);\r
66cc653d 757\r
c1191616 758 sc.logOut();\r
5a196189 759 uc.deleteReservation(reservation1);\r
66cc653d 760\r
5a196189
M
761 assertEquals(null, uc.getReservation(reservation1.getId()));\r
762 }\r
66cc653d 763\r
47d70ad5 764 @SuppressWarnings("deprecation")\r
66cc653d
D
765 @Test(expected = IllegalArgumentException.class)\r
766 public void deleteReservationException3Test() throws Exception {\r
5a196189 767 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
768 SessionController sc = new SessionController(dh);\r
769 UserController uc = null;\r
73469283 770\r
c1191616
M
771 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
772 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
773 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
774 for (Controller controller : controllers) {\r
73469283
D
775 if (controller.getClass().equals(UserController.class))\r
776 uc = (UserController) controller;\r
c1191616 777 }\r
66cc653d 778\r
5a196189
M
779 UUID groupId = UUID.randomUUID();\r
780 Date start = new Date();\r
781 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 782 Date finish = (Date) start.clone();\r
5a196189
M
783 finish.setMinutes(start.getMinutes() + 30);\r
784 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 785\r
5a196189
M
786 Resource resource1 = new Resource("Room101", "Class room");\r
787 dh.addResource(resource1);\r
66cc653d 788\r
c1191616 789 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 790 "Test reservation1");\r
5a196189 791 dh.addReservation(reservation1);\r
66cc653d 792\r
5a196189 793 uc.deleteReservation(null);\r
66cc653d 794\r
5a196189
M
795 assertEquals(null, uc.getReservation(reservation1.getId()));\r
796 }\r
66cc653d 797\r
47d70ad5 798 @SuppressWarnings("deprecation")\r
66cc653d
D
799 @Test(expected = Exception.class)\r
800 public void deleteReservationException4Test() throws Exception {\r
5a196189 801 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
802 SessionController sc = new SessionController(dh);\r
803 UserController uc = null;\r
73469283 804\r
c1191616
M
805 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
806 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
807 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
808 for (Controller controller : controllers) {\r
73469283
D
809 if (controller.getClass().equals(UserController.class))\r
810 uc = (UserController) controller;\r
c1191616 811 }\r
66cc653d 812\r
5a196189
M
813 UUID groupId = UUID.randomUUID();\r
814 Date start = new Date();\r
815 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 816 Date finish = (Date) start.clone();\r
5a196189
M
817 finish.setMinutes(start.getMinutes() + 30);\r
818 DateRange dateRange = new DateRangeImpl(start, finish);\r
66cc653d 819\r
5a196189
M
820 Resource resource1 = new Resource("Room101", "Class room");\r
821 dh.addResource(resource1);\r
66cc653d 822\r
c1191616 823 Reservation reservation1 = new Reservation(groupId, sc.getLoggedUser(), resource1, dateRange,\r
66cc653d 824 "Test reservation1");\r
5a196189 825 dh.addReservation(reservation1);\r
66cc653d 826\r
c1191616
M
827 sc.logOut();\r
828 sc.logIn("TestUser2", "pass2");\r
5a196189 829 uc.deleteReservation(reservation1);\r
66cc653d 830\r
5a196189
M
831 assertEquals(null, uc.getReservation(reservation1.getId()));\r
832 }\r
66cc653d 833\r
47d70ad5 834 @SuppressWarnings("deprecation")\r
5a196189 835 @Test\r
66cc653d 836 public void getResourcesTest() throws Exception {\r
5a196189 837 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
838 SessionController sc = new SessionController(dh);\r
839 UserController uc = null;\r
73469283 840\r
c1191616
M
841 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
842 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
843 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
844 for (Controller controller : controllers) {\r
73469283
D
845 if (controller.getClass().equals(UserController.class))\r
846 uc = (UserController) controller;\r
c1191616 847 }\r
66cc653d 848\r
5a196189
M
849 Date start = new Date();\r
850 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 851 Date finish = (Date) start.clone();\r
5a196189 852 finish.setMinutes(start.getMinutes() + 30);\r
66cc653d 853\r
5a196189
M
854 Resource resource1 = new Resource("Room101", "Class room");\r
855 Resource resource2 = new Resource("Room101", "Class room");\r
856 Resource resource3 = new Resource("Room101", "Class room");\r
857 dh.addResource(resource1);\r
858 dh.addResource(resource2);\r
859 dh.addResource(resource3);\r
66cc653d 860\r
5a196189 861 List<Resource> resList = uc.getResources();\r
66cc653d
D
862\r
863 assertEquals(3, resList.size());\r
5a196189 864 }\r
66cc653d 865\r
47d70ad5 866 @SuppressWarnings("deprecation")\r
66cc653d
D
867 @Test(expected = Exception.class)\r
868 public void getResourcesExceptionTest() throws Exception {\r
5a196189 869 DataHandler dh = new DataHandlerForTests();\r
c1191616
M
870 SessionController sc = new SessionController(dh);\r
871 UserController uc = null;\r
73469283 872\r
c1191616
M
873 sc.registUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
874 sc.registUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
875 Set<Controller> controllers = sc.logIn("TestUser1", "pass1");\r
876 for (Controller controller : controllers) {\r
73469283
D
877 if (controller.getClass().equals(UserController.class))\r
878 uc = (UserController) controller;\r
c1191616 879 }\r
66cc653d 880\r
5a196189
M
881 Date start = new Date();\r
882 start.setTime((System.currentTimeMillis() % 1000));\r
66cc653d 883 Date finish = (Date) start.clone();\r
5a196189 884 finish.setMinutes(start.getMinutes() + 30);\r
66cc653d 885\r
5a196189
M
886 Resource resource1 = new Resource("Room101", "Class room");\r
887 Resource resource2 = new Resource("Room101", "Class room");\r
888 Resource resource3 = new Resource("Room101", "Class room");\r
889 dh.addResource(resource1);\r
890 dh.addResource(resource2);\r
891 dh.addResource(resource3);\r
66cc653d 892\r
5a196189
M
893 uc.setDataHandler(null);\r
894 List<Resource> resList = uc.getResources();\r
66cc653d
D
895\r
896 assertEquals(3, resList.size());\r
5a196189 897 }\r
1ec0e01f 898}\r