Test Kullanım Senaryosu
Senaryo 1: Başarılı Sipariş Akışı
- Kullanıcı oluştur:
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/usersBeklenen HTTP Durum Kodu: 200
- Ürün oluştur:
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/productsBeklenen HTTP Durum Kodu: 200
- Envanter oluştur:
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/inventoryBeklenen HTTP Durum Kodu: 200
- Sipariş oluştur:
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/ordersBeklenen HTTP Durum Kodu: 200
- Ödeme yap:
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/paymentsBeklenen HTTP Durum Kodu: 200
- Siparişin durumunu kontrol et:
curl -X GET http://orderservice.example.com/api/orders/1Beklenen Yanıt:
{ "order_id": 1, "user_id": 1, "order_date": "2023-06-20T10:00:00Z", "total_amount": 21.98, "status": "Completed"}- Gönderi durumunu kontrol et:
curl -X GET http://dispatchservice.example.com/api/dispatches/1Beklenen 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
- Kullanıcı oluştur (kredi: 10):
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/usersBeklenen HTTP Durum Kodu: 200
- Sipariş oluştur (toplam tutar: 100):
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/ordersBeklenen HTTP Durum Kodu: 400 Beklenen Hata Mesajı: “Insufficient credit”
Senaryo 3: Yetersiz Stok
- Ürünün stok miktarını güncelle (stok: 1):
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/1Beklenen HTTP Durum Kodu: 200
- Sipariş oluştur (miktar: 2):
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/ordersBeklenen 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.