Search in sources :

Example 26 with Physical

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());
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Error(org.folio.rest.jaxrs.model.Error) Test(org.junit.jupiter.api.Test)

Example 27 with Physical

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));
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Error(org.folio.rest.jaxrs.model.Error) Test(org.junit.jupiter.api.Test)

Example 28 with Physical

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());
    });
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Error(org.folio.rest.jaxrs.model.Error) Cost(org.folio.rest.jaxrs.model.Cost) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 29 with Physical

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));
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) JsonObject(io.vertx.core.json.JsonObject) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) Cost(org.folio.rest.jaxrs.model.Cost) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 30 with Physical

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));
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PoLineCommonUtil.isHoldingUpdateRequiredForPhysical(org.folio.orders.utils.PoLineCommonUtil.isHoldingUpdateRequiredForPhysical) CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) CheckInPiece(org.folio.rest.jaxrs.model.CheckInPiece) Piece(org.folio.rest.jaxrs.model.Piece) TestUtils.getMinimalContentPiece(org.folio.TestUtils.getMinimalContentPiece) ArrayList(java.util.ArrayList) CheckInPiece(org.folio.rest.jaxrs.model.CheckInPiece) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Matchers.emptyString(org.hamcrest.Matchers.emptyString) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) PoLineCommonUtil.isHoldingUpdateRequiredForEresource(org.folio.orders.utils.PoLineCommonUtil.isHoldingUpdateRequiredForEresource) Eresource(org.folio.rest.jaxrs.model.Eresource) ToBeCheckedIn(org.folio.rest.jaxrs.model.ToBeCheckedIn) Test(org.junit.jupiter.api.Test)

Aggregations

Physical (org.folio.rest.jaxrs.model.Physical)54 Test (org.junit.jupiter.api.Test)51 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)43 Cost (org.folio.rest.jaxrs.model.Cost)42 Piece (org.folio.rest.jaxrs.model.Piece)42 Location (org.folio.rest.jaxrs.model.Location)39 PoLine (org.folio.rest.jaxrs.model.PoLine)28 PurchaseOrder (org.folio.rest.jaxrs.model.PurchaseOrder)27 Eresource (org.folio.rest.jaxrs.model.Eresource)25 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)24 ArrayList (java.util.ArrayList)23 JsonObject (io.vertx.core.json.JsonObject)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Title (org.folio.rest.jaxrs.model.Title)15 DisplayName (org.junit.jupiter.api.DisplayName)15 Context (io.vertx.core.Context)11 Collections (java.util.Collections)11 List (java.util.List)11 Map (java.util.Map)11 UUID (java.util.UUID)11