-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfileTestCases.java
More file actions
150 lines (123 loc) · 4.08 KB
/
ProfileTestCases.java
File metadata and controls
150 lines (123 loc) · 4.08 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
/**
* ProfileTestCases.java
*
* This class tests the methods in Profile that are unrelated to GUI
*
* @author Team 060, Section 11
* @version May 03, 2021
* */
public class ProfileTestCases {
public static void main(String[] args) throws IOException {
Profile testProfile = new Profile();
//Every Test case below is an example of proper input
try {
testProfile.getUsername();
testProfile.getInterests();
testProfile.getFriends();
testProfile.getEducation();
testProfile.getEmail();
testProfile.getPhoneNumber();
testProfile.getAboutMe();
testProfile.getRequestsSent();
testProfile.getRequestsReceived();
testProfile.setAboutMe("Something something");
testProfile.setEducation("Yale");
testProfile.setEmail("jbird@yale.edu");
testProfile.setFriends(new ArrayList<String>());
testProfile.addFriend("John");
testProfile.removeFriends("Josh");
testProfile.setInterests(new ArrayList<String>());
testProfile.addInterest("Hockey");
testProfile.removeInterest("Hockey");
testProfile.setPhoneNumber(6663331111L);
testProfile.setUsername("Jackson");
testProfile.setRequestsSent(new ArrayList<String>());
testProfile.addSentRequest("Charles");
testProfile.removeSentRequest("Charles");
testProfile.setRequestsReceived(new ArrayList<String>());
testProfile.addReceivedRequest("Casper");
testProfile.removeReceivedRequest("Casper");
testProfile.writeExportFile();
} catch (Exception e) {
System.out.println("There was an error running the test cases");
e.printStackTrace();
}
//Every test case below fails because it is given incorrect input
Boolean failed;
testProfile.setAboutMe(null);
testProfile.setEducation(null);
testProfile.setEmail(null);
int casesFailed = 0;
try {
Objects.requireNonNull(testProfile.getAboutMe());
} catch (Exception e) {
casesFailed++;
}
try {
Objects.requireNonNull(testProfile.getEducation());
} catch (Exception e) {
casesFailed++;
}
try {
Objects.requireNonNull(testProfile.getEmail());
} catch (Exception e) {
casesFailed++;
}
testProfile.setFriends(null);
try {
testProfile.addFriend("John");
} catch (Exception e) {
casesFailed++;
}
try {
testProfile.removeFriends("Josh");
} catch (Exception e) {
casesFailed++;
}
testProfile.setInterests(null);
try {
testProfile.removeInterest("Hockey");
} catch (Exception e) {
casesFailed++;
}
try {
testProfile.addInterest("Hockey");
} catch (Exception e) {
casesFailed++;
}
testProfile.setUsername(null);
try {
Objects.requireNonNull(testProfile.getUsername());
} catch (Exception e) {
casesFailed++;
}
testProfile.setRequestsSent(null);
try {
testProfile.addSentRequest("Charles");
} catch (Exception e) {
casesFailed++;
}
try {
testProfile.removeSentRequest("Charles");
} catch (Exception e) {
casesFailed++;
}
testProfile.setRequestsReceived(null);
try {
testProfile.addReceivedRequest("Casper");
} catch (Exception e) {
casesFailed++;
}
try {
testProfile.removeReceivedRequest("Casper");
} catch (Exception e) {
casesFailed++;
}
if(casesFailed == 12) {
System.out.println("All cases ran successfully");
}
}
}