forked from nus-cs2103-AY1819S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 4
/
GuiTestAssert.java
73 lines (64 loc) · 3.11 KB
/
GuiTestAssert.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
package seedu.address.ui.testutil;
import static org.junit.Assert.assertEquals;
import java.util.List;
import java.util.stream.Collectors;
import guitests.guihandles.ResultDisplayHandle;
import guitests.guihandles.VolunteerCardHandle;
import guitests.guihandles.VolunteerListPanelHandle;
import seedu.address.model.volunteer.Volunteer;
/**
* A set of assertion methods useful for writing GUI tests.
*/
public class GuiTestAssert {
/**
* Asserts that {@code actualCard} displays the same values as {@code expectedCard}.
*/
public static void assertCardEquals(VolunteerCardHandle expectedCard, VolunteerCardHandle actualCard) {
assertEquals(expectedCard.getId(), actualCard.getId());
assertEquals(expectedCard.getEmail(), actualCard.getEmail());
assertEquals(expectedCard.getName(), actualCard.getName());
assertEquals(expectedCard.getPhone(), actualCard.getPhone());
assertEquals(expectedCard.getTags(), actualCard.getTags());
}
/**
* Asserts that {@code actualCard} displays the details of {@code expectedVolunteer}.
*/
public static void assertCardDisplaysVolunteer(Volunteer expectedVolunteer, VolunteerCardHandle actualCard) {
assertEquals(expectedVolunteer.getName().fullName, actualCard.getName());
assertEquals(expectedVolunteer.getPhone().value, actualCard.getPhone());
assertEquals(expectedVolunteer.getEmail().value, actualCard.getEmail());
assertEquals(expectedVolunteer.getTags().stream().map(tag -> tag.tagName).collect(Collectors.toList()),
actualCard.getTags());
}
/**
* Asserts that the list in {@code volunteerListPanelHandle} displays the details of {@code volunteers} correctly
* and in the correct order.
*/
public static void assertListMatching(VolunteerListPanelHandle volunteerListPanelHandle, Volunteer... volunteers) {
for (int i = 0; i < volunteers.length; i++) {
volunteerListPanelHandle.navigateToCard(i);
assertCardDisplaysVolunteer(volunteers[i], volunteerListPanelHandle.getVolunteerCardHandle(i));
}
}
/**
* Asserts that the list in {@code volunteerListPanelHandle} displays the details of {@code volunteers}
* correctly and in the correct order.
*/
public static void assertListMatching(VolunteerListPanelHandle volunteerListPanelHandle,
List<Volunteer> volunteers) {
assertListMatching(volunteerListPanelHandle, volunteers.toArray(new Volunteer[0]));
}
/**
* Asserts the size of the list in {@code volunteerListPanelHandle} equals to {@code size}.
*/
public static void assertListSize(VolunteerListPanelHandle volunteerListPanelHandle, int size) {
int numberOfPeople = volunteerListPanelHandle.getListSize();
assertEquals(size, numberOfPeople);
}
/**
* Asserts the message shown in {@code resultDisplayHandle} equals to {@code expected}.
*/
public static void assertResultMessage(ResultDisplayHandle resultDisplayHandle, String expected) {
assertEquals(expected, resultDisplayHandle.getText());
}
}