Skip to content

spring-boot rest-api java-backend spring-data-jpa dto mysql postman junit mockito exception-handling cloud-vendor-api

Notifications You must be signed in to change notification settings

siddharth0161820/cloud-service-provider-management-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

☁️ Cloud Service Provider Management REST API

A full-stack-ready backend project demonstrating real-world Spring Boot REST API development using clean layered architecture (Controller → Service → Repository), DTOs, global exception handling, validation, and unit testing with JUnit and Mockito.

Java Spring Boot MySQL JUnit Postman


🚀 Tech Stack

  • Java 21
  • Spring Boot 3.x
  • Spring Data JPA + Hibernate
  • MySQL
  • DTO + Validation
  • Global Exception Handling
  • Unit Testing (JUnit + Mockito)
  • Postman for API testing

📁 Project Structure

Layer Link
🧾 Controller ControllerLayer.java
🧠 Service ServiceLayer
💾 Repository RepositoryLayer.java
🧱 Entity CloudVendor.java
📦 DTO UserDTO.java
⚠️ Custom Exception TestCustomExceptionHandler.java
🚨 Global Exception GlobalExceptionHandling
🧪 Unit Test TestServiceLayer.java
▶️ Main App RestapiApplication.java

✅ Features

  • Full CRUD operations for cloud vendors
  • DTO-based data transfer and request handling
  • Input validation using annotations
  • Global and custom exception handling
  • Clean layered architecture (Controller → Service → Repository)
  • JUnit + Mockito-based unit tests
  • Manual API tested with Postman

📮 API Endpoints

➕ POST /addVendors

Add a new cloud vendor

📤 Request:

{
  "name": "Ganesh Ji",
  "userName": "ganeshji@gmail.com",
  "passWord": "ganeshji"
}
✅ Success Response:
{
  "Message": "Vendor details added",
  "HttpStatus": "CREATED",
  "Object": {
    "id": 1,
    "name": "Ganesh Ji",
    "userName": "ganeshji@gmail.com",
    "passWord": "ganeshji"
  }
}
❌ Validation Error:
{
  "passWord": "The passWord is mandatory",
  "name": "Name should have at-least 2 characters",
  "userName": "must be a well-formed email address"
}
📥 GET /getAllVendors
Fetch all vendors
✅ Response:
[
  {
    "id": 1,
    "name": "Ganesh Ji",
    "userName": "ganeshji@gmail.com",
    "passWord": "ganeshji"
  },
  {
    "id": 52,
    "name": "Jai Maa Kali",
    "userName": "jaimaakali@gmail.com",
    "passWord": "jaimaakali"
  }
]
📄 GET /getSingleVendors/{id}
Fetch a vendor by ID
✅ Success (/getSingleVendors/1):
{
  "Message": "Single Vendor Details Extracted",
  "HttpStatus": "OK",
  "Object": {
    "id": 1,
    "name": "Ganesh Ji",
    "userName": "ganeshji@gmail.com",
    "passWord": "ganeshji"
  }
}
❌ Not Found (/getSingleVendors/11):
{
  "message": "Please,Enter the Valid input to extract the respective vendor details",
  "httpStatus": "NOT_FOUND"
}
🗑 DELETE /deleteVendors/{id}
Delete a vendor
✅ Success:
{
  "Message": "Single Vendor Details deleted",
  "HttpStatus": "OK",
  "Object": null
}
❌ Error:
{
  "message": "Please,Enter the Valid input to delete the respective vendor details",
  "httpStatus": "NOT_FOUND"
}
🔁 PUT /updateVendors
Update vendor details
📤 Request:
{
  "id": 1,
  "name": "Om Ganeshya Namah Ji",
  "userName": "omganeshyanamahji@gmail.com",
  "passWord": "omganeshyanamahji"
}
✅ Response:
{
  "Message": "Vendor details updated",
  "HttpStatus": "OK",
  "Object": {
    "id": 1,
    "name": "Om Ganeshya Namah Ji",
    "userName": "omganeshyanamahji@gmail.com",
    "passWord": "omganeshyanamahji"
  }
}

🧪 Unit Testing
Frameworks: JUnit 5 + Mockito

Class: TestServiceLayer.java

Scenarios:

Valid CRUD logic

Invalid ID → NotFoundException

Invalid input → Validation exception

📸 Postman API Screenshots
✅ Add Vendor
<img width="700" src="https://github.com/user-attachments/assets/61e138f6-886f-4822-b8d2-5f47e7f72756" />

❌ Validation Error
<img width="700" src="https://github.com/user-attachments/assets/30a6ab79-8ddb-4bc8-85ee-31f0dab74cfd" />

✅ Get All Vendors
<img width="700" src="https://github.com/user-attachments/assets/b2a32d3e-a26b-45c7-b8aa-5ae62f776fbb" />

🗑️ Delete Vendor
<img width="700" src="https://github.com/user-attachments/assets/e605efd8-384b-4ac3-8e60-d496f7d7b82d" />

🔄 Update Vendor
<img width="700" src="https://github.com/user-attachments/assets/b72d263a-0f37-49c9-babb-5656feacd0f6" />

🧾 Get Single Vendor
<img width="700" src="https://github.com/user-attachments/assets/ea7534e5-c694-4c7f-b20a-35e81d70d5a8" />

✅ Add Another Vendor
<img width="700" src="https://github.com/user-attachments/assets/0ec3f6fc-3d22-44c7-bcfd-c11f43c4f898" />

👨‍💻 Author

Sidharth Kumar

Email LinkedIn GitHub

🙏 Thank you for visiting this project. Feel free to connect for collaboration, job opportunities, or tech discussions.

About

spring-boot rest-api java-backend spring-data-jpa dto mysql postman junit mockito exception-handling cloud-vendor-api

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages