-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserListTest.java
78 lines (64 loc) · 2.13 KB
/
UserListTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.UUID;
public class UserListTest {
private User user1;
private User user2;
private UUID id1;
private UUID id2;
private UUID id3;
private UserList userList;
@Test
public void getInstance_Test() {
userList = UserList.getInstance();
assertNotNull(userList);
}
@Before
public void setUp() {
userList = UserList.getInstance();
id1 = UUID.randomUUID();
id2 = UUID.randomUUID();
user1 = new User(id1, "Brax", "West", "[email protected]", "password");
user2 = new User(id2, "Jane", "Doe", "[email protected]", "password");
user1.setUserType(UserType.STUDENT);
user2.setUserType(UserType.ADVISOR);
//((Student) user1).setStudentID("X12345678");
userList.addUser(user1);
userList.addUser(user2);
}
@Test
public void getUserEmailAndPassword_Test1() {
User userActual = userList.getUser("[email protected]", "password");
assertEquals(user1, userActual);
}
@Test
public void getUserEmailAndPassword_Test2() {
User userActual = userList.getUser("[email protected]", "password");
assertEquals(user2, userActual);
}
@Test
public void getUserStudentID_Test() {
User userActual = userList.getUser("X12345678");
assertEquals(user1, userActual);
}
@Test
public void getUserNameAndPassword_Test() {
User userActual = userList.getUser("Brax", "West", "password");
assertEquals(user1, userActual);
}
@Test
public void getUserID_Test() {
User userActual = userList.getUser(id1);
assertEquals(user1, userActual);
}
@Test
public void createUser_Test() {
userList.createUser("Advisor", "John", "Smith", "password", "[email protected]", null);
id3 = UUID.randomUUID();
User userExpected = new User(id3, "John", "Smith", "[email protected]", "password");
assertEquals(userExpected, userList.getUser(id3));
}
}