unused imports removed
[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
10import static org.junit.Assert.*;\r
11\r
1f7b5004
M
12import org.junit.Test;\r
13\r
14/**\r
15 * @author Michael Grossen\r
16 */\r
17public class DataHandlerForTestsTest {\r
18\r
19 @Test\r
20 public void addUserTest() throws Exception{\r
21 DataHandler dh = new DataHandlerForTests();\r
22 User testUser = null;\r
23 try {\r
24 testUser = new User("TestUser", "pass");\r
25 } catch (Exception e) {\r
26 fail("Check UserTest (Exception was thrown by User Cunstructor)!");\r
27 }\r
28 dh.addUser(testUser);\r
29 }\r
30 \r
31 @Test(expected=IllegalArgumentException.class)\r
32 public void addIllegalUserTest() throws Exception{\r
33 DataHandler dh = new DataHandlerForTests();\r
34 User testUser = null;\r
35 dh.addUser(testUser);\r
36 }\r
37 \r
38 @Test\r
39 public void findUserTest() throws Exception{\r
40 DataHandler dh = new DataHandlerForTests();\r
41 User addedUser = new User("TestUser", "pass");\r
42 dh.addUser(addedUser);\r
43 User foundUser = dh.findUser("TestUser");\r
44 assertEquals(addedUser.getUserName(), foundUser.getUserName());\r
45 }\r
46 \r
47 @Test\r
48 public void findNotAddedUser() throws Exception{\r
49 DataHandler dh = new DataHandlerForTests();\r
50 assertEquals(null, dh.findUser("notAddedUser"));\r
51 User addedUser = new User("TestUser", "pass");\r
52 dh.addUser(addedUser);\r
53 assertEquals(null, dh.findUser("otherUser"));\r
54 }\r
55\r
56}\r