This commit is contained in:
2026-05-07 21:27:23 +03:30
parent c9f7da2a71
commit 916c7b2a2d
2 changed files with 78 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
1. Movie: The Shawshank Redemption, Rating: 9.3, Year: 1994
2. Movie: The Godfather, Rating: 9.2, Year: 1972
3. Movie: The Dark Knight, Rating: 9.0, Year: 2008
4. Movie: 12 Angry Men, Rating: 9.0, Year: 1957
5. Movie: Schindler's List, Rating: 9.0, Year: 1993
6. Movie: The Lord of the Rings: The Return of the King, Rating: 9.0, Year: 2003
7. Movie: Pulp Fiction, Rating: 8.9, Year: 1994
8. Movie: The Lord of the Rings: The Fellowship of the Ring, Rating: 8.8, Year: 2001
9. Movie: Forrest Gump, Rating: 8.8, Year: 1994
10. Movie: Fight Club, Rating: 8.8, Year: 1999
11. Movie: Inception, Rating: 8.8, Year: 2010
12. Movie: Star Wars: Episode V - The Empire Strikes Back, Rating: 8.7, Year: 1980
13. Movie: The Matrix, Rating: 8.7, Year: 1999
14. Movie: Goodfellas, Rating: 8.7, Year: 1990
15. Movie: Interstellar, Rating: 8.6, Year: 2014
+63
View File
@@ -0,0 +1,63 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ParserTest {
public static Parser handle;
@BeforeAll
static void setUp() throws IOException {
handle = new Parser();
handle.setUp();
}
@Test
public void testSortByTitle() {
List<Movie> sortedMovies = handle.sortByTitle();
Movie m1 = new Movie("12 Angry Men", 9.0, 1957);
Movie m2 = new Movie("Forrest Gump", 8.8, 1994);
Movie m3 = new Movie("Star Wars: Episode V - The Empire Strikes Back", 8.7, 1980);
Movie m4 = new Movie("The Lord of the Rings: The Fellowship of the Ring", 8.8, 2001);
assertEquals(15, sortedMovies.size());
assertEquals(m1, sortedMovies.get(0));
assertEquals(m2, sortedMovies.get(2));
assertEquals(m3, sortedMovies.get(8));
assertEquals(m4, sortedMovies.get(11));
}
@Test
public void testSortByYear() {
List<Movie> sortedMovies = handle.sortByYear();
Movie m1 = new Movie("Interstellar", 8.6, 2014);
Movie m2 = new Movie("The Lord of the Rings: The Return of the King", 9.0, 2003);
Movie m3 = new Movie("Pulp Fiction", 8.9, 1994);
Movie m4 = new Movie("12 Angry Men", 9.0, 1957);
assertEquals(15, sortedMovies.size());
assertEquals(m1, sortedMovies.get(0));
assertEquals(m2, sortedMovies.get(3));
assertEquals(m3, sortedMovies.get(8));
assertEquals(m4, sortedMovies.get(14));
}
@Test
public void testSortByRating() {
List<Movie> sortedMovies = handle.sortByRating();
Movie m1 = new Movie("The Shawshank Redemption", 9.3, 1994);
Movie m2 = new Movie("The Dark Knight", 9.0, 2008);
Movie m3 = new Movie("Fight Club", 8.8, 1999);
Movie m4 = new Movie("Interstellar", 8.6, 2014);
assertEquals(15, sortedMovies.size());
assertEquals(m1, sortedMovies.get(0));
assertEquals(m2, sortedMovies.get(2));
assertEquals(m3, sortedMovies.get(9));
assertEquals(m4, sortedMovies.get(14));
}
}