This is a simple Spring Boot application that provides a User Feedback feature. It allows users to submit feedback (message and rating), and allows admins to view submitted feedback.
- Submit feedback with a message and rating.
- Admin-only endpoint to view all submitted feedback.
- Input validation for rating and message.
- JSON-based API responses.
- In-memory storage (for simplicity).
- Unit tests using JUnit and MockMvc.
Submit user feedback.
{
"userId": "user123",
"message": "Love the app!",
"rating": 5
}{
"status": "success",
"data": {
"userId": "user123",
"message": "Love the app!",
"rating": 5,
"timestamp": "2025-05-21T16:42:00"
}
}{
"status": "error",
"data": "Rating must be between 1 and 5"
}Get all submitted feedback (admin-only).
{
"x-admin": true
}{
"status": "success",
"data": [
{
"userId": "user123",
"message": "Love the app!",
"rating": 5,
"timestamp": "2025-05-21T16:42:00"
},
{
"userId": "user456",
"message": "Could be faster",
"rating": 3,
"timestamp": "2025-05-21T17:00:00"
}
]
}{
"status": "error",
"data": "Access denied: admins only"
}- Clone the repository:
git clone https://github.com/yourusername/user-feedback-api.git
cd user-feedback-api- Run the application using Maven:
./mvnw spring-boot:run- The API will be available at:
http://localhost:8080
You can test the endpoints using Postman, curl, or any HTTP client.
To execute unit tests:
./mvnw testTests cover:
- Valid and invalid feedback submission
- Admin access to feedback list
- Unauthorized access errors
- Java 17+
- Spring Boot
- Jakarta Validation
- JUnit 5
- MockMvc
- Maven