Create an endpoint that allows users to retrieve a list of all products available in the inventory database. This feature should return the product details in a structured format.
Acceptance Criteria:
Endpoint Creation:
A GET endpoint /api/products is created.
Response Format:
The response should return a JSON array containing the details of all products, including:
id (Long)
name (String)
description (String)
price (Decimal)
quantity (Integer)
Database Interaction:
Fetch all products from the inventory database.
Use JPA/Hibernate for database interactions.
Response:
On success, return HTTP status 200 (OK) with the list of products.
If no products are found, return an empty array.
Error Handling:
Handle database errors and return appropriate responses (e.g., 500 Internal Server Error).
Tasks:
[ ] Update the ProductRepository interface to include a method for retrieving all products.
[ ] Implement the ProductService method for fetching the list of products.
[ ] Create a ProductController method to handle the GET request.
[ ] Write unit tests for service methods related to listing products.
[ ] Write integration tests for the GET API endpoint.
Description:
Create an endpoint that allows users to retrieve a list of all products available in the inventory database. This feature should return the product details in a structured format.
Acceptance Criteria:
Endpoint Creation:
/api/products
is created.Response Format:
id
(Long)name
(String)description
(String)price
(Decimal)quantity
(Integer)Database Interaction:
Response:
Error Handling:
Tasks:
ProductRepository
interface to include a method for retrieving all products.ProductService
method for fetching the list of products.ProductController
method to handle the GET request.