0% found this document useful (0 votes)
3 views2 pages

WJava_EndModulePracticeQuestions

The document outlines the requirements for creating two Spring Boot REST applications for managing 'Grocery' and 'Flower' resources in a retail setting. Each application must support CRUD operations, utilize MySQL for data persistence, and enforce strict validation rules for input fields. Additionally, both applications should adhere to REST best practices, including proper URL conventions and HTTP response codes, while also implementing global exception handling and testing via Postman or Swagger.

Uploaded by

sumitpatait2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

WJava_EndModulePracticeQuestions

The document outlines the requirements for creating two Spring Boot REST applications for managing 'Grocery' and 'Flower' resources in a retail setting. Each application must support CRUD operations, utilize MySQL for data persistence, and enforce strict validation rules for input fields. Additionally, both applications should adhere to REST best practices, including proper URL conventions and HTTP response codes, while also implementing global exception handling and testing via Postman or Swagger.

Uploaded by

sumitpatait2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q1) Write a Spring Boot REST application which provides the following CRUD operations

for the "Grocery" resource used by a Retail Grocery Store.

Required Operations:

1. Add a new Grocery item.


2. Delete grocery items by item name.
3. Fetch all grocery items by a given category.
4. For a given purchase date, get the list of grocery item names and their quantities.
5. Search Grocery item by supplierName.

The Grocery entity has the following attributes:

1. id – Auto-generated unique identifier (starts from 1).


2. itemName – Cannot be blank. Examples: Rice, Wheat, Milk.
3. category – Enum. Examples: GRAIN, DAIRY, VEGETABLE, FRUIT.
4. quantity – Integer. Cannot be null or less than 1.
5. price – Decimal. Must be greater than 0.
6. purchaseDate – Date. Cannot be null.
7. supplierName – String. Cannot be blank.

Additional Requirements:

 Use MySQL as the relational database to persist data.


 None of the fields should be nullable in the database.
 Add proper validation for the input payload:
o itemName, supplierName – must not be blank.
o quantity – must be ≥ 1.
o price – must be > 0.
o purchaseDate – must not be null.
 Follow REST best practices:
o Use proper URL naming conventions.
o Use appropriate HTTP response codes:
 201 for resource creation.
 200 for success.
 404 for not found.
 400 for bad request.
 Handle validation and business logic errors using global exception handling.
 Call all APIs using Postman or Swagger.

Q2) Q1) Write a Spring Boot REST application which provides the following CRUD
operations for the "Flower" resource used by a Retail Flower Shop.
Required Operations:

1. Add a new Flower item.


2. Delete flower items by flower name.
3. Fetch all flower items by a given category.
4. For a given purchase date, get the list of flower item names and their quantities.
5. Search flower items by supplier name.

The Flower entity should have the following attributes:

1. id – Auto-generated unique identifier (starts from 1).


2. flowerName – Cannot be blank. Examples: Rose, Lily, Tulip.
3. category – Enum. Examples: SEASONAL, PERENNIAL, ANNUAL, BULB.
4. quantity – Integer. Cannot be null or less than 1.
5. price – Decimal. Must be greater than 0.
6. purchaseDate – Date. Cannot be null.
7. supplierName – String. Cannot be blank.

Additional Requirements:

 Use MySQL as the relational database to store flower records.


 Ensure that none of the fields are nullable in the database.
 Apply proper validation rules:
o flowerName, supplierName – must not be blank.
o quantity – must be ≥ 1.
o price – must be > 0.
o purchaseDate – must not be null.
 Follow REST best practices:
o Use meaningful and consistent URL naming (e.g., /api/flowers, /api/flowers/by-
category/{category}, etc.).
o Use appropriate HTTP status codes:
 201 – When a new resource is created.
 200 – When the request is successful.
 404 – When a resource is not found.
 400 – When the input is invalid.
 Implement global exception handling for validation and business logic errors.
 Test and demonstrate all endpoints using Postman or Swagger UI.

You might also like