Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Star Restaurant ( Spring Boot + Microservices ) 1 . 0 Introduction 1 . 0 Functional Requirements Star Restaurant is one of the leading restaurants,

Star Restaurant (Spring Boot + Microservices)
1.0 Introduction
1.0 Functional Requirements
Star Restaurant is one of the leading restaurants, that has branches all over India. It pioneered the concept of "Unlimited Food for the Customer". The Price chart is fixed for the Adults and Kids (5-9 years) under vegetarian and non-vegetarian categories. They are in need of a separate online portal that should support the below business activities.
Book a Table
Calculate Bill
Report
Statistics
The client wishes to have restful webservices for booking a table, calculating bill, viewing the booking done on a particular date, finding the star rated customer.
Help them to automate the above process by developing Rest Service using Maven and incorporate microservices for the same.
2.0 Technical Specifications
The provided RestaurantController which is a RestController, should be created with the below services:
Services:
Request Method
Post
/book
Method in Controller
bookATable
Description
T
This service should book a table for the customer by using the bookATable method of the Restaurant Servicelmpl class
Put
Request Url
/calculate/(bookingld)
calculateBill
This service calculates the bill of customer for the given Get
/viewBooking/{dateRequired)
booking Id and should return the booking information with the updated amount, by using the calculateBill method of the RestaurantServicelmpl class
view Booking OnAParticular Date
This service should retrieve the List of bookings by using the viewBooking OnAParticular Date method of the RestuarantServiceImpl class based on data required
Note:
Get
/starRated
findStarRated Customer
The date parameter obtained as String in the format "yyyy- MM-dd" should be converted to LocalDate in the RestController before invoking the service
This service should retrieve the list of mobile numbers of the customer who have done maximum bookings by using the findStarRatedCustomer method of the RestaurantServicelmpl class.
There can be more than one customer who have done maximum booking. Mobile Number should be taken as the unique value and not the customer Name.
For example, if a Customer with mobile number 7878676743 has made 10 bookings another customer with mobile number 6767676767 has made 8 bookings and another customer 9345678901 has made 12 bookings, then customer with mobile number 9345678901 is considered as star rated customer
The Controller class should have the below attribute:
IRestaurantService service;
It should be injected in the Controller via annotation.
Microservice Specification:
Spring boot application should contain all the REST services implementation as per the case study specification.
The Spring rest service application should have the application name as "restaurantapp" in the application.properties.
Register the spring rest service application with the Eureka server which should run in port 8761.
API Gateway Server:
Implement API Gateway using ZUUL proxy server
Must contain a routing information for the below URI mapping to the actual service implementation that is running in the port 9091
/book URI mapping,
/calculate URI mapping
/viewBooking/(dateRequired) URI mapping and
/starRated URI.
The API gate way server port (8777) must be specified in the "application.properties" file. The service must be accessible through API gateway using small-case url.
Do not specify absolute url of the rest service in the Gateway properties file. Rather use service-id to
The API gate way server port (8777) must be specified in the "application.properties" file.
The service must be accessible through API gateway using small-case uri.
Note:
Do not specify absolute url of the rest service in the Gateway properties file. Rather use service-id to specify the name of the application(Rest service). That is in Gateway, to specify the application name use the below property in application.properties.
zuul.routes.restaurantapp.service-id-restaurantapp
Service Layer
Refer to the IRestaurantService interface provided as part of the code skeleton. The RestaurantServicelmpl class which is provided as part of the code skeleton has to realize all the methods in the IRestaurantService interface.
RestaurantServicelmpl class should be configured via annotation as Service
RestaurantServiceImpl
Attribute Name
Booklist
Attribute Type
List
Requirements
Requirement 1
Method in Service
bookATable
Description
Exception
This method should add the booking details to the bookList and return the book Table object. Use SLF4J and log the success message as "Customer with id
The mobile number of the customer should contain exactly 10 digits and it should start with any digit from 6 to 9. If the above condition is not met then throw a user defined exception
<> booked
specify the name of the application/Best. septicel That in
Note:
Requirement 2
calculateBill
This method should iterate the booklist and calculate the total bill amount of the customer for the given booking Id based on the business rules (Please refer the Business Rules section) and set the total amount. This method should then return the booking information of the customer with the calculated total amount Use SLF4J and log the success message as "Transaction completed successfully"
Book TableInvalidException with the message "Enter a valid mobile number". Use SLF4J and log this as error message
Requirement 3
viewBooking On A Particular
quirement 3
viewBookingOnAParticularDate
This method accepts the booking date as parameter. It should iterate the bookList and
If no bookings are done in the given date, then throw Book TableInvalidException with the message "No
return the list of bookings made on the particular date.
Use SLF4J and log the success message as "View booking on a particular date is successfully done"
bookings available on the given date"
Use SLF4J and log this as error message
Requirement 4
findStarRated Customer
This method should iterate the booklist and returns the list of mobile numbers who have done maximum bookings.
Assumption there can be more than one customer who have done maximum booking. Mobile Number should be taken as the unique value and not the customer Name.
Use SLF4J and log the success message as "Find star rated customer is successful
Business Rules
The Price chart is fixed for the Adults and Kids (5-9 years) under vegetarian and non-vegetarian categories.
Business Rules
The Price chart is fixed for the Adults and Kids (5-9 years) under vegetarian and non-vegetarian categories.
Categories
Cost for each category (in Rs.)
Adult
Kids
Vegetarian
599
249
Non-
699
349
vegetarian
For example:
adultVegCount =2, kidsVegCount=0, adult NonVegCount =3, kidsNonVeg Count =1
totalCost (2599,0+0+3699.0+1349.0)(1198.0+0.0+2097.0+349.0)=3644.0
Exception Class
Refer to the Book TableException class provided as part of the code skeleton. This class should extend the Exception class. Provide the needed annotation so that it handies HttpStatus as NOT FOUND
Model class
Refer to the Book Table class provided as part of the code skeleton.
Attributes
bookingld
DataType
customerName
String
mobNumber
String
String
totalGuestCount
Integer
totalAdultVegCount
Integer
totalAdult NonVegCount
Integer
totalKids Veg Count
Integer
totalKidsNonVegCount
Integer
booking Date
LocalDate
totalBillAmount
Double
bookingDate will be in "yyyy-MM-dd" format. Set this format for Json.
Note:
Use Lombok to generate getters and setters for the attributes
Do not change the all-argument constructor and no argument constructor provided as part of the code skeleton
Do not change the datatype or the attribute name provided as part of the code skeleton
Business Validation
Inbuilt Validation
Rule
customerName should not be null
Total adult veg count should not be negative
Total adult non veg count should not be negative
Total kids veg count should not be negative
Total kids non veg count should not be negative
The date format should be yyyy-MM-dd
Message when validation fails
Provide value for customer name
Provide value greater than or equal to zero
Provide value greater than or equal to zero
Provide value greater than or equal to zero
Provide value greater than or equal to zero
Provide correct format
Perform the above Validations using annotations that are available in javax.validation.constraints package
Custom Validation
Also perform Custom validation for the totalGuestCount attribute.
Rule
Message when validation fails
A
totalGuestCount value should be equal to the sum of totalAdultVegCount and totalAdultNonVegCount and totalKidsVegCount and totalKidsNonVegCount.
Provide correct value for the totalGuestCount
booking Date must not be past date
Booking date cannot be the past date
For this you are provided with RestaurantValidator class. This class should be configured via annotation as Component.
Incorporate Exception and validations as ResponseEntity
To incorporate the messages related to Exception and validations(both custom and inbuilt validations) as
ResponseEntity, you are provided with the below classes Make use of Exception Response class that is already provided as part of the code skeleton to send the customized response error message.
CustomizedResponse EntityExceptionHandler class to handle all the exceptions that has occurred in the application(both user defined and pre defined)
Method Name
Explanation
handleAllExceptions
This method should generally handle
all the exceptions
handleNotFoundException
This method should handle and provide customized error message using Exception Response class
handleNotFoundException
handleMethodArgumentNotValid
This method should handle and provide customized error message using Exception Response class for user defined exception Book TableInvalid Exception
This method should handle and provide customized error message using Exception Response class for both pre-defined and user defined validations
Note:
In CustomizedResponse Entity ExceptionHandler class, log all the error messages usingClient invokes the required service.
Controller invokes the method of the RestaurantServicelmpl.
RestaurantServicelmpl performs the service and returns the data back.
IRestaurantService has to be injected into the RestaurantController.
RestaurantValidator has to be injected into the RestaurantController.
To perform Custom validation, you are provided with a class RestaurantValidator. Provide the necessary annotation and implement the validate method
Use appropriate annotations for performing the predefined validations.
To perform logging, you are provided with log4j.xml file. Do not change the contents of the log4j.xml file provided as part of the code skeleton
Use Lombok to create getters and setters in BookTable. Do not alter the constructors provided as part of the code skeleton.
Configure logging using Slf4j annotation with Lombok in RestaurantService and CustomizedResponse EntityExceptionHandler class.
When multiple validation fails, concatenate all messages as a single string and store it in details attribute of ExceptionResponse object.
4.0 Microservices implementation Guidelines
For Microservices implementation, we will be implementing 3 projects.
Spring Cloud (Eureka-Server) for service registry and discovery
Spring Boot for REST service creation
Spring Cloud gateway for API Gateway
Project 1:
This project should be the Eureka-Server acting as the registry. Run this server in port 8761
spring Eureka
System Status
Environment
Data center
test
default
Current time
Uptime
Lease expira
Renews thre
DS Replicas
Renews (last
Project 2:
This project should be a spring boot application containing all the REST services implemented as per the requirements stated in the case study.
These services must be registered with Eureka-Server.
+
These services must be registered with Eureka-Server.
Run the services in port 9091.Services should get automatically registered with the Eureka Registry After the service is registered
Applicationname should be given as restaurantapp as specified in the case study.
Eureka Registry should run only in port 8761
You can change application port number ie 9091 if required.
Project 3:
This must be a Spring cloud gateway project that contains the routing implementation to the actual services running in port 9091. Run this in port 8777
5.0 Overall Design Constraints
1) Do not change the property name given in the application.properties files, you can change the value and you can include additional property if needed.
2) In the pom.xml you are provided with all the dependencies needed for developing the application. Do not change or add new dependencies
3) Use the service type and the service names as expected in the specification
4) Adhere to the design specifications mentioned in the case study.
5) Do not change or delete the class/method names or return types which are provided to you as a part of the base code skeleton.
6) Developer will create 3 applications:
Spring Boot (Name of the application Should be RestaurantService)
Spring Cloud (Eureka-Server, spring-cloud-starter-eureka-server)(Name of the application Should be RestaurantRegistry)
Spring Cloud API GateWay(spring-cloud-starter-gateway)(Name of the application Should be RestaurantRouter)
7) CORS related issues need to be handled at the application level.
8) Services can be tested using external tools like postman by the associate.
9) Eureka Registry should run only in port 8761. You can change the port number of the
application (spring rest) or the Gateway (Router) if required
10) Application should be configured in the Gateway(Router) only by using service-id and not
by using absolute url. ie in Gateway properties use the below properties to configure the service
zuul.routes.restaurantapp.service-id=restaurantapp
11) To run the microservice, the order of execution of the applications are:
1. Restaurant Registry
2. RestaurantService
3. RestaurantRouter
12) Please make sure that your code does not have any compilation errors while submitting your case study solution.
PART -II INTER MICROSERVICE CONFIGURATION

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions