imports tweaked
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / core / 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
8package ch.bfh.ti.srs.core;\r
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
15/**\r
16 * @author Michael Grossen\r
17 */\r
18public class DataHandlerForTestsTest {\r
19\r
20 @Test\r
21 public void addUserTest() throws Exception{\r
22 DataHandler dh = new DataHandlerForTests();\r
23 User testUser = null;\r
24 try {\r
25 testUser = new User("TestUser", "pass");\r
26 } catch (Exception e) {\r
27 fail("Check UserTest (Exception was thrown by User Cunstructor)!");\r
28 }\r
29 dh.addUser(testUser);\r
30 }\r
31 \r
32 @Test(expected=IllegalArgumentException.class)\r
33 public void addIllegalUserTest() throws Exception{\r
34 DataHandler dh = new DataHandlerForTests();\r
35 User testUser = null;\r
36 dh.addUser(testUser);\r
37 }\r
38 \r
39 @Test\r
40 public void findUserTest() throws Exception{\r
41 DataHandler dh = new DataHandlerForTests();\r
42 User addedUser = new User("TestUser", "pass");\r
43 dh.addUser(addedUser);\r
44 User foundUser = dh.findUser("TestUser");\r
45 assertEquals(addedUser.getUserName(), foundUser.getUserName());\r
46 }\r
47 \r
48 @Test\r
49 public void findNotAddedUser() throws Exception{\r
50 DataHandler dh = new DataHandlerForTests();\r
51 assertEquals(null, dh.findUser("notAddedUser"));\r
52 User addedUser = new User("TestUser", "pass");\r
53 dh.addUser(addedUser);\r
54 assertEquals(null, dh.findUser("otherUser"));\r
55 }\r
56\r
57}\r