Fully reactive Rental film REST API. Also see Kotlin version (in Kotlin branch).
- Enable annotation processors (in your IDE for lombok)
- Reactive Layers architecture (spring-framework reactor).
- Java non-blocking functional programming: reactor+streams.
- REST API's with Spring-WebFlux.
- Persistence with reactive MongoDb.
Notes:
- No security implementation at all.
- No persistence transaction implementation (https://spring.io/blog/2019/05/16/reactive-transactions-with-spring).
- You'll find some reactive junit tests.
- Sonar gradle plugin (you can run sonarqube gradle task if you have sonar installed on localhost:9000)
I've changed the requirement "renting for x days".
In my implementation, when renting, you are always paying for 1 day.
When you return films you pay for surcharges if applies.
Rent & Return films:
-
In both cases:
- Non-existent
userId
throws UserNotFoundException. - duplicated
filmId
's are ignored, just processing one.
- Non-existent
-
Rent films
- Non-existent
filmId
's or not available stock, are ignored and not returned in result list. - With all available films found:
- decreases stock
- calculates rent for 1 day.
- get saved in
Customer.films
(including date in each film).
- Non-existent
-
Return films
- Non-existent films in
Customer.films
are ignored and not returned in result list. - From all matching films in
Customer.films
, gets the older one (a filmId could be repeated with different rent date)- calculate surcharges (after x days).
- remove from customer & save.
- increase film stock.
- Non-existent films in
- Run App as a spring-boot app:
- command line:
gradlew :bootRun
- intellij: right button on
App.java
& Run...
- command line:
Every time app starts, customer and films are created automatically with harcoded ids for ease of use.
Also, generated json for each user+films is printed in log console, so we can copy/paste in RestApi POST bodies.
- Use
postman_collection.json
(importing the json file in Postman client):rentFilms
: to rentcustomerGet
: to see customer rented films & bonusPointsreturnFilms
: to return (after x days as path param)