use of org.folio.rest.jaxrs.model.Physical in project mod-orders by folio-org.
the class PieceValidatorUtilTest method testShouldReturnErrorsIfLocationPhysAndHoldingIsNotProvided.
@Test
void testShouldReturnErrorsIfLocationPhysAndHoldingIsNotProvided() {
Piece piece = new Piece().withFormat(Piece.Format.ELECTRONIC);
Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.NONE);
CompositePoLine originPoLine = new CompositePoLine().withIsPackage(false).withPhysical(physical);
List<Error> errorList = PieceValidatorUtil.validatePieceLocation(piece, originPoLine);
assertEquals(0, errorList.size());
}
use of org.folio.rest.jaxrs.model.Physical in project mod-orders by folio-org.
the class PieceValidatorUtilTest method testShouldReturnErrorsIfLocationAndHoldingProvidedAtOneTime.
@Test
void testShouldReturnErrorsIfLocationAndHoldingProvidedAtOneTime() {
Piece piece = new Piece().withFormat(Piece.Format.PHYSICAL).withLocationId(UUID.randomUUID().toString()).withHoldingId(UUID.randomUUID().toString());
Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING);
CompositePoLine originPoLine = new CompositePoLine().withIsPackage(false).withPhysical(physical);
List<Error> errorList = PieceValidatorUtil.validatePieceLocation(piece, originPoLine);
assertEquals(MAY_BE_LINK_TO_EITHER_HOLDING_OR_LOCATION_ERROR.toError(), errorList.get(0));
}
use of org.folio.rest.jaxrs.model.Physical in project mod-orders by folio-org.
the class CompositePoLineValidationServiceTest method shouldReturnErrorIfLocationAndHoldingReferenceAreNotPresentInTheLocation.
@Test
@DisplayName("Should return error if location and holding reference are not present in the location")
void shouldReturnErrorIfLocationAndHoldingReferenceAreNotPresentInTheLocation() {
Location location1 = new Location().withQuantity(1).withQuantityPhysical(1);
Location location2 = new Location().withQuantity(1).withQuantityPhysical(1);
Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM);
Cost cost = new Cost().withQuantityPhysical(2);
CompositePoLine compositePoLine = new CompositePoLine().withPhysical(physical).withCost(cost).withLocations(List.of(location1, location2));
List<Error> errors = compositePoLineValidationService.validateLocations(compositePoLine);
assertEquals(2, errors.size());
errors.forEach(error -> {
assertEquals(ErrorCodes.HOLDINGS_ID_AND_LOCATION_ID_IS_NULL_ERROR.getCode(), error.getCode());
});
}
use of org.folio.rest.jaxrs.model.Physical in project mod-orders by folio-org.
the class PieceApiTest method deletePieceByIdWithItemDeletionTest.
@Test
void deletePieceByIdWithItemDeletionTest() {
logger.info("=== Test delete piece by id - item deleted ===");
String itemId = UUID.randomUUID().toString();
JsonObject item = new JsonObject().put(ID, itemId);
String lineId = UUID.randomUUID().toString();
String orderId = UUID.randomUUID().toString();
String holdingId = UUID.randomUUID().toString();
CompositePurchaseOrder order = new CompositePurchaseOrder().withId(orderId);
Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
Cost cost = new Cost().withQuantityElectronic(1);
CompositePoLine poLine = new CompositePoLine().withId(lineId).withPurchaseOrderId(order.getId()).withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withOrderFormat(CompositePoLine.OrderFormat.PHYSICAL_RESOURCE).withLocations(List.of(loc)).withCost(cost).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM));
order.setCompositePoLines(Collections.singletonList(poLine));
Piece piece = new Piece().withId(UUID.randomUUID().toString()).withFormat(Piece.Format.PHYSICAL).withHoldingId(holdingId).withItemId(itemId).withPoLineId(poLine.getId());
MockServer.addMockEntry(PIECES_STORAGE, JsonObject.mapFrom(piece));
MockServer.addMockEntry(PO_LINES_STORAGE, JsonObject.mapFrom(poLine));
MockServer.addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(order));
MockServer.addMockEntry(ITEM_RECORDS, item);
verifyDeleteResponse(String.format(PIECES_ID_PATH, piece.getId()), "", 204);
assertNull(MockServer.getItemDeletions());
assertThat(MockServer.getPieceDeletions(), hasSize(1));
}
use of org.folio.rest.jaxrs.model.Physical 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));
}
Aggregations