From 7e5cbd68cd9c691d27b8e059b7dde1a1bbfd66ea Mon Sep 17 00:00:00 2001 From: saba_zedginidze Date: Wed, 27 Nov 2024 19:59:17 +0400 Subject: [PATCH] [MODORDERS-1210] Fix failing unit tests --- .../orders/events/handlers/ReceiptStatusConsistency.java | 6 +++--- .../java/org/folio/orders/events/utils/EventUtils.java | 6 +++--- .../folio/orders/events/handlers/HandlersTestHelper.java | 3 ++- .../events/handlers/ReceiptStatusConsistencyTest.java | 3 ++- .../pieces/flows/update/PieceUpdateFlowManagerTest.java | 8 ++++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/folio/orders/events/handlers/ReceiptStatusConsistency.java b/src/main/java/org/folio/orders/events/handlers/ReceiptStatusConsistency.java index 34e7d87a2..c992e4902 100644 --- a/src/main/java/org/folio/orders/events/handlers/ReceiptStatusConsistency.java +++ b/src/main/java/org/folio/orders/events/handlers/ReceiptStatusConsistency.java @@ -48,9 +48,9 @@ public void handle(Message message) { var requestContext = new RequestContext(ctx, okapiHeaders); var poLineId = getPoLineId(messageFromEventBus); - var future = purchaseOrderLineService.getOrderLineById(poLineId, requestContext) - .compose(poLine -> pieceStorageService.getPiecesByLineId(poLineId, requestContext) - .compose(pieces -> updatePoLineAndOrderStatuses(pieces, poLine, requestContext)) + var future = pieceStorageService.getPiecesByLineId(poLineId, requestContext) + .compose(pieces -> purchaseOrderLineService.getOrderLineById(poLineId, requestContext) + .compose(poLine -> updatePoLineAndOrderStatuses(pieces, poLine, requestContext)) .onFailure(e -> logger.error("Exception occurred while fetching PoLine by id: '{}'", poLineId, e))) .onFailure(e -> logger.error("Exception occurred while fetching pieces by PoLine id: '{}'", poLineId, e)); diff --git a/src/main/java/org/folio/orders/events/utils/EventUtils.java b/src/main/java/org/folio/orders/events/utils/EventUtils.java index 4ec3ba7c1..99dcebce6 100644 --- a/src/main/java/org/folio/orders/events/utils/EventUtils.java +++ b/src/main/java/org/folio/orders/events/utils/EventUtils.java @@ -4,14 +4,14 @@ public class EventUtils { - private static final String POL_UPDATE = "poLineIdUpdate"; + public static final String POL_UPDATE_FIELD = "poLineIdUpdate"; public static JsonObject createPoLineUpdateEvent(String poLineId) { - return JsonObject.of(POL_UPDATE, poLineId); + return JsonObject.of(POL_UPDATE_FIELD, poLineId); } public static String getPoLineId(JsonObject eventPayload) { - return eventPayload.getString(POL_UPDATE); + return eventPayload.getString(POL_UPDATE_FIELD); } private EventUtils() {} diff --git a/src/test/java/org/folio/orders/events/handlers/HandlersTestHelper.java b/src/test/java/org/folio/orders/events/handlers/HandlersTestHelper.java index 50744e2b0..d331d60ad 100644 --- a/src/test/java/org/folio/orders/events/handlers/HandlersTestHelper.java +++ b/src/test/java/org/folio/orders/events/handlers/HandlersTestHelper.java @@ -4,6 +4,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; import static org.folio.helper.BaseHelper.EVENT_PAYLOAD; +import static org.folio.orders.events.utils.EventUtils.POL_UPDATE_FIELD; import static org.folio.rest.impl.EventBusContextConfiguration.eventMessages; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -71,7 +72,7 @@ public static void verifyReceiptStatusUpdateEvent(int msgQty) { assertThat(message.headers(), not(emptyIterable())); assertThat(message.body(), notNullValue()); assertThat(message.body() - .getString("poLineIdUpdate"), not(is(emptyOrNullString()))); + .getString(POL_UPDATE_FIELD), not(is(emptyOrNullString()))); assertThat(message.body() .getString(HelperUtils.LANG), not(is(emptyOrNullString()))); } diff --git a/src/test/java/org/folio/orders/events/handlers/ReceiptStatusConsistencyTest.java b/src/test/java/org/folio/orders/events/handlers/ReceiptStatusConsistencyTest.java index 768c326fe..aa2ac5a03 100644 --- a/src/test/java/org/folio/orders/events/handlers/ReceiptStatusConsistencyTest.java +++ b/src/test/java/org/folio/orders/events/handlers/ReceiptStatusConsistencyTest.java @@ -5,6 +5,7 @@ import static org.folio.TestConfig.isVerticleNotDeployed; import static org.folio.TestUtils.checkVertxContextCompletion; import static org.folio.TestUtils.getMockAsJson; +import static org.folio.orders.events.utils.EventUtils.POL_UPDATE_FIELD; import static org.folio.rest.impl.MockServer.POLINES_COLLECTION; import static org.folio.rest.impl.MockServer.PO_LINES_MOCK_DATA_PATH; import static org.folio.rest.impl.MockServer.getPieceSearches; @@ -227,7 +228,7 @@ void testPieceReceiptStatusFailureWhenNoMatchingPoLineForPiece(VertxTestContext private JsonObject createBody(String poLineId) { JsonObject jsonObj = new JsonObject(); - jsonObj.put("poLineIdUpdate", poLineId); + jsonObj.put(POL_UPDATE_FIELD, poLineId); return jsonObj; } diff --git a/src/test/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManagerTest.java b/src/test/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManagerTest.java index 55ffd59ca..94c48bb87 100644 --- a/src/test/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManagerTest.java +++ b/src/test/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManagerTest.java @@ -331,7 +331,7 @@ void poLineStatusWhenReceiveLast() { var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update); // then - assertEquals(CompositePoLine.ReceiptStatus.FULLY_RECEIVED, receiptStatus); + assertEquals(PoLine.ReceiptStatus.FULLY_RECEIVED, receiptStatus); } @Test @@ -345,7 +345,7 @@ void poLineStatusWhenExpectLast() { var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update); // then - assertEquals(CompositePoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus); + assertEquals(PoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus); } @Test @@ -359,7 +359,7 @@ void poLineStatusWhenExpectAll() { var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update); // then - assertEquals(CompositePoLine.ReceiptStatus.AWAITING_RECEIPT, receiptStatus); + assertEquals(PoLine.ReceiptStatus.AWAITING_RECEIPT, receiptStatus); } @Test @@ -373,7 +373,7 @@ void poLineStatusWhenReceivePart() { var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update); // then - assertEquals(CompositePoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus); + assertEquals(PoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus); } private static List givenPieces(Piece.ReceivingStatus... statuses) {