forked from Vidhee1411/Internship-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInternshipApplicationTest.java
180 lines (152 loc) · 6.06 KB
/
InternshipApplicationTest.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
public class InternshipApplicationTest {
private User user;
private int permission;
private SearchableDatabase database;
@BeforeClass
public void oneTimeSetup() {
}
@AfterClass
public void oneTimeTearDown() {
}
@Before
public void setUp() {
this.database = DataLoader.loadData();
}
@After
public void tearDown() {
}
/*@Test
public void testCreateAccountWithStudent() {
InternshipApplication app = new InternshipApplication();
InputStream backup = System.in;
InputStream input = new ByteArrayInputStream("Jennifer\nLupfalter\[email protected]\nLadyLuck54321".getBytes());
System.setIn(input);
assertTrue(app.createAccount("Student"));
System.setIn(backup);
}*/
@Test
public void testLogOn() {
String email = "[email protected]";
String password = "12345678";
InternshipApplication app = new InternshipApplication();
assertTrue(app.logOn(email, password));
}
@Test
public void testLogOff() {
InternshipApplication app = new InternshipApplication();
app.logOn("[email protected]", "12345678");
app.logOff();
}
@Test
public void testSearchByPayRateNormal() {
InternshipApplication app = new InternshipApplication();
assertEquals(app.search(25.0).get(0).getTitle(), "Web Developer");
assertEquals(app.search(25.0).get(0).getPaid(), true);
assertEquals(app.search(25.0).get(0).getLocation(), "SouthCarolina");
assertEquals(app.search(25.0).get(0).getPayRate(), 55.00);
assertEquals(app.search(25.0).get(0).getCompany(), "WeyLand-Yutani");
assertEquals(app.search(25.0).get(1).getTitle(), "Genetic Reasearh Intern");
assertEquals(app.search(25.0).get(1).getPaid(), true);
assertEquals(app.search(25.0).get(1).getLocation(), "SouthCarolina");
assertEquals(app.search(25.0).get(1).getPayRate(), 25.00);
assertEquals(app.search(25.0).get(1).getCompany(), "WeyLand-Yutani");
}
@Test
public void testSearchByPayRateSizeGreaterThan25() {
InternshipApplication app = new InternshipApplication();
assertEquals(1, app.search(30.0).size());
}
@Test
public void testSearchByPayRateSizeLessThan25() {
InternshipApplication app = new InternshipApplication();
assertEquals(2, app.search(20.0).size());
}
@Test
public void testSearchByPayRateSizeEquals25() {
InternshipApplication app = new InternshipApplication();
assertEquals(2, app.search(25.0).size());
}
@Test
public void testSearchByPayRateSizeEquals55() {
InternshipApplication app = new InternshipApplication();
assertEquals(1, app.search(55.0).size());
}
@Test
public void testSearchByPayRateSizeGreaterThan55() {
InternshipApplication app = new InternshipApplication();
assertEquals(0, app.search(85.0).size());
}
@Test
public void testSearchByTitleNormal() {
InternshipApplication app = new InternshipApplication();
assertEquals(1, app.search("Web Developer").size());
}
@Test
public void testSearchByTitleSubstring() {
InternshipApplication app = new InternshipApplication();
assertEquals(1, app.search("dev").size());
}
@Test
public void testSearchByTitleNullTitle() {
InternshipApplication app = new InternshipApplication();
assertEquals(2, app.search("").size());
}
@Test
public void testSearchByTitleNotInDatabase() {
InternshipApplication app = new InternshipApplication();
assertEquals(0, app.search("z").size());
}
@Test
public void testSearchBySkillNormal() {
InternshipApplication app = new InternshipApplication();
assertEquals(2, app.searchBySkill("morally ambiguous").size());
}
@Test
public void testSearchByNullSkill() {
InternshipApplication app = new InternshipApplication();
assertEquals(0, app.searchBySkill("").size());
}
@Test
public void testSearchByNonExistentSkill() {
InternshipApplication app = new InternshipApplication();
assertEquals(0, app.searchBySkill("grand ole fellow").size());
}
@Test
public void testAssociateCompanyNormal() {
String email = "[email protected]";
String password = "password";
InternshipApplication app = new InternshipApplication();
app.logOn(email, password); // This user was previously associated with a company - duplicate profile below
CompanyProfile comp = new CompanyProfile("WeyLand-Yutani", "135 Sulaco Drive ", "pushing the boundries of science");
Employer emp = (Employer) app.getUser();
assertEquals(emp.getCompany().getCompanyName(), comp.getCompanyName());
assertEquals(emp.getCompany().getAddress(), comp.getAddress());
assertEquals(emp.getCompany().getDescription(), comp.getDescription());
}
@Test //Tests for a student that previously applied for a listing through the applyForInternship method
public void testApplyForInternshipNormal() {
String studentEmail = "[email protected]";
String studentPassword = "12345678";
String employerEmail = "[email protected]";
String employerPassword = "password";
InternshipApplication app = new InternshipApplication();
app.logOn(employerEmail, employerPassword);
Employer emp = (Employer) app.getUser();
JobListing jl = emp.getCompany().getListings().get(0);
app.logOff();
app.logOn(studentEmail, studentPassword);
Student stud = (Student) app.getUser();
assertEquals(jl.getApplicants().get(0),stud);
}
}