-
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.
mise à jour avec les nouveaux tests de master
- Loading branch information
Showing
17 changed files
with
172 additions
and
185 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
TMDB_JETON_ACCES=<METTRE ICI LE JETON TMDB> |
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,9 +1,25 @@ | ||
########## SPRING | ||
server.port=8080 | ||
server.servlet.session.timeout=60 | ||
########## DB | ||
spring.datasource.url=jdbc:postgresql://localhost:15432/ajavadb | ||
spring.datasource.username=admin | ||
spring.datasource.password=passwd | ||
spring.datasource.driver-class-name=org.postgresql.Driver | ||
spring.jpa.open-in-view=false | ||
spring.jpa.properties.jakarta.persistence.sharedCache.mode=NONE | ||
########## SECURITY | ||
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8090/realms/octo | ||
spring.session.timeout=60 | ||
########## SWAGGER UI | ||
########## SWAGGER | ||
springdoc.swagger-ui.docExpansion=none | ||
########## CHOIX FILM REPO | ||
springdoc.swagger-ui.oauth.clientId=octo-api | ||
springdoc.swagger-ui.oauth.clientSecret=uAUgImRefxbqHLafd4LbCU9kiQevHgUc | ||
springdoc.swagger-ui.tagsSorter=alpha | ||
########## API TMDB | ||
tmdb.baseUrl=https://api.themoviedb.org/3 | ||
# /!\ Attention ! Ne pas commit des secrets dans le git ! | ||
tmdb.token=${TMDB_JETON_ACCES} | ||
########## CHOIX FILM REPOS | ||
# valeurs possibles: IN_MEMORY ou TMDB | ||
film.source=IN_MEMORY | ||
film.source=IN_MEMORY |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.octo.ajava; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeFormatterBuilder; | ||
import java.time.format.SignStyle; | ||
import java.time.temporal.ChronoField; | ||
|
||
public class ObjectMapperBuilder { | ||
|
||
public static final DateTimeFormatter FORMATEUR_DATE = | ||
(new DateTimeFormatterBuilder()) | ||
.appendValue(ChronoField.DAY_OF_MONTH, 2) | ||
.appendLiteral('/') | ||
.appendValue(ChronoField.MONTH_OF_YEAR, 2) | ||
.appendLiteral('/') | ||
.appendValue(ChronoField.YEAR_OF_ERA, 4, 10, SignStyle.EXCEEDS_PAD) | ||
.toFormatter(); | ||
|
||
public static ObjectMapper handle() { | ||
var objectMapper = new ObjectMapper(); | ||
JavaTimeModule javaTimeModule = new JavaTimeModule(); | ||
javaTimeModule.addSerializer(new LocalDateSerializer(FORMATEUR_DATE)); | ||
objectMapper.registerModule(javaTimeModule); | ||
|
||
return objectMapper; | ||
} | ||
} |
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,56 +1,30 @@ | ||
package com.octo.ajava.fixture; | ||
|
||
import com.octo.ajava.domain.Film; | ||
import static java.util.Collections.emptyList; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public class FilmFixture { | ||
|
||
public static List<Film> uneListeDeFilms() { | ||
return List.of( | ||
new Film( | ||
1, | ||
"Pulp Fiction", | ||
"Les vies de deux hommes de main...", | ||
List.of("Policier", "Drame"), | ||
LocalDate.of(1994, 9, 23)), | ||
new Film( | ||
2, | ||
"Les Dents de la Mer", | ||
"Un shérif local, un biologiste marin et un vieux marin...", | ||
List.of("Aventure", "Thriller"), | ||
LocalDate.of(1975, 6, 20))); | ||
} | ||
|
||
public static List<Film> deuxFilmsProvenantDeTMDB() { | ||
public static List<Film> deuxFilmsPopulaires() { | ||
return List.of( | ||
new Film( | ||
297761, | ||
"Suicide Squad", | ||
"From DC Comics comes the Suicide Squad...", | ||
List.of(), | ||
LocalDate.of(2016, 8, 3)), | ||
new Film( | ||
324668, | ||
"Jason Bourne", | ||
"The most dangerous former operative of the CIA...", | ||
List.of(), | ||
LocalDate.of(2016, 7, 27))); | ||
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> deuxFilmsRecherchesProvenantDeTMDB() { | ||
return List.of( | ||
new Film( | ||
414906, | ||
"The Batman", | ||
"In his second year of fighting crime, Batman...", | ||
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...", | ||
List.of(), | ||
LocalDate.of(2005, 6, 23))); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/java/com/octo/ajava/infra/controllers/FilmControllerFTest.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.octo.ajava.infra.controllers; | ||
|
||
import com.octo.ajava.AjavaApplication; | ||
import com.octo.ajava.ObjectMapperBuilder; | ||
import com.octo.ajava.domain.Film; | ||
import io.restassured.RestAssured; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@SpringBootTest( | ||
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, | ||
classes = AjavaApplication.class | ||
) | ||
class FilmControllerFTest { | ||
|
||
@Test | ||
void recuperTousLesFilms_devrait_renvoyer_une_HTTP_200_et_une_liste_de_film() throws Exception { | ||
// Given | ||
|
||
// When | ||
var response = RestAssured.given() | ||
.get("/api/films") | ||
.then() | ||
.statusCode(HttpStatus.OK.value()) | ||
.extract().response().asString(); | ||
|
||
// Then | ||
Film[] listeDeFilms = ObjectMapperBuilder.handle().readValue(response, Film[].class); | ||
|
||
assertThat(listeDeFilms.length).isEqualTo(22); | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
src/test/java/com/octo/ajava/infra/controllers/FilmControllerITest.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
src/test/java/com/octo/ajava/infra/controllers/FilmControllerUTest.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
TMDB_JETON_ACCES=<METTRE ICI LE JETON TMDB> |
Oops, something went wrong.