From 92a68458150eab2350d28ad0318b35174e4efbeb Mon Sep 17 00:00:00 2001 From: Saba-Zedginidze-EPAM <148070844+Saba-Zedginidze-EPAM@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:41:04 +0400 Subject: [PATCH] [MODORDERS-1166] Add bindItemTenantId to Piece schema (#1003) * [MODORDERS-1166] Add bindItemTenantId to Piece schema * [MODORDERS-1166] Update acq-models pointer * [MODORDERS-1166] Update acq-models pointer --- ramls/acq-models | 2 +- .../java/org/folio/helper/BindHelper.java | 7 ++++--- .../rest/impl/CheckinReceivingApiTest.java | 20 ++++++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ramls/acq-models b/ramls/acq-models index 25083ed83..f28215d2e 160000 --- a/ramls/acq-models +++ b/ramls/acq-models @@ -1 +1 @@ -Subproject commit 25083ed834962a4b9423b33b4b307f86a2e4918b +Subproject commit f28215d2ee2b2582f96f65b91c388f4ac7395f46 diff --git a/src/main/java/org/folio/helper/BindHelper.java b/src/main/java/org/folio/helper/BindHelper.java index 0f3ade1a8..225a5bfa7 100644 --- a/src/main/java/org/folio/helper/BindHelper.java +++ b/src/main/java/org/folio/helper/BindHelper.java @@ -76,7 +76,7 @@ public Future removeBinding(String pieceId, RequestContext requestContext) return pieceStorageService.getPieceById(pieceId, requestContext) .compose(piece -> { var bindItemId = piece.getBindItemId(); - piece.withBindItemId(null).withIsBound(false); + piece.withBindItemId(null).withBindItemTenantId(null).withIsBound(false); return removeForbiddenEntities(piece, requestContext) .map(v -> Collections.>singletonMap(null, List.of(piece))) .compose(piecesGroupedByPoLine -> storeUpdatedPieceRecords(piecesGroupedByPoLine, requestContext)) @@ -220,10 +220,11 @@ private Future updateItemStatus(BindPiecesHolder holder, Reque private Future createItemForPieces(BindPiecesHolder holder, RequestContext requestContext) { var bindPiecesCollection = holder.getBindPiecesCollection(); var poLineId = holder.getPoLineId(); + var bindItem = bindPiecesCollection.getBindItem(); logger.debug("createItemForPiece:: Trying to get poLine by id '{}'", poLineId); return purchaseOrderLineService.getOrderLineById(poLineId, requestContext) .map(PoLineCommonUtil::convertToCompositePoLine) - .compose(compPOL -> createInventoryObjects(compPOL, bindPiecesCollection.getInstanceId(), bindPiecesCollection.getBindItem(), requestContext)) + .compose(compPOL -> createInventoryObjects(compPOL, bindPiecesCollection.getInstanceId(), bindItem, requestContext)) .map(newItemId -> { // Move requests if requestsAction is TRANSFER, otherwise do nothing if (TRANSFER.equals(bindPiecesCollection.getRequestsAction())) { @@ -231,7 +232,7 @@ private Future createItemForPieces(BindPiecesHolder holder, Re inventoryItemRequestService.transferItemRequests(itemIds, newItemId, requestContext); } // Set new item ids for pieces and holder - holder.getPieces().forEach(piece -> piece.setBindItemId(newItemId)); + holder.getPieces().forEach(piece -> piece.withBindItemTenantId(bindItem.getTenantId()).setBindItemId(newItemId)); return holder.withBindItemId(newItemId); }); } diff --git a/src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java b/src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java index ba216d0e6..18c15f1fe 100644 --- a/src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java +++ b/src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java @@ -1221,6 +1221,7 @@ void testBindPiecesToTitleWithItem() { var holdingId = "849241fa-4a14-4df5-b951-846dcd6cfc4d"; var receivingStatus = Piece.ReceivingStatus.UNRECEIVABLE; var format = Piece.Format.ELECTRONIC; + var tenantId = "tenantId"; var order = getMinimalContentCompositePurchaseOrder() .withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN); @@ -1249,7 +1250,8 @@ void testBindPiecesToTitleWithItem() { .withPoLineId(poLine.getId()) .withBindItem(getMinimalContentBindItem() .withLocationId(null) - .withHoldingId(holdingId)) + .withHoldingId(holdingId) + .withTenantId(tenantId)) .withBindPieceIds(pieceIds); var response = verifyPostResponse(ORDERS_BIND_ENDPOINT, JsonObject.mapFrom(bindPiecesCollection).encode(), @@ -1269,6 +1271,7 @@ void testBindPiecesToTitleWithItem() { .map(json -> json.mapTo(Piece.class)) .filter(piece -> pieceIds.contains(piece.getId())) .filter(piece -> piece.getBindItemId().equals(newItemId)) + .filter(piece -> piece.getBindItemTenantId().equals(tenantId)) .toList(); assertThat(pieceList.size(), is(2)); @@ -1306,6 +1309,8 @@ void testBindPiecesWithLocationIdOnly() { var receivingStatus = Piece.ReceivingStatus.UNRECEIVABLE; var format = Piece.Format.ELECTRONIC; + var tenantId = "tenantId"; + var order = getMinimalContentCompositePurchaseOrder() .withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN); var poLine = getMinimalContentCompositePoLine(order.getId()); @@ -1324,7 +1329,8 @@ void testBindPiecesWithLocationIdOnly() { var bindPiecesCollection = new BindPiecesCollection() .withPoLineId(poLine.getId()) .withBindItem(getMinimalContentBindItem() - .withLocationId(locationId)) + .withLocationId(locationId) + .withTenantId(tenantId)) .withBindPieceIds(pieceIds); var response = verifyPostResponse(ORDERS_BIND_ENDPOINT, JsonObject.mapFrom(bindPiecesCollection).encode(), @@ -1342,7 +1348,8 @@ void testBindPiecesWithLocationIdOnly() { var pieceList = pieceUpdates.stream().filter(pol -> { Piece piece = pol.mapTo(Piece.class); String pieceId = piece.getId(); - return Objects.equals(bindingPiece.getId(), pieceId); + return Objects.equals(bindingPiece.getId(), pieceId) + && Objects.equals(piece.getBindItemTenantId(), tenantId); }).toList(); assertThat(pieceList.size(), is(1)); @@ -1504,6 +1511,7 @@ void testRemovePieceBinding() { logger.info("=== Test DELETE Remove binding"); var holdingId = "849241fa-4a14-4df5-b951-846dcd6cfc4d"; + var tenantId = "tenantId"; var order = getMinimalContentCompositePurchaseOrder() .withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN); var poLine = getMinimalContentCompositePoLine(order.getId()); @@ -1531,7 +1539,8 @@ void testRemovePieceBinding() { .withPoLineId(poLine.getId()) .withBindItem(getMinimalContentBindItem() .withLocationId(null) - .withHoldingId(holdingId)) + .withHoldingId(holdingId) + .withTenantId(tenantId)) .withBindPieceIds(bindPieceIds); var bindResponse = verifyPostResponse(ORDERS_BIND_ENDPOINT, JsonObject.mapFrom(bindPiecesCollection).encode(), @@ -1543,7 +1552,6 @@ void testRemovePieceBinding() { assertThat(bindResponse.getBoundPieceIds(), is(bindPieceIds)); assertThat(bindResponse.getItemId(), notNullValue()); - var bindItemId = bindResponse.getItemId(); var url = String.format(ORDERS_BIND_ID_ENDPOINT, bindPiece1.getId()); verifyDeleteResponse(url, "", HttpStatus.HTTP_NO_CONTENT.toInt()); @@ -1561,10 +1569,12 @@ void testRemovePieceBinding() { var pieceBefore = pieceList.get(1); assertThat(pieceBefore.getIsBound(), is(true)); assertThat(pieceBefore.getBindItemId(), notNullValue()); + assertThat(pieceBefore.getBindItemTenantId(), notNullValue()); var pieceAfter = pieceList.get(0); assertThat(pieceAfter.getIsBound(), is(false)); assertThat(pieceAfter.getBindItemId(), nullValue()); + assertThat(pieceAfter.getReceivingTenantId(), nullValue()); } @Test