-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBackend1.java
More file actions
190 lines (180 loc) · 13.2 KB
/
TestBackend1.java
File metadata and controls
190 lines (180 loc) · 13.2 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
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
181
182
183
184
185
186
187
188
189
190
import java.io.File;
import java.io.FileReader;
import java.io.StringReader;
/**
* This class contains a set of tests for the back end of the Movie Mapper project.
*/
public class TestBackend1 {
public static void main(String[] args) {
(new TestBackend1()).runTests();
}
public void runTests() {
// add all tests to this method
if (this.testInitialNumberOfMovies()) {
System.out.println("Test initial number of movies: PASSED");
} else {
System.out.println("Test initial number of movies: FAILED");
}
if (this.testGetAllGenres()) {
System.out.println("Test get all genres: PASSED");
} else {
System.out.println("Test get all genres: FAILED");
}
if (this.testGetThreeMoviesInitial()) {
System.out.println("Test get three movies sorted by rating: PASSED");
} else {
System.out.println("Test get three movies sorted by rating: FAILED");
}
if (this.testAddGenres()) {
System.out.println("Test add genre: PASSED");
} else {
System.out.println("Test add genre: FAILED");
}
if (this.testGetGenresInitial()) {
System.out.println("Test get genre: PASSED");
} else {
System.out.println("Test get genre: FAILED");
}
}
/**
* This test instantiates the back end with three movies and tests whether the
* initial selection is empty (getNumberOfMovies() returns 0). It passes when
* 0 is returned and fails in all other cases, including when an exception is
* thrown.
* @return true if the test passed, false if it failed
*/
public boolean testInitialNumberOfMovies() {
try {
// instantiate once BackendInterface is implemented
BackendInterface backendToTest = new Backend(new StringReader(
"title,original_title,year,genre,duration,country,language,director,writer,production_company,actors,description,avg_vote\n"
+ "The Source of Shadows,The Source of Shadows,2020,Horror,83,USA,English,\"Ryan Bury, Jennifer Bonior\",\"Jennifer Bonior, Trevor Botkin\",Four Thieves Productions,\"Ashleigh Allard, Tom Bonington, Eliane Gagnon, Marissa Kaye Grinestaff, Jenna Heffernan, Joshua Hummel, Janice Kingsley, Chris Labasbas, Jared Laufree, Dominic Lee, Vic May, Sienna Mazzone, Lizzie Mounter, Grace Mumm, Ashley Otis\",\"A series of stories woven together by one of our most primal fears, the fear of the unknown.\",3.5\n"
+ "The Insurrection,The Insurrection,2020,Action,90,USA,English,Rene Perez,Rene Perez,,\"Michael Par¨¦, Wilma Elles, Joseph Camilleri, Rebecca Tarabocchia, Jeanine Harrington, Malorie Glavan, Danner Boyd, Michael Cendejas, Woody Clendenen, Keely Dervin, Aaron Harvey, Tony Jackson, Michael Jarrod, Angelina Karo, Bernie Kelly\",The director of the largest media company wants to expose how left-wing powers use film to control populations.,2.9\n"
+ "Valley Girl,Valley Girl,2020,\"Comedy, Musical, Romance\",102,USA,English,Rachel Lee Goldenberg,\"Amy Talkington, Andrew Lane\",Sneak Preview Productions,\"Jessica Rothe, Josh Whitehouse, Jessie Ennis, Ashleigh Murray, Chloe Bennet, Logan Paul, Mae Whitman, Mario Revolori, Rob Huebel, Judy Greer, Alex Lewis, Alex MacNicoll, Danny Ramirez, Andrew Kai, Allyn Rachel\",\"Set to a new wave '80s soundtrack, a pair of young lovers from different backgrounds defy their parents and friends to stay together. A musical adaptation of the 1983 film.\",5.4\n"
));
if (backendToTest.getNumberOfMovies() == 0) {
// test passed
return true;
} else {
// test failed
return false;
}
} catch (Exception e) {
e.printStackTrace();
// test failed
return false;
}
}
/**
* This test instantiates the back end with three movies and tests whether
* the getAllGenres method return the correct set of genres for those three
* movies.
* @return true if the test passed, false if it failed
*/
public boolean testGetAllGenres() {
try {
BackendInterface backendToTest = new Backend(new StringReader(
"title,original_title,year,genre,duration,country,language,director,writer,production_company,actors,description,avg_vote\n"
+ "The Source of Shadows,The Source of Shadows,2020,Horror,83,USA,English,\"Ryan Bury, Jennifer Bonior\",\"Jennifer Bonior, Trevor Botkin\",Four Thieves Productions,\"Ashleigh Allard, Tom Bonington, Eliane Gagnon, Marissa Kaye Grinestaff, Jenna Heffernan, Joshua Hummel, Janice Kingsley, Chris Labasbas, Jared Laufree, Dominic Lee, Vic May, Sienna Mazzone, Lizzie Mounter, Grace Mumm, Ashley Otis\",\"A series of stories woven together by one of our most primal fears, the fear of the unknown.\",3.5\n"
+ "The Insurrection,The Insurrection,2020,Action,90,USA,English,Rene Perez,Rene Perez,,\"Michael Par¨¦, Wilma Elles, Joseph Camilleri, Rebecca Tarabocchia, Jeanine Harrington, Malorie Glavan, Danner Boyd, Michael Cendejas, Woody Clendenen, Keely Dervin, Aaron Harvey, Tony Jackson, Michael Jarrod, Angelina Karo, Bernie Kelly\",The director of the largest media company wants to expose how left-wing powers use film to control populations.,2.9\n"
+ "Valley Girl,Valley Girl,2020,\"Comedy, Musical, Romance\",102,USA,English,Rachel Lee Goldenberg,\"Amy Talkington, Andrew Lane\",Sneak Preview Productions,\"Jessica Rothe, Josh Whitehouse, Jessie Ennis, Ashleigh Murray, Chloe Bennet, Logan Paul, Mae Whitman, Mario Revolori, Rob Huebel, Judy Greer, Alex Lewis, Alex MacNicoll, Danny Ramirez, Andrew Kai, Allyn Rachel\",\"Set to a new wave '80s soundtrack, a pair of young lovers from different backgrounds defy their parents and friends to stay together. A musical adaptation of the 1983 film.\",5.4\n"
));
if (backendToTest.getAllGenres().size() == 5
&& backendToTest.getAllGenres().contains("Horror")
&& backendToTest.getAllGenres().contains("Action")
&& backendToTest.getAllGenres().contains("Comedy")
&& backendToTest.getAllGenres().contains("Musical")
&& backendToTest.getAllGenres().contains("Romance")) {
// test passed
return true;
} else {
// test failed
return false;
}
} catch (Exception e) {
e.printStackTrace();
// test failed
return false;
}
}
/**
* This test instantiates the back end with three movies and tests whether the
* initial list returned by getThreeMovies starting with the first movie (0)
* is empty. It passes when 0 is returned and fails in all other cases, including
* when an exception is thrown.
* @return true if the test passed, false if its failed
*/
public boolean testGetThreeMoviesInitial() {
try {
BackendInterface backendToTest = new Backend(new StringReader(
"title,original_title,year,genre,duration,country,language,director,writer,production_company,actors,description,avg_vote\n"
+ "The Source of Shadows,The Source of Shadows,2020,Horror,83,USA,English,\"Ryan Bury, Jennifer Bonior\",\"Jennifer Bonior, Trevor Botkin\",Four Thieves Productions,\"Ashleigh Allard, Tom Bonington, Eliane Gagnon, Marissa Kaye Grinestaff, Jenna Heffernan, Joshua Hummel, Janice Kingsley, Chris Labasbas, Jared Laufree, Dominic Lee, Vic May, Sienna Mazzone, Lizzie Mounter, Grace Mumm, Ashley Otis\",\"A series of stories woven together by one of our most primal fears, the fear of the unknown.\",3.5\n"
+ "The Insurrection,The Insurrection,2020,Action,90,USA,English,Rene Perez,Rene Perez,,\"Michael Par¨¦, Wilma Elles, Joseph Camilleri, Rebecca Tarabocchia, Jeanine Harrington, Malorie Glavan, Danner Boyd, Michael Cendejas, Woody Clendenen, Keely Dervin, Aaron Harvey, Tony Jackson, Michael Jarrod, Angelina Karo, Bernie Kelly\",The director of the largest media company wants to expose how left-wing powers use film to control populations.,2.9\n"
+ "Valley Girl,Valley Girl,2020,\"Comedy, Musical, Romance\",102,USA,English,Rachel Lee Goldenberg,\"Amy Talkington, Andrew Lane\",Sneak Preview Productions,\"Jessica Rothe, Josh Whitehouse, Jessie Ennis, Ashleigh Murray, Chloe Bennet, Logan Paul, Mae Whitman, Mario Revolori, Rob Huebel, Judy Greer, Alex Lewis, Alex MacNicoll, Danny Ramirez, Andrew Kai, Allyn Rachel\",\"Set to a new wave '80s soundtrack, a pair of young lovers from different backgrounds defy their parents and friends to stay together. A musical adaptation of the 1983 film.\",5.4\n"
));
if (backendToTest.getThreeMovies(0).size() == 0) {
// test passed
return true;
} else {
// test failed
return false;
}
} catch (Exception e) {
e.printStackTrace();
// test failed
return false;
}
}
// TODO: Back End Developer, add at least 2 more tests
public boolean testAddGenres() {
try {
// instantiate once BackendInterface is implemented
BackendInterface backendToTest = new Backend(new StringReader(
"title,original_title,year,genre,duration,country,language,director,writer,production_company,actors,description,avg_vote\n"
+ "The Source of Shadows,The Source of Shadows,2020,Horror,83,USA,English,\"Ryan Bury, Jennifer Bonior\",\"Jennifer Bonior, Trevor Botkin\",Four Thieves Productions,\"Ashleigh Allard, Tom Bonington, Eliane Gagnon, Marissa Kaye Grinestaff, Jenna Heffernan, Joshua Hummel, Janice Kingsley, Chris Labasbas, Jared Laufree, Dominic Lee, Vic May, Sienna Mazzone, Lizzie Mounter, Grace Mumm, Ashley Otis\",\"A series of stories woven together by one of our most primal fears, the fear of the unknown.\",3.5\n"
+ "The Insurrection,The Insurrection,2020,Action,90,USA,English,Rene Perez,Rene Perez,,\"Michael Par¨¦, Wilma Elles, Joseph Camilleri, Rebecca Tarabocchia, Jeanine Harrington, Malorie Glavan, Danner Boyd, Michael Cendejas, Woody Clendenen, Keely Dervin, Aaron Harvey, Tony Jackson, Michael Jarrod, Angelina Karo, Bernie Kelly\",The director of the largest media company wants to expose how left-wing powers use film to control populations.,2.9\n"
+ "Valley Girl,Valley Girl,2020,\"Comedy, Musical, Romance\",102,USA,English,Rachel Lee Goldenberg,\"Amy Talkington, Andrew Lane\",Sneak Preview Productions,\"Jessica Rothe, Josh Whitehouse, Jessie Ennis, Ashleigh Murray, Chloe Bennet, Logan Paul, Mae Whitman, Mario Revolori, Rob Huebel, Judy Greer, Alex Lewis, Alex MacNicoll, Danny Ramirez, Andrew Kai, Allyn Rachel\",\"Set to a new wave '80s soundtrack, a pair of young lovers from different backgrounds defy their parents and friends to stay together. A musical adaptation of the 1983 film.\",5.4\n"
));
backendToTest.addGenre("Horror");
if (backendToTest.getGenres().size() == 1 &&
backendToTest.getGenres().contains("Horror")) {
// test passed
return true;
} else {
// test failed
return false;
}
} catch (Exception e) {
e.printStackTrace();
// test failed
return false;
}
}
/**
* This test instantiates the back end with three movies and tests whether the
* initial list returned by getGenres is empty. It passes when 0 is returned and fails in
* all other cases, including when an exception is thrown.
* @return true if the test passed, false if its failed
*/
public boolean testGetGenresInitial() {
try {
BackendInterface backendToTest = new Backend(new StringReader(
"title,original_title,year,genre,duration,country,language,director,writer,production_company,actors,description,avg_vote\n"
+ "The Source of Shadows,The Source of Shadows,2020,Horror,83,USA,English,\"Ryan Bury, Jennifer Bonior\",\"Jennifer Bonior, Trevor Botkin\",Four Thieves Productions,\"Ashleigh Allard, Tom Bonington, Eliane Gagnon, Marissa Kaye Grinestaff, Jenna Heffernan, Joshua Hummel, Janice Kingsley, Chris Labasbas, Jared Laufree, Dominic Lee, Vic May, Sienna Mazzone, Lizzie Mounter, Grace Mumm, Ashley Otis\",\"A series of stories woven together by one of our most primal fears, the fear of the unknown.\",3.5\n"
+ "The Insurrection,The Insurrection,2020,Action,90,USA,English,Rene Perez,Rene Perez,,\"Michael Par¨¦, Wilma Elles, Joseph Camilleri, Rebecca Tarabocchia, Jeanine Harrington, Malorie Glavan, Danner Boyd, Michael Cendejas, Woody Clendenen, Keely Dervin, Aaron Harvey, Tony Jackson, Michael Jarrod, Angelina Karo, Bernie Kelly\",The director of the largest media company wants to expose how left-wing powers use film to control populations.,2.9\n"
+ "Valley Girl,Valley Girl,2020,\"Comedy, Musical, Romance\",102,USA,English,Rachel Lee Goldenberg,\"Amy Talkington, Andrew Lane\",Sneak Preview Productions,\"Jessica Rothe, Josh Whitehouse, Jessie Ennis, Ashleigh Murray, Chloe Bennet, Logan Paul, Mae Whitman, Mario Revolori, Rob Huebel, Judy Greer, Alex Lewis, Alex MacNicoll, Danny Ramirez, Andrew Kai, Allyn Rachel\",\"Set to a new wave '80s soundtrack, a pair of young lovers from different backgrounds defy their parents and friends to stay together. A musical adaptation of the 1983 film.\",5.4\n"
));
if (backendToTest.getGenres().size() == 0) {
// test passed
return true;
} else {
// test failed
return false;
}
} catch (Exception e) {
e.printStackTrace();
// test failed
return false;
}
}
}