Skip to content

Commit

Permalink
[MODORDERS-1146] Remove unit tests for title bindItemIds
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Jul 11, 2024
1 parent 92f1917 commit d669991
Showing 1 changed file with 0 additions and 86 deletions.
86 changes: 0 additions & 86 deletions src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1380,92 +1380,6 @@ void testRemovePieceBinding() {
var pieceAfter = pieceList.get(0);
assertThat(pieceAfter.getIsBound(), is(false));
assertThat(pieceAfter.getBindItemId(), nullValue());

var titleUpdates = getUpdatedTitles();
assertThat(titleUpdates, notNullValue());
assertThat(titleUpdates, hasSize(1));

var updatedTitleOpt = titleUpdates.stream()
.map(json -> json.mapTo(Title.class))
.filter(updatedTitle -> updatedTitle.getId().equals(pieceList.get(0).getTitleId()))
.findFirst();

assertThat(updatedTitleOpt.isPresent(), is(true));
var titleBindItemIds = updatedTitleOpt.get().getBindItemIds();
assertThat(titleBindItemIds, hasSize(1));
assertThat(titleBindItemIds.get(0), is(bindItemId));
}

@Test
void testRemovePieceBindingAndClearTitleBindItemIds() {
logger.info("=== Test DELETE Remove binding and clear title's bindItemIds");

var holdingId = "849241fa-4a14-4df5-b951-846dcd6cfc4d";
var order = getMinimalContentCompositePurchaseOrder()
.withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN);
var poLine = getMinimalContentCompositePoLine(order.getId());
var title = getTitle(poLine);
var bindPiece = getMinimalContentPiece(poLine.getId())
.withTitleId(title.getId())
.withHoldingId(holdingId)
.withReceivingStatus(Piece.ReceivingStatus.RECEIVED)
.withFormat(Piece.Format.PHYSICAL);

addMockEntry(PURCHASE_ORDER_STORAGE, order);
addMockEntry(PO_LINES_STORAGE, poLine);
addMockEntry(PIECES_STORAGE, bindPiece);
addMockEntry(TITLES, title);

var bindPiecesCollection = new BindPiecesCollection()
.withPoLineId(poLine.getId())
.withBindItem(getMinimalContentBindItem()
.withLocationId(null)
.withHoldingId(holdingId))
.withBindPieceIds(List.of(bindPiece.getId()));

var bindResponse = verifyPostResponse(ORDERS_BIND_ENDPOINT, JsonObject.mapFrom(bindPiecesCollection).encode(),
prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, HttpStatus.HTTP_OK.toInt())
.as(BindPiecesResult.class);

assertThat(bindResponse.getPoLineId(), is(poLine.getId()));
assertThat(bindResponse.getBoundPieceIds(), hasSize(1));
assertThat(bindResponse.getBoundPieceIds().get(0), is(bindPiece.getId()));
assertThat(bindResponse.getItemId(), notNullValue());

var url = String.format(ORDERS_BIND_ID_ENDPOINT, bindPiece.getId());
verifyDeleteResponse(url, "", HttpStatus.HTTP_NO_CONTENT.toInt());

var pieceUpdates = getPieceUpdates();
assertThat(pieceUpdates, notNullValue());
assertThat(pieceUpdates, hasSize(2));

var pieceList = pieceUpdates.stream()
.map(json -> json.mapTo(Piece.class))
.filter(piece -> Objects.equals(bindPiece.getId(), piece.getId()))
.sorted(Comparator.comparing(Piece::getIsBound))
.toList();
assertThat(pieceList.size(), is(2));

var pieceBefore = pieceList.get(1);
assertThat(pieceBefore.getIsBound(), is(true));
assertThat(pieceBefore.getBindItemId(), notNullValue());

var pieceAfter = pieceList.get(0);
assertThat(pieceAfter.getIsBound(), is(false));
assertThat(pieceAfter.getBindItemId(), nullValue());

var titleUpdates = getUpdatedTitles();
assertThat(titleUpdates, notNullValue());
assertThat(titleUpdates, hasSize(1));

var updatedTitleOpt = titleUpdates.stream()
.map(json -> json.mapTo(Title.class))
.filter(updatedTitle -> updatedTitle.getId().equals(pieceList.get(0).getTitleId()))
.findFirst();

assertThat(updatedTitleOpt.isPresent(), is(true));
var titleBindItemIds = updatedTitleOpt.get().getBindItemIds();
assertThat(titleBindItemIds, hasSize(0));
}

@Test
Expand Down

0 comments on commit d669991

Please sign in to comment.