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
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 java.util.Set;
13
14 import org.junit.BeforeClass;
15 import org.junit.Test;
16
17 public class UserTest {
18 private Set<User> userList;
19 User TestUser;
20
21 @BeforeClass
22 public static void setUpBeforeClass() throws Exception {
23
24 }
25
26 @Test
27 public void createUserTest() {
28 TestUser = new User("TestUser","pass");
29 assertEquals("TestUser", TestUser.getUserName());
30 }
31
32 @Test
33 public void checkPasswordTest() {
34 TestUser = new User("TestUser","pass");
35 assertTrue(TestUser.checkPassword("pass"));
36 assertFalse(TestUser.checkPassword("notmypass"));
37 }
38
39 @Test
40 public void changePasswordTest() {
41 TestUser = new User("TestUser","pass");
42 assertTrue(TestUser.checkPassword("pass"));
43 TestUser.changePassword("newpass");
44 assertTrue(TestUser.checkPassword("newpass"));
45 assertFalse(TestUser.checkPassword("pass"));
46 assertFalse(TestUser.checkPassword("notmypass"));
47 }
48
49 @Test
50 public void setMailTest() {
51 TestUser = new User("TestUser","pass");
52 String goodMail = "grosm9@bfh.ch";
53 String wrongMail1 = "ioajfd.ch";
54 String wrongMail2 = "asjdfh@fds";
55
56 assertTrue(TestUser.setMail(goodMail));
57 assertFalse(TestUser.setMail(wrongMail1));
58 assertFalse(TestUser.setMail(wrongMail2));
59 }
60
61 @Test
62 public void getMailTest() {
63 TestUser = new User("TestUser","pass");
64 String mail = "grosm9@bfh.ch";
65
66 TestUser.setMail(mail);
67 assertEquals(mail, TestUser.getMail());
68 }
69
70 @Test
71 public void setAndGetNameTest() {
72 TestUser = new User("TestUser","pass");
73 TestUser.setName("Tester");
74 assertEquals("Tester",TestUser.getName());
75 }
76
77 @Test
78 public void setAndGetLastnameTest() {
79 TestUser = new User("TestUser","pass");
80 TestUser.setLastname("Dummy");
81 assertEquals("Dummy", TestUser.getLastname());
82 }
83 }