Search in sources :

Example 1 with CheckInPiece

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));
}
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)

Example 2 with CheckInPiece

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()));
}
Also used : RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) Response(io.restassured.response.Response) 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)

Example 3 with CheckInPiece

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

Example 4 with CheckInPiece

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);
}
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)

Example 5 with CheckInPiece

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);
    }
}
Also used : CheckInPiece(org.folio.rest.jaxrs.model.CheckInPiece) Date(java.util.Date)

Aggregations

CheckInPiece (org.folio.rest.jaxrs.model.CheckInPiece)9 ToBeCheckedIn (org.folio.rest.jaxrs.model.ToBeCheckedIn)8 CheckinCollection (org.folio.rest.jaxrs.model.CheckinCollection)7 ArrayList (java.util.ArrayList)6 Piece (org.folio.rest.jaxrs.model.Piece)6 Test (org.junit.jupiter.api.Test)6 TestUtils.getMinimalContentCompositePoLine (org.folio.TestUtils.getMinimalContentCompositePoLine)5 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)5 Matchers.emptyString (org.hamcrest.Matchers.emptyString)5 TestUtils.getMinimalContentCompositePurchaseOrder (org.folio.TestUtils.getMinimalContentCompositePurchaseOrder)4 TestUtils.getMinimalContentPiece (org.folio.TestUtils.getMinimalContentPiece)4 PoLineCommonUtil.isHoldingUpdateRequiredForEresource (org.folio.orders.utils.PoLineCommonUtil.isHoldingUpdateRequiredForEresource)4 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)4 Eresource (org.folio.rest.jaxrs.model.Eresource)4 PoLineCommonUtil.isHoldingUpdateRequiredForPhysical (org.folio.orders.utils.PoLineCommonUtil.isHoldingUpdateRequiredForPhysical)3 Physical (org.folio.rest.jaxrs.model.Physical)3 Response (io.restassured.response.Response)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2