-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateWithExclRewardTest.java
83 lines (66 loc) · 2.56 KB
/
CreateWithExclRewardTest.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
79
80
81
82
83
package STassgn;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import junitparams.JUnitParamsRunner;
@RunWith(JUnitParamsRunner.class)
public class CreateWithExclRewardTest {
DisplayUtilities duMock;
Room roomMock;
BookingRecordApplication braMock;
User userMock;
HotelBookingSystem hbs;
WaitingList waitingListMock;
@Before
public void setup() {
hbs = new HotelBookingSystem();
duMock = mock(DisplayUtilities.class);
roomMock = mock(Room.class);
braMock = mock(BookingRecordApplication.class);
waitingListMock = mock(WaitingList.class);
hbs.setDu(duMock);
hbs.setRoom(roomMock);
hbs.setBra(braMock);
hbs.setWaitingList(waitingListMock);
}
@Test
public void testCreateWithExclReward_RedeemExclReward_VIPAvailable() {
when(duMock.getFromScreen()).thenReturn("Y");
when(roomMock.checkRoom("VIP")).thenReturn(true);
hbs.createWithExclReward();
verify(duMock).showToScreen("You have an exclusive reward.\n");
verify(duMock).showToScreen("Do you want to redeem it? (Y/N): ");
verify(roomMock).checkRoom("VIP");
verify(duMock).showToScreen("You got a free VIP room from exclusive reward!\n\n");
verify(roomMock).vip--;
verify(braMock).addBookingRecord(any(Booking.class));
}
@Test
public void testCreateWithExclReward_RedeemExclReward_VIPNotAvailable_StandardAvailable() {
when(duMock.getFromScreen()).thenReturn("Y");
when(roomMock.checkRoom("VIP")).thenReturn(false);
when(roomMock.checkRoom("Standard")).thenReturn(true);
hbs.createWithExclReward();
verify(duMock).showToScreen("You have an exclusive reward.\n");
verify(duMock).showToScreen("Do you want to redeem it? (Y/N): ");
verify(roomMock).checkRoom("VIP");
verify(roomMock).checkRoom("Standard");
verify(duMock).showToScreen("VIP room not available. Allocating Standard room instead for exclusive reward.\n");
verify(roomMock).standard--;
verify(braMock).addBookingRecord(any(Booking.class));
}
@Test
public void testCreateWithExclReward_NoRedeemExclReward() {
when(duMock.getFromScreen()).thenReturn("N");
hbs.createWithExclReward();
verify(duMock).showToScreen("You have an exclusive reward.\n");
verify(duMock).showToScreen("Do you want to redeem it? (Y/N): ");
verify(waitingListMock).addWaiting(any(User.class));
}
}