Skip to content

Latest commit

 

History

History
402 lines (286 loc) · 8.27 KB

File metadata and controls

402 lines (286 loc) · 8.27 KB

EV Station Booking System - Postman Testing Guide

🚀 Quick Setup

Base URL: http://localhost:5067

📁 Postman Collection Structure

1. Database Management

2. EV Owner Management

3. Charging Station Management

4. Booking Management

5. User Account Management


🗃️ 1. DATABASE MANAGEMENT

Initialize Database

  • Method: POST
  • URL: {{baseUrl}}/api/Database/initialize
  • Headers: Content-Type: application/json
  • Body: {}
  • Description: Creates indexes and sample data

Get Database Schema

  • Method: GET
  • URL: {{baseUrl}}/api/Database/schema
  • Description: Returns database schema information

Get Schema JSON

  • Method: GET
  • URL: {{baseUrl}}/api/Database/schema/json
  • Description: Returns structured schema in JSON format

👥 2. EV OWNER MANAGEMENT

Get All EV Owners

  • Method: GET
  • URL: {{baseUrl}}/api/EVOwner
  • Query Params:
    • includeInactive (optional): false

Get EV Owner by NIC

  • Method: GET
  • URL: {{baseUrl}}/api/EVOwner/199512345678

Create New EV Owner

  • Method: POST
  • URL: {{baseUrl}}/api/EVOwner
  • Headers: Content-Type: application/json
  • Body:
{
  "nic": "199712345678",
  "firstName": "Alice",
  "lastName": "Cooper",
  "email": "alice.cooper@example.com",
  "phoneNumber": "+94777888999",
  "address": "456 Electric Avenue, Colombo 03",
  "dateOfBirth": "1997-06-20T00:00:00Z",
  "licenseNumber": "DL19970620",
  "vehicleDetails": [
    {
      "vehicleNumber": "EV-2023",
      "vehicleModel": "Tesla Model Y",
      "vehicleBrand": "Tesla",
      "batteryCapacity": 82.0,
      "chargingType": "Both",
      "isActive": true
    }
  ]
}

Update EV Owner

  • Method: PUT
  • URL: {{baseUrl}}/api/EVOwner/199712345678
  • Headers: Content-Type: application/json
  • Body:
{
  "firstName": "Alice Updated",
  "lastName": "Cooper Updated",
  "email": "alice.updated@example.com",
  "phoneNumber": "+94777999888",
  "address": "789 Updated Street, Colombo 05",
  "dateOfBirth": "1997-06-20T00:00:00Z",
  "licenseNumber": "DL19970621",
  "vehicleDetails": [
    {
      "vehicleNumber": "EV-2024",
      "vehicleModel": "Tesla Model S",
      "vehicleBrand": "Tesla",
      "batteryCapacity": 100.0,
      "chargingType": "Both",
      "isActive": true
    }
  ]
}

Deactivate EV Owner

  • Method: PATCH
  • URL: {{baseUrl}}/api/EVOwner/199712345678/deactivate

Activate EV Owner

  • Method: PATCH
  • URL: {{baseUrl}}/api/EVOwner/199712345678/activate

Delete EV Owner

  • Method: DELETE
  • URL: {{baseUrl}}/api/EVOwner/199712345678

Get EV Owner by Email

  • Method: GET
  • URL: {{baseUrl}}/api/EVOwner/email/alice.cooper@example.com

3. CHARGING STATION MANAGEMENT

Get All Charging Stations

  • Method: GET
  • URL: {{baseUrl}}/api/ChargingStations

Get Charging Station by ID

  • Method: GET
  • URL: {{baseUrl}}/api/ChargingStations/{{stationId}}

Create Charging Station

  • Method: POST
  • URL: {{baseUrl}}/api/ChargingStations
  • Headers: Content-Type: application/json
  • Body:
{
  "name": "Postman Test Station",
  "location": "Postman City",
  "type": "DC",
  "availableSlots": 10,
  "isActive": true
}

Update Charging Station

  • Method: PUT
  • URL: {{baseUrl}}/api/ChargingStations/{{stationId}}
  • Headers: Content-Type: application/json
  • Body:
{
  "id": "{{stationId}}",
  "name": "Updated Test Station",
  "location": "Updated Location",
  "type": "AC",
  "availableSlots": 15,
  "isActive": true
}

Deactivate Charging Station

  • Method: PATCH
  • URL: {{baseUrl}}/api/ChargingStations/{{stationId}}/deactivate

📅 4. BOOKING MANAGEMENT

Create Booking

  • Method: POST
  • URL: {{baseUrl}}/api/Booking
  • Headers: Content-Type: application/json
  • Body:
{
  "userId": "507f1f77bcf86cd799439011",
  "stationId": "507f1f77bcf86cd799439012",
  "reservationDateTime": "2025-09-27T14:30:00Z"
}

Get Booking by ID

  • Method: GET
  • URL: {{baseUrl}}/api/Booking/{{bookingId}}

Get User's Bookings

  • Method: GET
  • URL: {{baseUrl}}/api/Booking/user/507f1f77bcf86cd799439011

Update Booking

  • Method: PUT
  • URL: {{baseUrl}}/api/Booking/{{bookingId}}
  • Headers: Content-Type: application/json
  • Body:
{
  "reservationDateTime": "2025-09-28T15:30:00Z"
}

Confirm Booking

  • Method: PATCH
  • URL: {{baseUrl}}/api/Booking/{{bookingId}}/confirm

Cancel Booking

  • Method: PATCH
  • URL: {{baseUrl}}/api/Booking/{{bookingId}}/cancel

👤 5. USER ACCOUNT MANAGEMENT

Register User

  • Method: POST
  • URL: {{baseUrl}}/api/UserAccount/register
  • Headers: Content-Type: application/json
  • Body:
{
  "name": "Test User",
  "email": "testuser@example.com",
  "password": "TestPassword123!",
  "role": "StationOperator"
}

Login User

  • Method: POST
  • URL: {{baseUrl}}/api/UserAccount/login
  • Headers: Content-Type: application/json
  • Body:
{
  "email": "testuser@example.com",
  "password": "TestPassword123!"
}

Get All Users (Requires Auth)

  • Method: GET
  • URL: {{baseUrl}}/api/UserAccount
  • Headers: Authorization: Bearer {{token}}

⚙️ POSTMAN ENVIRONMENT SETUP

Create a new environment in Postman with these variables:

Variable Name Value
baseUrl http://localhost:5067
token {{jwt_token_from_login}}
evOwnerNIC 199712345678
stationId {{station_id_from_create}}
bookingId {{booking_id_from_create}}

🧪 TESTING WORKFLOW

Step 1: Database Setup

  1. Initialize Database - Run POST /api/Database/initialize
  2. Verify Schema - Run GET /api/Database/schema

Step 2: EV Owner Testing

  1. Create EV Owner - Run POST /api/EVOwner
  2. Get All Owners - Run GET /api/EVOwner
  3. Get Owner by NIC - Run GET /api/EVOwner/{nic}
  4. Update Owner - Run PUT /api/EVOwner/{nic}
  5. Test Activation - Run PATCH /api/EVOwner/{nic}/deactivate then /activate

Step 3: Charging Station Testing

  1. Create Station - Run POST /api/ChargingStations
  2. Get All Stations - Run GET /api/ChargingStations
  3. Update Station - Run PUT /api/ChargingStations/{id}

Step 4: Booking Testing

  1. Create User - Run POST /api/UserAccount/register
  2. Create Booking - Run POST /api/Booking
  3. Test Booking Flow - Confirm, Update, Cancel bookings

📝 TEST SCENARIOS

Positive Tests

  • ✅ Create EV Owner with valid data
  • ✅ Update existing EV Owner
  • ✅ Activate/Deactivate accounts
  • ✅ Create bookings with future dates
  • ✅ Confirm and cancel bookings

Negative Tests

  • ❌ Create EV Owner with duplicate NIC
  • ❌ Create EV Owner with invalid email
  • ❌ Create booking with past date
  • ❌ Update booking less than 12 hours before
  • ❌ Create booking more than 7 days in future

Edge Cases

  • 🔍 Create EV Owner with no vehicle details
  • 🔍 Update EV Owner with same email as another owner
  • 🔍 Create booking exactly 12 hours before reservation
  • 🔍 Test NIC validation with old/new formats

🔧 COMMON HEADERS

For all requests, include:

Content-Type: application/json
Accept: application/json

For authenticated requests, add:

Authorization: Bearer YOUR_JWT_TOKEN

🎯 SUCCESS CRITERIA

  • All endpoints return appropriate HTTP status codes
  • Response bodies contain expected data structures
  • Error messages are descriptive and helpful
  • Business rules are properly enforced
  • Database constraints work correctly

🚨 TROUBLESHOOTING

Common Issues:

  1. 404 Not Found - Check URL spelling and method
  2. 400 Bad Request - Verify JSON body format
  3. 409 Conflict - Check for duplicate NIC/email
  4. 500 Internal Error - Check server logs

Server Status:

Ensure your application is running on http://localhost:5067

dotnet run

Happy Testing! 🚀