-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemoveWaitingTest.java
57 lines (43 loc) · 1.47 KB
/
RemoveWaitingTest.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
package STassgn;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@RunWith(JUnitParamsRunner.class)
public class RemoveWaitingTest {
private WaitingList waitingList;
private DisplayUtilities duMock;
@Before
public void setup() {
duMock = mock(DisplayUtilities.class);
waitingList = new WaitingList();
waitingList.du = duMock;
}
private Object[] getUsersToRemove() {
User vipUser = new User("John", "VIP", false);
User memberUser = new User("Alice", "Normal", true);
User normalUser = new User("Bob", "Non-member", false);
return new Object[] { vipUser, memberUser, normalUser };
}
@Test
@Parameters(method = "getUsersToRemove")
public void testRemoveWaiting(User user) {
waitingList.addWaiting(user);
waitingList.removeWaiting(user);
ArrayList<User> AR = waitingList.getWaiting(user.getMemberType());
assertTrue(AR.isEmpty());
}
@Test(expected = IllegalArgumentException.class)
public void testRemoveWaitingNullUser() {
waitingList.removeWaiting(null);
}
@Test(expected = IllegalArgumentException.class)
public void testRemoveWaitingInvalidUserType() {
User user = new User("Unknown", "Standard", false);
waitingList.removeWaiting(user);
}
}