-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatage tp-2 et correction des diffs non significatifs entre énoncé
et solution
- Loading branch information
Pierre-Yves Fourmond
committed
Oct 26, 2023
1 parent
9752981
commit 06801c3
Showing
13 changed files
with
157 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 17 additions & 11 deletions
28
src/main/java/com/octo/ajava/infra/mapper/TMDBFilmMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
package com.octo.ajava.infra.mapper; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
import com.octo.ajava.domain.Film; | ||
import com.octo.ajava.infra.api_client.entities.PaginatedTMDBMovies; | ||
import java.util.Collections; | ||
import com.octo.ajava.infra.api_client.entities.TMDBMovie; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static java.util.Collections.emptyList; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TMDBFilmMapper { | ||
|
||
public List<Film> convertirEnFilms(PaginatedTMDBMovies paginatedTMDBMovies) { | ||
var movies = paginatedTMDBMovies.getMovies(); | ||
List<TMDBMovie> movies = paginatedTMDBMovies.getMovies(); | ||
|
||
if (movies == null) { | ||
return emptyList(); | ||
} | ||
|
||
return movies.stream().map(tmdbMovie -> new Film( | ||
tmdbMovie.getId(), | ||
tmdbMovie.getTitle(), | ||
tmdbMovie.getOverview(), | ||
emptyList(), | ||
tmdbMovie.getReleaseDate() | ||
)).toList(); | ||
List<Film> list = new ArrayList<>(); | ||
for (TMDBMovie movie : movies) { | ||
Film film = | ||
new Film( | ||
movie.getId(), | ||
movie.getTitle(), | ||
movie.getOverview(), | ||
emptyList(), | ||
movie.getReleaseDate()); | ||
list.add(film); | ||
} | ||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
package com.octo.ajava.fixture; | ||
|
||
import com.octo.ajava.domain.Film; | ||
import static java.util.Collections.emptyList; | ||
|
||
import com.octo.ajava.domain.Film; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public class FilmFixture { | ||
|
||
public static List<Film> deuxFilmsPopulaires() { | ||
return List.of( | ||
new Film( | ||
502356, | ||
"The Super Mario Bros. Movie", | ||
"While working underground to fix a water main, Brooklyn plumbers—and brothers—Mario and Luigi are transported down a mysterious pipe and wander into a magical new world. But when the brothers are separated, Mario embarks on an epic quest to find Luigi.", | ||
emptyList(), | ||
LocalDate.of(2023, 4, 5) | ||
), | ||
new Film( | ||
76600, | ||
"Avatar: The Way of Water", | ||
"Set more than a decade after the events of the first film, learn the story of the Sully family (Jake, Neytiri, and their kids), the trouble that follows them, the lengths they go to keep each other safe, the battles they fight to stay alive, and the tragedies they endure.", | ||
emptyList(), | ||
LocalDate.of(2022, 12, 14) | ||
) | ||
); | ||
new Film( | ||
502356, | ||
"The Super Mario Bros. Movie", | ||
"While working underground to fix a water main, Brooklyn plumbers—and brothers—Mario and Luigi are transported down a mysterious pipe and wander into a magical new world. But when the brothers are separated, Mario embarks on an epic quest to find Luigi.", | ||
emptyList(), | ||
LocalDate.of(2023, 4, 5)), | ||
new Film( | ||
76600, | ||
"Avatar: The Way of Water", | ||
"Set more than a decade after the events of the first film, learn the story of the Sully family (Jake, Neytiri, and their kids), the trouble that follows them, the lengths they go to keep each other safe, the battles they fight to stay alive, and the tragedies they endure.", | ||
emptyList(), | ||
LocalDate.of(2022, 12, 14))); | ||
} | ||
|
||
public static List<Film> deuxFilmsRecherches() { | ||
return List.of( | ||
new Film( | ||
414906, | ||
"The Batman", | ||
"In his second year of fighting crime, Batman uncovers corruption in Gotham City that connects to his own family while facing a serial killer known as the Riddler.", | ||
List.of(), | ||
LocalDate.of(2022, 3, 1)), | ||
new Film( | ||
272, | ||
"Batman Begins", | ||
"Driven by tragedy, billionaire Bruce Wayne dedicates his life to uncovering and defeating the corruption that plagues his home, Gotham City. Unable to work within the system, he instead creates a new identity, a symbol of fear for the criminal underworld - The Batman.", | ||
List.of(), | ||
LocalDate.of(2005, 6, 10))); | ||
new Film( | ||
414906, | ||
"The Batman", | ||
"In his second year of fighting crime, Batman uncovers corruption in Gotham City that connects to his own family while facing a serial killer known as the Riddler.", | ||
List.of(), | ||
LocalDate.of(2022, 3, 1)), | ||
new Film( | ||
272, | ||
"Batman Begins", | ||
"Driven by tragedy, billionaire Bruce Wayne dedicates his life to uncovering and defeating the corruption that plagues his home, Gotham City. Unable to work within the system, he instead creates a new identity, a symbol of fear for the criminal underworld - The Batman.", | ||
List.of(), | ||
LocalDate.of(2005, 6, 10))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 42 additions & 49 deletions
91
src/test/java/com/octo/ajava/fixture/TMDBMovieFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,52 @@ | ||
package com.octo.ajava.fixture; | ||
|
||
import com.octo.ajava.infra.api_client.entities.TMDBMovie; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public class TMDBMovieFixture { | ||
|
||
public static List<TMDBMovie> deuxFilmsPopulairesVenantDeTMTB() { | ||
return List.of( | ||
new TMDBMovie( | ||
502356, | ||
"The Super Mario Bros. Movie", | ||
"en", | ||
"The Super Mario Bros. Movie", | ||
"While working underground to fix a water main, Brooklyn plumbers—and brothers—Mario and Luigi are transported down a mysterious pipe and wander into a magical new world. But when the brothers are separated, Mario embarks on an epic quest to find Luigi.", | ||
LocalDate.of(2023, 4, 5), | ||
8501, | ||
8 | ||
), | ||
new TMDBMovie( | ||
76600, | ||
"Avatar: The Way of Water", | ||
"en", | ||
"Avatar: The Way of Water", | ||
"Set more than a decade after the events of the first film, learn the story of the Sully family (Jake, Neytiri, and their kids), the trouble that follows them, the lengths they go to keep each other safe, the battles they fight to stay alive, and the tragedies they endure.", | ||
LocalDate.of(2022, 12, 14), | ||
1453, | ||
8 | ||
) | ||
); | ||
} | ||
public static List<TMDBMovie> deuxFilmsPopulairesVenantDeTMTB() { | ||
return List.of( | ||
new TMDBMovie( | ||
502356, | ||
"The Super Mario Bros. Movie", | ||
"en", | ||
"The Super Mario Bros. Movie", | ||
"While working underground to fix a water main, Brooklyn plumbers—and brothers—Mario and Luigi are transported down a mysterious pipe and wander into a magical new world. But when the brothers are separated, Mario embarks on an epic quest to find Luigi.", | ||
LocalDate.of(2023, 4, 5), | ||
8501, | ||
8), | ||
new TMDBMovie( | ||
76600, | ||
"Avatar: The Way of Water", | ||
"en", | ||
"Avatar: The Way of Water", | ||
"Set more than a decade after the events of the first film, learn the story of the Sully family (Jake, Neytiri, and their kids), the trouble that follows them, the lengths they go to keep each other safe, the battles they fight to stay alive, and the tragedies they endure.", | ||
LocalDate.of(2022, 12, 14), | ||
1453, | ||
8)); | ||
} | ||
|
||
public static List<TMDBMovie> deuxFilmsRecherchesVenantDeTMTB() { | ||
return List.of( | ||
new TMDBMovie( | ||
414906, | ||
"The Batman", | ||
"en", | ||
"The Batman", | ||
"In his second year of fighting crime, Batman uncovers corruption in Gotham City that connects to his own family while facing a serial killer known as the Riddler.", | ||
LocalDate.of(2022, 3, 1), | ||
153, | ||
8 | ||
), | ||
new TMDBMovie( | ||
272, | ||
"Batman Begins", | ||
"en", | ||
"Batman Begins", | ||
"Driven by tragedy, billionaire Bruce Wayne dedicates his life to uncovering and defeating the corruption that plagues his home, Gotham City. Unable to work within the system, he instead creates a new identity, a symbol of fear for the criminal underworld - The Batman.", | ||
LocalDate.of(2005, 6, 10), | ||
42, | ||
8 | ||
) | ||
); | ||
} | ||
public static List<TMDBMovie> deuxFilmsRecherchesVenantDeTMTB() { | ||
return List.of( | ||
new TMDBMovie( | ||
414906, | ||
"The Batman", | ||
"en", | ||
"The Batman", | ||
"In his second year of fighting crime, Batman uncovers corruption in Gotham City that connects to his own family while facing a serial killer known as the Riddler.", | ||
LocalDate.of(2022, 3, 1), | ||
153, | ||
8), | ||
new TMDBMovie( | ||
272, | ||
"Batman Begins", | ||
"en", | ||
"Batman Begins", | ||
"Driven by tragedy, billionaire Bruce Wayne dedicates his life to uncovering and defeating the corruption that plagues his home, Gotham City. Unable to work within the system, he instead creates a new identity, a symbol of fear for the criminal underworld - The Batman.", | ||
LocalDate.of(2005, 6, 10), | ||
42, | ||
8)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.