Before testing, ensure the system is running correctly.
# Check if containers are running
docker ps
# Expected Output:
# streamflix-api ... Up 0.0.0.0:8080->8080/tcp
# streamflix-db ... Up 0.0.0.0:5432->5432/tcp# Verify database is accepting connections
docker exec -it streamflix-db pg_isready -U admin -d streamflixYou can use Swagger UI or curl to test endpoints.
Swagger UI: http://localhost:8080/swagger-ui.html
-
Register:
- Endpoint:
POST /api/v1/auth/register - Body:
{ "email": "testuser@example.com", "password": "password123" } - Expected:
201 Created
- Endpoint:
-
Login:
- Endpoint:
POST /api/v1/auth/login - Body:
{ "email": "testuser@example.com", "password": "password123" } - Expected:
200 OKwith a JWTtoken.
- Endpoint:
-
Authorize:
- Copy the token.
- Click "Authorize" in Swagger.
- Enter
Bearer <your_token>.
- Create Profile:
- Endpoint:
POST /api/v1/profiles - Body:
{ "name": "Test Profile", "ageRatingId": 1 } - Expected:
201 Created
- Endpoint:
-
Get All Media:
- Endpoint:
GET /api/v1/media - Expected:
200 OKwith list of movies/series.
- Endpoint:
-
Get Specific Movie:
- Endpoint:
GET /api/v1/media/movies/1(Shawshank Redemption) - Expected:
200 OKwith details.
- Endpoint:
-
Add to Watchlist:
- Endpoint:
POST /api/v1/watchlist - Body:
{"mediaId": 1} - Expected:
200 OK
- Endpoint:
-
Start Watching:
- Endpoint:
POST /api/v1/viewing-progress/start - Body:
{"movieId": 1} - Expected:
200 OK
- Endpoint:
Use these SQL queries to verify data persistence.
-- Check if user was created
SELECT * FROM accounts WHERE email = 'testuser@example.com';
-- Check viewing progress
SELECT * FROM viewing_progress;
-- Verify trigger (Watchlist removal)
-- 1. Add item to watchlist
-- 2. Mark item as finished in viewing_progress
-- 3. Check if removed from watch_list
SELECT * FROM watch_list;Run the included JUnit tests.
# Linux/Mac
./mvnw test
# Windows
mvnw.cmd test-
Access without Token:
- Try to access
GET /api/v1/mediawithout logging in. - Expected:
401 Unauthorized.
- Try to access
-
Role Access:
- Try to access Admin endpoints (e.g.,
POST /api/v1/media/movies) as a regular user. - Expected:
403 Forbidden.
- Try to access Admin endpoints (e.g.,