55 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Gherkin
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Gherkin
		
	
	
	
	
	
Feature:
 | 
						|
  Frontend is able to send requests that will be processed by the application.
 | 
						|
 | 
						|
  Background:
 | 
						|
    Given there exist following clients:
 | 
						|
      | clientId                             | name   | initialBalance | currentBalance |
 | 
						|
      | 018edd2e-894a-78d7-b10c-16e05ca933a3 | Kacper | 10000          | 200000         |
 | 
						|
 | 
						|
  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
 |