-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
93 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.oopproject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.oopproject.deserializers.AuthDeserializer; | ||
import org.oopproject.deserializers.FilmDeserializer; | ||
import org.oopproject.deserializers.ListDeserializer; | ||
import org.oopproject.deserializers.PersonDeserializer; | ||
import org.oopproject.parameters.MovieParameters; | ||
import org.oopproject.parameters.ParametersBuilder; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.oopproject.utils.Config.TMDB_TOKEN; | ||
import static org.oopproject.utils.Config.tmdbService; | ||
|
||
public class RequestsCheckTest { | ||
@Test | ||
void checkAuthStatusTest() { | ||
AuthDeserializer status = tmdbService.checkAuthStatus(TMDB_TOKEN); | ||
assertEquals("true", status.success, "Expected auth status should be true"); | ||
} | ||
|
||
@Test | ||
void getMovieByIdTest() { | ||
FilmDeserializer film = tmdbService.getMovieById(TMDB_TOKEN, 725201); | ||
assertEquals("The Gray Man", film.title, "Expected movie should be 'The Gray Man'"); | ||
} | ||
|
||
@Test | ||
void getPopularMoviesTest() { | ||
ListDeserializer<FilmDeserializer> films = tmdbService.getPopularMovies(TMDB_TOKEN); | ||
assertNotNull(films.results, "Results should not be null"); | ||
assertFalse(films.results.isEmpty(), "Results should not be empty"); | ||
} | ||
|
||
@Test | ||
void getSimilarMovies() { | ||
ListDeserializer<FilmDeserializer> films = tmdbService.getSimilarMovies(TMDB_TOKEN, 725201); | ||
assertNotNull(films.results, "Results should not be null"); | ||
assertFalse(films.results.isEmpty(), "Results should not be empty"); | ||
} | ||
|
||
@Test | ||
void findMovieTest() { | ||
MovieParameters params = new ParametersBuilder() | ||
.withGenres("28") | ||
.withCertificationLte("PG-13") | ||
.withCertificationCountry("US") | ||
.build(); | ||
ListDeserializer<FilmDeserializer> films = tmdbService.findMovie(params); | ||
assertNotNull(films.results, "Results should not be null"); | ||
assertFalse(films.results.isEmpty(), "Results should not be empty"); | ||
} | ||
|
||
@Test | ||
void getRecommendationsForMovieTest() { | ||
ListDeserializer<FilmDeserializer> films = tmdbService.getRecommendationsForMovie(TMDB_TOKEN, 725201); | ||
assertNotNull(films.results, "Results should not be null"); | ||
assertFalse(films.results.isEmpty(), "Results should not be empty"); | ||
} | ||
|
||
@Test | ||
void searchMovieTest() { | ||
ListDeserializer<FilmDeserializer> films = tmdbService | ||
.searchMovie(TMDB_TOKEN, "Oppenheimer", "en-US", 1, "2023"); | ||
assertNotNull(films.results, "Results should not be null"); | ||
assertFalse(films.results.isEmpty(), "Results should not be empty"); | ||
} | ||
|
||
@Test | ||
void searchPersonTest() { | ||
ListDeserializer<PersonDeserializer> people = tmdbService | ||
.searchPerson(TMDB_TOKEN, "Ryan Gosling", "en-US", 1); | ||
assertNotNull(people.results, "Results should not be null"); | ||
assertFalse(people.results.isEmpty(), "Results should not be empty"); | ||
} | ||
} |
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,30 +1,32 @@ | ||
package org.oopproject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.oopproject.utils.Validators; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.oopproject.utils.Validators.isCommand; | ||
|
||
class ValidatorsTest { | ||
class ValidatorsTest extends Validators{ | ||
|
||
@Test | ||
void testValidCommands() { | ||
assertTrue(isCommand("/start")); | ||
assertTrue(isCommand("Start")); | ||
assertTrue(isCommand("/genre")); | ||
assertTrue(isCommand("Genre")); | ||
assertTrue(isCommand("/year")); | ||
assertTrue(isCommand("Year")); | ||
assertTrue(isCommand("/help")); | ||
assertTrue(isCommand("Help")); | ||
assertTrue(isCommand("/setage")); | ||
assertTrue(isCommand("Set Age")); | ||
for (String command : Validators.COMMANDS) { | ||
assertTrue(Validators.isCommand(command), "Command should be valid: " + command); | ||
} | ||
} | ||
|
||
@Test | ||
void testInvalidCommands() { | ||
assertFalse(isCommand("/unknown")); | ||
assertFalse(isCommand("RandomCommand")); | ||
assertFalse(isCommand(" ")); | ||
assertFalse(isCommand("setage")); | ||
String[] invalidCommands = {"/unknown", "RandomCommand", " ", "setage", "/unset", "/find"}; | ||
|
||
for (String command : invalidCommands) { | ||
assertFalse(Validators.isCommand(command), "Command should be invalid: " + command); | ||
} | ||
} | ||
|
||
@Test | ||
void testCaseInsensitiveMatching() { | ||
assertTrue(Validators.isCommand("/start".toUpperCase()), "Command should be valid: /START (case insensitive)"); | ||
assertTrue(Validators.isCommand("start".toLowerCase()), "Command should be valid: start (case insensitive)"); | ||
assertTrue(Validators.isCommand("Set Age".toUpperCase()), "Command should be valid: Set Age (case insensitive)"); | ||
} | ||
} |