unused imports removed
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / core / DataHandlerForTestsTest.java
1 /*
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.
3 *
4 * Project Smart Reservation System.
5 *
6 * Distributable under GPL license. See terms of license at gnu.org.
7 */
8 package ch.bfh.ti.srs.core;
9
10 import static org.junit.Assert.*;
11
12 import org.junit.Test;
13
14 /**
15 * @author Michael Grossen
16 */
17 public class DataHandlerForTestsTest {
18
19 @Test
20 public void addUserTest() throws Exception{
21 DataHandler dh = new DataHandlerForTests();
22 User testUser = null;
23 try {
24 testUser = new User("TestUser", "pass");
25 } catch (Exception e) {
26 fail("Check UserTest (Exception was thrown by User Cunstructor)!");
27 }
28 dh.addUser(testUser);
29 }
30
31 @Test(expected=IllegalArgumentException.class)
32 public void addIllegalUserTest() throws Exception{
33 DataHandler dh = new DataHandlerForTests();
34 User testUser = null;
35 dh.addUser(testUser);
36 }
37
38 @Test
39 public void findUserTest() throws Exception{
40 DataHandler dh = new DataHandlerForTests();
41 User addedUser = new User("TestUser", "pass");
42 dh.addUser(addedUser);
43 User foundUser = dh.findUser("TestUser");
44 assertEquals(addedUser.getUserName(), foundUser.getUserName());
45 }
46
47 @Test
48 public void findNotAddedUser() throws Exception{
49 DataHandler dh = new DataHandlerForTests();
50 assertEquals(null, dh.findUser("notAddedUser"));
51 User addedUser = new User("TestUser", "pass");
52 dh.addUser(addedUser);
53 assertEquals(null, dh.findUser("otherUser"));
54 }
55
56 }