use of org.folio.rest.jaxrs.model.CheckInPiece in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostCheckinElectronicPhysicalChangeLocationIdNewHoldingIsCreatedForPhysicalPiece.
@Test
void testPostCheckinElectronicPhysicalChangeLocationIdNewHoldingIsCreatedForPhysicalPiece() {
logger.info("=== Test POST check-in - Check-in physical and electronic resource with new locationId ===");
CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder();
CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId());
poLine.setOrderFormat(CompositePoLine.OrderFormat.P_E_MIX);
// holding mustn't be created
poLine.setEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE));
// holding must be created
poLine.setPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING));
String locationForPhysical = UUID.randomUUID().toString();
String locationForElectronic = UUID.randomUUID().toString();
String titleId = UUID.randomUUID().toString();
MockServer.addMockTitleWithId(poLine, titleId);
Piece physicalPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.PHYSICAL).withLocationId(locationForPhysical).withId(UUID.randomUUID().toString()).withTitleId(titleId).withItemId(UUID.randomUUID().toString());
Piece electronicPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC).withId(UUID.randomUUID().toString()).withTitleId(titleId).withItemId(UUID.randomUUID().toString());
addMockEntry(PURCHASE_ORDER_STORAGE, order.withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN));
addMockEntry(PO_LINES_STORAGE, poLine);
addMockEntry(PIECES_STORAGE, physicalPiece);
addMockEntry(PIECES_STORAGE, electronicPiece);
List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>();
toBeCheckedInList.add(new ToBeCheckedIn().withCheckedIn(1).withPoLineId(poLine.getId()).withCheckInPieces(Arrays.asList(new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER), new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER))));
CheckinCollection request = new CheckinCollection().withToBeCheckedIn(toBeCheckedInList).withTotalRecords(2);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setId(physicalPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(locationForPhysical);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setId(electronicPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setLocationId(locationForElectronic);
checkResultWithErrors(request, 0);
assertThat(getCreatedHoldings(), hasSize(1));
assertThat(getCreatedHoldings().get(0).getString(HOLDING_PERMANENT_LOCATION_ID), is(locationForPhysical));
}
use of org.folio.rest.jaxrs.model.CheckInPiece in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostCheckinTitleNotFoundError.
@Test
void testPostCheckinTitleNotFoundError() {
logger.info("=== Test POST check-in title not found error ===");
CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder();
CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId());
poLine.setIsPackage(true);
poLine.setOrderFormat(CompositePoLine.OrderFormat.ELECTRONIC_RESOURCE);
poLine.setEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE_HOLDING_ITEM));
String locationForElectronic = UUID.randomUUID().toString();
Piece electronicPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC).withId(UUID.randomUUID().toString()).withTitleId(UUID.randomUUID().toString()).withItemId(UUID.randomUUID().toString());
addMockEntry(PURCHASE_ORDER_STORAGE, order.withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN));
addMockEntry(PO_LINES_STORAGE, poLine);
addMockEntry(PIECES_STORAGE, electronicPiece);
List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>();
toBeCheckedInList.add(new ToBeCheckedIn().withCheckedIn(1).withPoLineId(poLine.getId()).withCheckInPieces(Collections.singletonList(new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER))));
CheckinCollection request = new CheckinCollection().withToBeCheckedIn(toBeCheckedInList).withTotalRecords(1);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setId(electronicPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(locationForElectronic);
Response response = verifyPostResponse(ORDERS_CHECKIN_ENDPOINT, JsonObject.mapFrom(request).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, HttpStatus.HTTP_BAD_REQUEST.toInt());
assertThat(response.as(Errors.class).getErrors().get(0).getMessage(), is(TITLE_NOT_FOUND.getDescription()));
}
use of org.folio.rest.jaxrs.model.CheckInPiece in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostCheckInLocationId.
@Test
void testPostCheckInLocationId() {
logger.info("=== Test POST Checkin - locationId checking ===");
String poLineId = "fe47e95d-24e9-4a9a-9dc0-bcba64b51f56";
String pieceId = UUID.randomUUID().toString();
CompositePoLine poLine = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(5).mapTo(CompositePoLine.class);
MockServer.addMockTitles(Collections.singletonList(poLine));
List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>();
toBeCheckedInList.add(new ToBeCheckedIn().withCheckedIn(1).withPoLineId(poLineId).withCheckInPieces(Arrays.asList(new CheckInPiece().withId(pieceId).withItemStatus(CheckInPiece.ItemStatus.ON_ORDER), new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.IN_PROCESS))));
CheckinCollection request = new CheckinCollection().withToBeCheckedIn(toBeCheckedInList).withTotalRecords(2);
String physicalPieceWithoutLocationId = "90894300-5285-4d83-80f4-76cf621e555e";
String electronicPieceWithoutLocationId = "1a247602-c51a-4221-9a07-27d075d03625";
// Positive cases:
// 1. Both CheckInPiece with locationId
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setId(physicalPieceWithoutLocationId);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(UUID.randomUUID().toString());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setId(electronicPieceWithoutLocationId);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setLocationId(UUID.randomUUID().toString());
checkResultWithErrors(request, 0);
assertThat(getPieceSearches(), hasSize(2));
assertThat(getPieceUpdates(), hasSize(2));
assertThat(getPoLineSearches(), hasSize(1));
assertThat(getPoLineUpdates(), hasSize(1));
verifyCheckinOrderStatusUpdateEvent(1);
// Negative cases:
// 1. One CheckInPiece and corresponding Piece without locationId
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(null);
clearServiceInteractions();
MockServer.addMockTitles(Collections.singletonList(poLine));
checkResultWithErrors(request, 1);
assertThat(getPieceSearches(), hasSize(2));
assertThat(getPieceUpdates(), hasSize(1));
assertThat(getPoLineSearches(), hasSize(1));
assertThat(getPoLineUpdates(), hasSize(1));
verifyCheckinOrderStatusUpdateEvent(1);
// 2. All CheckInPieces and corresponding Pieces without locationId
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(null);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setLocationId(null);
clearServiceInteractions();
MockServer.addMockTitles(Collections.singletonList(poLine));
checkResultWithErrors(request, 2);
assertThat(getPieceSearches(), hasSize(1));
assertThat(getPieceUpdates(), nullValue());
assertThat(getPoLineSearches(), hasSize(1));
assertThat(getPoLineUpdates(), nullValue());
verifyOrderStatusUpdateEvent(0);
}
use of org.folio.rest.jaxrs.model.CheckInPiece in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostCheckinForPackagePOL.
@Test
void testPostCheckinForPackagePOL() {
logger.info("=== Test POST check-in - Package POL ===");
CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder();
CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId());
poLine.setIsPackage(true);
poLine.setOrderFormat(CompositePoLine.OrderFormat.P_E_MIX);
poLine.setEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE_HOLDING_ITEM));
poLine.setPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM));
String locationForPhysical = UUID.randomUUID().toString();
String locationForElectronic = UUID.randomUUID().toString();
String titleIdForPhysical = UUID.randomUUID().toString();
MockServer.addMockTitleWithId(poLine, titleIdForPhysical);
String titleIdForElectronic = UUID.randomUUID().toString();
MockServer.addMockTitleWithId(poLine, titleIdForElectronic);
Piece physicalPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.PHYSICAL).withLocationId(locationForPhysical).withId(UUID.randomUUID().toString()).withTitleId(titleIdForPhysical).withItemId(UUID.randomUUID().toString());
Piece electronicPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC).withId(UUID.randomUUID().toString()).withTitleId(titleIdForElectronic).withItemId(UUID.randomUUID().toString());
addMockEntry(PURCHASE_ORDER_STORAGE, order.withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN));
addMockEntry(PO_LINES_STORAGE, poLine);
addMockEntry(PIECES_STORAGE, physicalPiece);
addMockEntry(PIECES_STORAGE, electronicPiece);
List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>();
toBeCheckedInList.add(new ToBeCheckedIn().withCheckedIn(2).withPoLineId(poLine.getId()).withCheckInPieces(Arrays.asList(new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER), new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER))));
CheckinCollection request = new CheckinCollection().withToBeCheckedIn(toBeCheckedInList).withTotalRecords(2);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setId(physicalPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(locationForPhysical);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setId(electronicPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setLocationId(locationForElectronic);
checkResultWithErrors(request, 0);
}
use of org.folio.rest.jaxrs.model.CheckInPiece in project mod-orders by folio-org.
the class CheckinHelper method updatePieceWithCheckinInfo.
private void updatePieceWithCheckinInfo(Piece piece) {
// Get checkinPiece corresponding to piece record
CheckInPiece checkinPiece = piecesByLineId.get(piece.getPoLineId()).get(piece.getId());
piece.setCaption(checkinPiece.getCaption());
piece.setComment(checkinPiece.getComment());
if (StringUtils.isNotEmpty(checkinPiece.getLocationId())) {
piece.setLocationId(checkinPiece.getLocationId());
}
if (StringUtils.isNotEmpty(checkinPiece.getHoldingId())) {
piece.setHoldingId(checkinPiece.getHoldingId());
}
piece.setEnumeration(checkinPiece.getEnumeration());
piece.setChronology(checkinPiece.getChronology());
piece.setDisplayOnHolding(checkinPiece.getDisplayOnHolding());
piece.setDiscoverySuppress(checkinPiece.getDiscoverySuppress());
piece.setSupplement(checkinPiece.getSupplement());
// Piece record might be received or rolled-back to Expected
if (inventoryManager.isOnOrderPieceStatus(checkinPiece)) {
piece.setReceivedDate(null);
piece.setReceivingStatus(Piece.ReceivingStatus.EXPECTED);
} else {
piece.setReceivedDate(new Date());
piece.setReceivingStatus(Piece.ReceivingStatus.RECEIVED);
}
}
Aggregations