Application is written by using SOLID principles, DDD and also clean architecture (ports and adapters) where domain is completely separated from framework. I also used design patterns like factory and strategy for clean code purposes. There also tests to check appropriate code working: interfaces layer, domain layer and unit.
- Guests are saved in database
- Client sends request to the server on endpoint POST "room-occupancy" with body: freeEconomyRooms, freePremiumRooms
- Server calculates rooms occupancy for guests represented by prices combination with "room-occupancy" body
- Server responds with calculated values: economyUsage, economyTotalPrice, premiumUsage, premiumTotalPrice
In application.yaml:
- "bound-price" is responsible for bound price where economy rooms are finish and premium start.
- "initialize-guests" is responsible for initialization guests You can adjust them according to your needs.
In the app only MethodArgumentNotValidException is handled because client shouldn't know about any other:
- BadBoundPriceValueException.java - bound price value is set internally, part of business logic
- UnsupportedRoomOccupancyCalculatorTypeException.java - client shouldn't know about internal process in business logic
- java 17
mvn clean install
mvn spring-boot:run
mvn test