Feature: Frontend is able to send requests that will be processed by the application. Background: Given there exist following clients: | clientId | name | initialBalance | currentBalance | locked | | 018edd2e-894a-78d7-b10c-16e05ca933a3 | Kacper | 10000 | 200000 | no | | 018ede1e-a587-76a8-88f3-23987a8dade9 | Jacek | 10000 | 60000000 | yes | | 018ede4c-f5ac-7be9-9f14-7c00d2636812 | Mirek | 10000 | -10000 | no | Scenario: Frontend is able to send new orders Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "018edd2e-894a-78d7-b10c-16e05ca933a3", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 }, { "productId": "p2", "quantity": 1, "price": 100.0, "weight": 200 }, { "productId": "p3", "quantity": 5, "price": 200.0, "weight": 100 }, { "productId": "p4", "quantity": 1, "price": 50.0, "weight": 400 }, { "productId": "p5", "quantity": 10, "price": 10.0, "weight": 100 } ] } """ When I send a POST request to "/orders" Then the response status should be 200 And client with id "018edd2e-894a-78d7-b10c-16e05ca933a3" should have balance of 71000 Scenario: Frontend must send properly formatted order request Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3" } """ When I send a POST request to "/orders" Then the response status should be 422 Scenario: Frontend must send valid client reference Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "00000000-0000-0000-0000-000000000000", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 }, { "productId": "p2", "quantity": 1, "price": 100.0, "weight": 200 }, { "productId": "p3", "quantity": 5, "price": 200.0, "weight": 100 }, { "productId": "p4", "quantity": 1, "price": 50.0, "weight": 400 }, { "productId": "p5", "quantity": 10, "price": 10.0, "weight": 100 } ] } """ When I send a POST request to "/orders" Then the response status should be 422 Scenario: Locked clients should not be allowed Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "018ede1e-a587-76a8-88f3-23987a8dade9", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 }, { "productId": "p2", "quantity": 1, "price": 100.0, "weight": 200 }, { "productId": "p3", "quantity": 5, "price": 200.0, "weight": 100 }, { "productId": "p4", "quantity": 1, "price": 50.0, "weight": 400 }, { "productId": "p5", "quantity": 10, "price": 10.0, "weight": 100 } ] } """ When I send a POST request to "/orders" Then the response status should be 403 Scenario: Orders above 24 tons should not be allowed Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "018edd2e-894a-78d7-b10c-16e05ca933a3", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 }, { "productId": "p2", "quantity": 1, "price": 100.0, "weight": 200 }, { "productId": "p3", "quantity": 5, "price": 200.0, "weight": 100 }, { "productId": "p4", "quantity": 1, "price": 50.0, "weight": 400 }, { "productId": "p5", "quantity": 10, "price": 10.0, "weight": 10000 } ] } """ When I send a POST request to "/orders" Then the response status should be 400 Scenario: Clients with negative balance should not be allowed Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "018ede4c-f5ac-7be9-9f14-7c00d2636812", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 }, { "productId": "p2", "quantity": 1, "price": 100.0, "weight": 200 }, { "productId": "p3", "quantity": 5, "price": 200.0, "weight": 100 }, { "productId": "p4", "quantity": 1, "price": 50.0, "weight": 400 }, { "productId": "p5", "quantity": 10, "price": 10.0, "weight": 10000 } ] } """ When I send a POST request to "/orders" Then the response status should be 400 Scenario: Orders below 5 products should not be allowed Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "018edd2e-894a-78d7-b10c-16e05ca933a3", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 } ] } """ When I send a POST request to "/orders" Then the response status should be 400 Scenario: Invalid order should not deduce from balance Given the request has the following body: """ { "orderId": "018eddae-ff52-7813-9f88-ada9e61a76f3", "clientId": "018edd2e-894a-78d7-b10c-16e05ca933a3", "products": [ { "productId": "p1", "quantity": 2, "price": 20.0, "weight": 100 } ] } """ When I send a POST request to "/orders" Then client with id "018edd2e-894a-78d7-b10c-16e05ca933a3" should have balance of 200000