Added commons-codec as Maven dependency and removed library from tree.
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / core / UserTest.java
CommitLineData
7f912ebe
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
12import java.util.Set;\r
13\r
14import org.junit.BeforeClass;\r
15import org.junit.Test;\r
16\r
17public class UserTest {\r
d6a2afc6 18 private Set<User> userList;\r
7f912ebe
M
19 User TestUser;\r
20 \r
21 @BeforeClass\r
22 public static void setUpBeforeClass() throws Exception {\r
23 \r
24 }\r
25\r
26 @Test\r
d6a2afc6
M
27 public void createUserTest() {\r
28 TestUser = new User("TestUser","pass");\r
7f912ebe
M
29 assertEquals("TestUser", TestUser.getUserName());\r
30 }\r
31 \r
32 @Test\r
d6a2afc6 33 public void checkPasswordTest() {\r
853407df 34 TestUser = new User("TestUser","pass");\r
d6a2afc6
M
35 assertTrue(TestUser.checkPassword("pass"));\r
36 assertFalse(TestUser.checkPassword("notmypass"));\r
37 }\r
38 \r
39 @Test\r
40 public void changePasswordTest() {\r
853407df 41 TestUser = new User("TestUser","pass");\r
d6a2afc6
M
42 assertTrue(TestUser.checkPassword("pass"));\r
43 TestUser.changePassword("newpass");\r
44 assertTrue(TestUser.checkPassword("newpass"));\r
45 assertFalse(TestUser.checkPassword("pass"));\r
46 assertFalse(TestUser.checkPassword("notmypass"));\r
47 }\r
48 \r
49 @Test\r
50 public void setMailTest() {\r
853407df 51 TestUser = new User("TestUser","pass");\r
d6a2afc6
M
52 String goodMail = "grosm9@bfh.ch";\r
53 String wrongMail1 = "ioajfd.ch";\r
54 String wrongMail2 = "asjdfh@fds";\r
55 \r
56 assertTrue(TestUser.setMail(goodMail));\r
57 assertFalse(TestUser.setMail(wrongMail1));\r
58 assertFalse(TestUser.setMail(wrongMail2));\r
59 }\r
60 \r
8ceddb90 61 @Test\r
d6a2afc6 62 public void getMailTest() {\r
853407df 63 TestUser = new User("TestUser","pass");\r
d6a2afc6
M
64 String mail = "grosm9@bfh.ch";\r
65 \r
66 TestUser.setMail(mail);\r
67 assertEquals(mail, TestUser.getMail());\r
7f912ebe
M
68 }\r
69\r
8ceddb90
M
70 @Test\r
71 public void setAndGetNameTest() {\r
853407df 72 TestUser = new User("TestUser","pass");\r
a019e29e 73 TestUser.setName("Tester");\r
8ceddb90
M
74 assertEquals("Tester",TestUser.getName());\r
75 }\r
76 \r
77 @Test\r
61e1becd 78 public void setAndGetLastnameTest() {\r
853407df 79 TestUser = new User("TestUser","pass");\r
a019e29e 80 TestUser.setLastname("Dummy");\r
129640a7 81 assertEquals("Dummy", TestUser.getLastname());\r
8ceddb90 82 }\r
7f912ebe 83}\r