packaging updated
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / datahandler / DataHandlerForTestsTest.java
CommitLineData
1f7b5004
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.datahandler;\r
1f7b5004 9\r
9e071834
M
10import static org.junit.Assert.assertEquals;\r
11import static org.junit.Assert.fail;\r
1f7b5004 12\r
1f7b5004
M
13import org.junit.Test;\r
14\r
e3535133
M
15import ch.bfh.ti.srs.datahandler.DataHandler;\r
16import ch.bfh.ti.srs.datahandler.DataHandlerForTests;\r
5c0ee08b 17import ch.bfh.ti.srs.dataschema.User;\r
e3535133 18\r
1f7b5004
M
19/**\r
20 * @author Michael Grossen\r
21 */\r
22public class DataHandlerForTestsTest {\r
23\r
24 @Test\r
25 public void addUserTest() throws Exception{\r
26 DataHandler dh = new DataHandlerForTests();\r
27 User testUser = null;\r
28 try {\r
29 testUser = new User("TestUser", "pass");\r
30 } catch (Exception e) {\r
31 fail("Check UserTest (Exception was thrown by User Cunstructor)!");\r
32 }\r
33 dh.addUser(testUser);\r
34 }\r
35 \r
36 @Test(expected=IllegalArgumentException.class)\r
37 public void addIllegalUserTest() throws Exception{\r
38 DataHandler dh = new DataHandlerForTests();\r
39 User testUser = null;\r
40 dh.addUser(testUser);\r
41 }\r
42 \r
43 @Test\r
44 public void findUserTest() throws Exception{\r
45 DataHandler dh = new DataHandlerForTests();\r
46 User addedUser = new User("TestUser", "pass");\r
47 dh.addUser(addedUser);\r
48 User foundUser = dh.findUser("TestUser");\r
49 assertEquals(addedUser.getUserName(), foundUser.getUserName());\r
50 }\r
51 \r
52 @Test\r
53 public void findNotAddedUser() throws Exception{\r
54 DataHandler dh = new DataHandlerForTests();\r
55 assertEquals(null, dh.findUser("notAddedUser"));\r
56 User addedUser = new User("TestUser", "pass");\r
57 dh.addUser(addedUser);\r
58 assertEquals(null, dh.findUser("otherUser"));\r
59 }\r
60\r
61}\r