Basic REST API using Java Spring Boot.
- This API supports Movie catalog and movie Rental.
- It is a Tomcat embedded app.
- Support JSON media content.
- Uses MySQL for saving data.
- Uses JPA for persistence operations
Verb |
URI Pattern |
Return |
GET |
/api/movies |
Array |
Verb |
URI Pattern |
Return |
POST |
/api/movie |
String |
{
"title": "abcdefhijklmnopqrstuvwxyzabcdefhijklmnopqrstuvwxyzabcdefhijklmnopqrstuvwxyz",
"description": "BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah",
"year": "2020-05-05",
"rate": "PG",
"registeringUser": "Erika",
"actors": [
101,
102,
103,
104
]
}
Verb |
URI Pattern |
Return |
POST |
/api/member |
String |
{
"username": "[email protected]",
"name": "abcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijklmnabcdefhijk",
"telephone": "1234567890"
}
Verb |
URI Pattern |
Return |
POST |
/api/catalog-entry |
String |
{
"movie": 108,
"price": 105,
"numberofCopies": 7
}
Verb |
URI Pattern |
Return |
POST |
/api/rental |
String |
{
"memberId": 101,
"movieId": 101,
"date": "2020-05-01"
}
Verb |
URI Pattern |
Return |
PATCH |
/api/rental/:id |
String |
There are JUnit unit tests for services and controllers on src/test
.
There is a SQL migration file with valid data on src/main/resources/data.sql
.
The most important changed files are:
- Controllers:
src/main/java/com/juan/movies/controller
- All REST controllers for each model and exception handler
- Models:
src/main/java/com/juan/movies/model
- All entity models to be mapped using JPA
- Repositories:
src/main/java/com/juan/movies/repository
- All models' repositories interfaces
- Services:
src/main/java/com/juan/movies/service
- Services and implementations for each model
- Utils:
src/main/java/com/juan/movies/utils
- Utilities like date updater
- Tests:
src/test
- JUnit tests for controllers and services.
- Generate unit test for models.
- Exception handling for
SQLIntegrityConstraintViolationException
.
- Can't use Mockito on services. It did not worked.
MIT