Skip to content

Commit

Permalink
[MODORDERS-1226]. Update validation to prevent opening an order witho…
Browse files Browse the repository at this point in the history
…ut po lines (#1652)

* [MODORDERS-1226]. Update validation to prevent opening an order without po lines

* [MODORDERS-1226]. Apply review recommendations
  • Loading branch information
BKadirkhodjaev authored Dec 27, 2024
1 parent 2c0a4d3 commit 403588b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# For MODORDERS-1226
Feature: Open Orders with PoLines

Background:
* url baseUrl
* print karate.info.scenarioName

* callonce login testAdmin
* def okapitokenAdmin = okapitoken
* callonce login testUser
* def okapitokenUser = okapitoken

* def headersUser = { 'Content-Type': 'application/json', 'x-okapi-token': '#(okapitokenUser)', 'Accept': 'application/json' }
* def headersAdmin = { 'Content-Type': 'application/json', 'x-okapi-token': '#(okapitokenAdmin)', 'Accept': 'application/json' }

* configure headers = headersUser

* callonce variables

* def fundId = call uuid
* def budgetId = call uuid

* configure headers = headersAdmin
* def v = callonce createFund { id: '#(fundId)' }
* def v = callonce createBudget { id: '#(budgetId)', fundId: '#(fundId)', allocated: 1000 }
* configure headers = headersUser

@Positive
Scenario: Open Orders with PoLines
* def orderId = call uuid

* print '1. Create composite order'
* def v = call createOrder { id: '#(orderId)' }

* print '2. Create order lines'
* table statusTable
| paymentStatus | receiptStatus |
| 'Awaiting Payment' | 'Awaiting Receipt' |
* def v = call createOrderLine statusTable

* print '3. Open the order'
* def v = call openOrder { orderId: '#(orderId)' }

@Negative
Scenario: Open Orders with PoLines - Throw Exception
* def orderId = call uuid

* print '1. Create composite order'
* def v = call createOrder { id: '#(orderId)' }

* print '2. Open the order'
Given path 'orders/composite-orders', orderId
When method GET
Then status 200

* def orderResponse = $
* set orderResponse.workflowStatus = 'Open'
* remove order.compositePoLines

Given path 'orders/composite-orders', orderId
And request orderResponse
When method PUT
Then status 422

And match each $.errors[*].code == 'compositeOrderMissingPoLines'
And match each $.errors[*].message == 'Composite order is missing poLines for Open operations'
And match $.errors[*].paremeters == []
And match $.total_records == 1

Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ Feature: mod-orders integration tests
Scenario: Update Pieces statuses in batch
Given call read("features/pieces-batch-update-status.feature")

Scenario: Open Orders with PoLines
Given call read("open-orders-with-poLines.feature")

# These 2 have to be called with OrdersApiTest - this comment is here as a reminder
# Scenario: Create pieces for an open order in parallel
# Given call read("features/parallel-create-piece.feature")
# Scenario: Update order lines for the same open orders in parallel
# Given call read("features/parallel-update-order-lines-same-order.feature")
# Scenario: Create pieces for an open order in parallel
# Given call read("features/parallel-create-piece.feature")
# Scenario: Update order lines for the same open orders in parallel
# Given call read("features/parallel-update-order-lines-same-order.feature")

Scenario: wipe data
Given call read('classpath:common/destroy-data.feature')
5 changes: 5 additions & 0 deletions acquisitions/src/test/java/org/folio/OrdersApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ void updatePiecesBatchStatus() {
runFeatureTest("pieces-batch-update-status.feature");
}

@Test
void openOrdersWithPoLines() {
runFeatureTest("open-orders-with-poLines.feature");
}

@BeforeAll
public void ordersApiTestBeforeAll() {
runFeature("classpath:thunderjet/mod-orders/orders-junit.feature");
Expand Down

0 comments on commit 403588b

Please sign in to comment.