Endpoint: POST /movie
Description: Added default values and validation using Spring Boot Validation
{
"title": "The Shawshank Redemption",
"durationInMin": 142,
"language": "English",
"releaseDate": "1994-09-22"
}
- Movie creation with valid data:
- Expected status code:
200 OK
- Expected data: The created
Movie
object with the status "OK."
- Expected status code:
- Movie creation with missing optional fields:
- Expected status code:
200 OK
- Expected data: The created
Movie
object with only the fields provided (defaults for missing fields).
- Expected status code:
- Invalid data provided (e.g., missing required fields like
title
,durationInMin
, orlanguage
):- Expected status code:
400 Bad Request
- Expected data: An error message explaining which required fields are missing.
- Expected status code:
- Server-side error:
- Expected status code:
500 Internal Server Error
- Expected data: An error message like "Internal Server Error."
- Expected status code:
Endpoint: DELETE /movieId/{movieId}
Description: This endpoint allows you to delete a movie entry based on the movie's ID. Checked for a condition if movieId doesn't exist in database
movieId
: The ID of the movie to delete.
- Movie deletion with valid
movieId
:- Expected status code:
204 No Content
- Expected data: No content returned as the movie has been deleted successfully.
- Expected status code:
- Movie ID not found (trying to delete a movie that doesn't exist):
- Expected status code:
404 Not Found
- Expected data: An error message like "Movie Not Found."
- Expected status code:
- Server failure during deletion:
- Expected status code:
500 Internal Server Error
- Expected data: An error message explaining the issue.
- Expected status code:
Endpoint: PUT /movieId/{movieId}
Description: This endpoint allows you to update a movie entry based on the movie's ID. Checked for a condition if movieId doesn't exist in database
movieId
: The ID of the movie to delete.
-
Successfully updating a movie with valid changes.:
- Expected status code:
200 OK
- Expected data: The updated Movie object with the changes reflected.
- Expected status code:
-
Updating a movie with some optional fields, leaving others unchanged.:
- Expected status code:
200 OK
- Expected data: The updated Movie object, with updated fields and unchanged fields.
- Expected status code:
-
Movie ID not found (trying to update a movie that doesn't exist):
- Expected status code:
404 Not Found
- Expected data: An error message like "Movie Not Found."
- Expected status code:
-
Invalid data in the request body (e.g., invalid genre or duration).:
- Expected status code:
400 Bad Request
- Expected data: "An error message explaining which fields are invalid."
- Expected status code:
-
Server failure during deletion:
- Expected status code:
500 Internal Server Error
- Expected data: An error message explaining the issue.
- Expected status code:
Endpoint: POST /cinema
- Creating or updating a cinema with valid data.:
- Expected status code:
200 OK
- Expected data:The created/updated Cinema object.
- Expected status code:
- Invalid cinema data (missing required fields like name or location:
- Expected status code:
404 Not Found
- Expected data: An error message detailing missing or invalid fields"
- Expected status code:
- Server failure during deletion:
- Expected status code:
500 Internal Server Error
- Expected data: An error message explaining the issue.
- Expected status code:
- Valid Scenarios:
- Successfully deleting a cinema.
- Expected status code:
204 No Content
- Expected data: No content, as the cinema has been deleted successfully.
- Expected status code:
- Successfully deleting a cinema.
- Error Cases:
- Cinema ID not found.
- Expected status code:
404 Not Found
- Expected data: An error message like "Cinema not found."
- Expected status code:
- Server failure during the deletion process.
- Expected status code:
500 Internal Server Error
- Expected data: An error message explaining the failure.
- Expected status code:
- Cinema ID not found.
If any required fields are missing or invalid, the system will return a 400 Bad Request
with a detailed error message. For example:
{
"title": "Title is required and cannot be blank",
"durationInMin": "Duration must be at least 1 minute",
"language": "Language is required and cannot be blank",
"releaseDate": "Release date cannot be in the future"
}
In case of an internal server error (e.g., database issues), the system will return a 500 Internal Server Error
along with a generic error message like:
{
"message": "Internal Server Error"
}
- Spring Boot 2.x+
- Spring Data JPA (or MongoDB if applicable)
- Hibernate Validator
- Spring Web
- Java 11 or higher
- Spring Boot project set up with the required dependencies
- Database MySQL,
- Clone or download the repository.
- Import the project into your preferred IDE (e.g., IntelliJ IDEA or Eclipse).
- Configure your database settings in
application.properties
(orapplication.yml
). - Run the application using the
@SpringBootApplication
class or using the command:mvn spring-boot:run
- Test the API using Postman or a similar tool.
Feel free to fork the project and submit pull requests for any improvements or bug fixes.
master