-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MODORDER-1087]-Delete received pieces in bulk #952
Open
yuntianhu
wants to merge
10
commits into
master
Choose a base branch
from
MODORDERS-1087-3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
55b0a7a
[MODORDER-1087] add batch delete
yuntianhu 6db3963
Merge branch 'master' into MODORDERS-1087-3
yuntianhu 8771a90
[MODORDER-1087] change the piecesCollection to list. Raml file modifc…
yuntianhu 3ab692c
Merge remote-tracking branch 'origin/MODORDERS-1087-3' into MODORDERS…
yuntianhu ad25b1a
Merge branch 'master' into MODORDERS-1087-3
yuntianhu 0bf580a
[MODORDER-1087] change the piecesCollection to list. Raml file modifc…
yuntianhu 7981d47
Merge remote-tracking branch 'origin/MODORDERS-1087-3' into MODORDERS…
yuntianhu b4a0f4d
[MODORDER-1087] update the batch delete PiecesApiTest
yuntianhu 5ced63d
Merge branch 'master' into MODORDERS-1087-3
yuntianhu 03aa3cc
Merge branch 'master' into MODORDERS-1087-3
yuntianhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.folio.service.pieces.flows.delete; | ||
|
||
import static io.vertx.core.Future.*; | ||
import static io.vertx.core.Future.succeededFuture; | ||
import static org.folio.TestConfig.autowireDependencies; | ||
import static org.folio.TestConfig.clearServiceInteractions; | ||
|
@@ -42,6 +43,7 @@ | |
import org.folio.rest.jaxrs.model.Eresource; | ||
import org.folio.rest.jaxrs.model.Location; | ||
import org.folio.rest.jaxrs.model.Piece; | ||
import org.folio.rest.jaxrs.model.PieceCollection; | ||
import org.folio.rest.jaxrs.model.PoLine; | ||
import org.folio.rest.jaxrs.model.PurchaseOrder; | ||
import org.folio.rest.jaxrs.model.Title; | ||
|
@@ -368,6 +370,67 @@ void shouldUpdateLineQuantityIfPoLineIsNotPackageAndManualPieceCreateFalseAndInv | |
verify(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(holder, requestContext); | ||
} | ||
|
||
@Test | ||
void shouldDeletePiecesInBatch() { | ||
String orderId = UUID.randomUUID().toString(); | ||
String holdingId = UUID.randomUUID().toString(); | ||
String lineId = UUID.randomUUID().toString(); | ||
String itemId = UUID.randomUUID().toString(); | ||
String locationId = UUID.randomUUID().toString(); | ||
String titleId = UUID.randomUUID().toString(); | ||
JsonObject holding = new JsonObject(); | ||
holding.put(ID, holdingId); | ||
holding.put(HOLDING_PERMANENT_LOCATION_ID, locationId); | ||
JsonObject item = new JsonObject().put(ID, itemId); | ||
item.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, ItemStatus.ON_ORDER.value())); | ||
Piece piece = new Piece().withId(UUID.randomUUID().toString()).withPoLineId(lineId) | ||
.withHoldingId(holdingId).withFormat(Piece.Format.ELECTRONIC); | ||
Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1); | ||
Cost cost = new Cost().withQuantityElectronic(1) | ||
.withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD") | ||
.withPoLineEstimatedPrice(1d); | ||
PoLine poLine = new PoLine().withIsPackage(false).withCheckinItems(false).withOrderFormat(PoLine.OrderFormat.ELECTRONIC_RESOURCE) | ||
.withEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE_HOLDING)) | ||
.withPurchaseOrderId(orderId).withId(lineId).withLocations(List.of(loc)).withCost(cost); | ||
PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN); | ||
Title title = new Title().withId(titleId); | ||
List<Piece> pieces = new ArrayList<>(); | ||
pieces.add(piece); | ||
List<String> ids = new ArrayList<>(); | ||
ids.add(piece.getId()); | ||
doReturn(succeededFuture(piece)).when(pieceStorageService).getPieceById(piece.getId(), requestContext); | ||
doReturn(succeededFuture(null)).when(protectionService).isOperationRestricted(any(), any(ProtectedOperationType.class), eq(requestContext)); | ||
doReturn(succeededFuture(null)).when(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext)); | ||
doReturn(succeededFuture(null)).when(circulationRequestsRetriever).getNumberOfRequestsByItemId(eq(piece.getItemId()), eq(requestContext)); | ||
doReturn(succeededFuture(holding)).when(inventoryHoldingManager).getHoldingById(holdingId, false, requestContext); | ||
doReturn(succeededFuture(null)).when(inventoryItemManager).getItemsByHoldingId(holdingId, requestContext); | ||
doReturn(succeededFuture(null)).when(inventoryHoldingManager).deleteHoldingById(piece.getHoldingId(), true, requestContext); | ||
doReturn(succeededFuture(null)).when(inventoryItemManager).getItemRecordById(itemId, true, requestContext); | ||
doReturn(succeededFuture(null)).when(inventoryItemManager).deleteItem(itemId, true, requestContext); | ||
doReturn(succeededFuture(holding)).when(inventoryHoldingManager).getHoldingById(holdingId, true, requestContext); | ||
doReturn(succeededFuture(null)).when(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext); | ||
doReturn(succeededFuture(new ArrayList<JsonObject>())).when(inventoryItemManager).getItemsByHoldingId(holdingId, requestContext); | ||
final ArgumentCaptor<PieceDeletionHolder> PieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class); | ||
doAnswer((Answer<Future<Void>>) invocation -> { | ||
PieceDeletionHolder answerHolder = invocation.getArgument(0); | ||
answerHolder.withOrderInformation(purchaseOrder, poLine); | ||
return succeededFuture(null); | ||
}).when(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(PieceDeletionHolderCapture.capture(), eq(requestContext)); | ||
doAnswer((Answer<Future<Void>>) invocation -> { | ||
PieceDeletionHolder answerHolder = invocation.getArgument(0); | ||
answerHolder.withTitleInformation(title); | ||
return succeededFuture(null); | ||
}).when(basePieceFlowHolderBuilder).updateHolderWithTitleInformation(PieceDeletionHolderCapture.capture(), eq(requestContext)); | ||
|
||
final ArgumentCaptor<PieceDeletionHolder> pieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class); | ||
doReturn(succeededFuture(null)).when(pieceDeleteFlowPoLineService).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also separate declaration doReturn and action and verification part to be easy to read |
||
//When | ||
pieceDeleteFlowManager.batchDeletePiece(ids,false ,requestContext).result(); | ||
verify(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext)); | ||
verify(inventoryItemManager, times(0)).deleteItem(itemId, true, requestContext); | ||
verify(pieceStorageService, times(1)).deletePiece(eq(piece.getId()), eq(true), eq(requestContext)); | ||
} | ||
|
||
private static class ContextConfiguration { | ||
|
||
@Bean | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piece records
orPieces
more correctThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also refactor Sentences in other places to be gramatically correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, sure will.