packaging updated
[staff/due1/sed-hs15-srs-purple.git] / src / main / java / ch / bfh / ti / srs / datahandler / DataHandlerForTests.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
M
9\r
10import java.util.HashSet;\r
11import java.util.Set;\r
12\r
e3535133
M
13import ch.bfh.ti.srs.core.User;\r
14\r
1f7b5004
M
15public class DataHandlerForTests implements DataHandler{\r
16 Set<User> userList = new HashSet<User>();\r
17 \r
18 public DataHandlerForTests(){\r
19 \r
20 }\r
21\r
22 /* (non-Javadoc)\r
23 * @see ch.bfh.ti.srs.core.DataHandler#findUser(java.lang.String)\r
24 */\r
25 @Override\r
26 public User findUser(String userName) {\r
27 for (User user : userList) {\r
28 if(user.getUserName().equals(userName)) return user;\r
29 }\r
30 return null;\r
31 }\r
32\r
33 /* (non-Javadoc)\r
34 * @see ch.bfh.ti.srs.core.DataHandler#addUser(ch.bfh.ti.srs.core.User)\r
35 */\r
36 @Override\r
37 public void addUser(User user) throws Exception {\r
38 if(user == null) throw new IllegalArgumentException("User object must not be null!");\r
39 userList.add(user);\r
40 }\r
41}\r