Skip to content

Test Kullanım Senaryosu

Senaryo 1: Başarılı Sipariş Akışı

  1. Kullanıcı oluştur:
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"username": "furkanadkt",
"email": "furkanadkt@gmail.com",
"password_hash": "furkan123",
"full_name": "Furkan Adıktı",
"address": "Ankara",
"phone_number": "1234567890",
"credit": 100
}' http://userservice.example.com/api/users

Beklenen HTTP Durum Kodu: 200

  1. Ürün oluştur:
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"name": "Ürün 1",
"description": "Örnek Ürün",
"price": 10.99,
"weight": 1.5,
"category": "Elektronik",
"image_url": "https://example.com/product1.jpg",
"tags": "test,test1"
}' http://productservice.example.com/api/products

Beklenen HTTP Durum Kodu: 200

  1. Envanter oluştur:
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"product_id": 1,
"stock_quantity": 100,
"safety_stock": 20,
"lead_time": 5
}' http://productservice.example.com/api/inventory

Beklenen HTTP Durum Kodu: 200

  1. Sipariş oluştur:
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"order": {
"user_id": 1,
"total_amount": 21.98,
"status": "Pending"
},
"order_items": [
{
"product_id": 1,
"quantity": 2,
"price": 10.99
}
]
}' http://orderservice.example.com/api/orders

Beklenen HTTP Durum Kodu: 200

  1. Ödeme yap:
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"order_id": 1,
"payment_amount": 21.98,
"payment_method": "Kredi Kartı",
"payment_date": "2024-04-10T10:00:00Z"
}' http://orderservice.example.com/api/payments

Beklenen HTTP Durum Kodu: 200

  1. Siparişin durumunu kontrol et:
Terminal window
curl -X GET http://orderservice.example.com/api/orders/1

Beklenen Yanıt:

{
"order_id": 1,
"user_id": 1,
"order_date": "2023-06-20T10:00:00Z",
"total_amount": 21.98,
"status": "Completed"
}
  1. Gönderi durumunu kontrol et:
Terminal window
curl -X GET http://dispatchservice.example.com/api/dispatches/1

Beklenen Yanıt:

{
"dispatch_id": 1,
"order_id": 1,
"dispatch_date": "2023-06-20T10:00:00Z",
"delivery_date": "2023-06-27T10:00:00Z",
"status": "Dispatched"
}

Senaryo 2: Yetersiz Kredi

  1. Kullanıcı oluştur (kredi: 10):
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"username": "janedoe",
"email": "janedoe@example.com",
"password_hash": "password456",
"full_name": "Jane Doe",
"address": "456 Elm St",
"phone_number": "9876543210",
"credit": 10
}' http://userservice.example.com/api/users

Beklenen HTTP Durum Kodu: 200

  1. Sipariş oluştur (toplam tutar: 100):
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"order": {
"user_id": 2,
"total_amount": 100,
"status": "Pending"
},
"order_items": [
{
"product_id": 1,
"quantity": 10,
"price": 10
}
]
}' http://orderservice.example.com/api/orders

Beklenen HTTP Durum Kodu: 400 Beklenen Hata Mesajı: “Insufficient credit”

Senaryo 3: Yetersiz Stok

  1. Ürünün stok miktarını güncelle (stok: 1):
Terminal window
curl -X PUT -H "Content-Type: application/json" -d '{
"product_id": 1,
"stock_quantity": 1,
"safety_stock": 20,
"lead_time": 5
}' http://productservice.example.com/api/inventory/1

Beklenen HTTP Durum Kodu: 200

  1. Sipariş oluştur (miktar: 2):
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"order": {
"user_id": 1,
"total_amount": 21.98,
"status": "Pending"
},
"order_items": [
{
"product_id": 1,
"quantity": 2,
"price": 10.99
}
]
}' http://orderservice.example.com/api/orders

Beklenen HTTP Durum Kodu: 400 Beklenen Hata Mesajı: “Insufficient stock”

Bu test senaryoları, sistemin farklı durumlarda (başarılı sipariş, yetersiz kredi, yetersiz stok) nasıl davrandığını göstermektedir. Her senaryo, ilgili endpoint’lere istekler göndererek ve yanıtları kontrol ederek adım adım ilerlemektedir.