Search in sources :

Example 11 with CheckinCollection

use of org.folio.rest.jaxrs.model.CheckinCollection in project mod-orders by folio-org.

the class CheckinReceivingApiTest method testPostCheckinMultipleTitlesError.

@Test
void testPostCheckinMultipleTitlesError() {
    logger.info("=== Test POST check-in multiple titles error for non-packages ===");
    CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder();
    CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId());
    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);
    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(MULTIPLE_NONPACKAGE_TITLES.getDescription()));
}
Also used : RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) Response(io.restassured.response.Response) 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 12 with CheckinCollection

use of org.folio.rest.jaxrs.model.CheckinCollection in project mod-orders by folio-org.

the class CheckinReceivingApiTest method testPostCheckinRevertPhysicalResource.

@Test
void testPostCheckinRevertPhysicalResource() {
    logger.info("=== Test POST Check-in - Revert received Physical resource");
    CompositePoLine poLines = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(8).mapTo(CompositePoLine.class);
    MockServer.addMockTitles(Collections.singletonList(poLines));
    CheckinCollection checkinReq = getMockAsJson(CHECKIN_RQ_MOCK_DATA_PATH + "revert-checkin-physical-1-resource.json").mapTo(CheckinCollection.class);
    ReceivingResults results = verifyPostResponse(ORDERS_CHECKIN_ENDPOINT, JsonObject.mapFrom(checkinReq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, 200).as(ReceivingResults.class);
    assertThat(results.getTotalRecords(), equalTo(checkinReq.getTotalRecords()));
    verifyReceivingSuccessRs(results);
    List<JsonObject> pieceSearches = getPieceSearches();
    List<JsonObject> pieceUpdates = getPieceUpdates();
    List<JsonObject> itemsSearches = getItemsSearches();
    List<JsonObject> itemUpdates = getItemUpdates();
    List<JsonObject> polSearches = getPoLineSearches();
    List<JsonObject> polUpdates = getPoLineUpdates();
    assertThat(pieceSearches, not(nullValue()));
    assertThat(pieceUpdates, not(nullValue()));
    assertThat(itemsSearches, not(nullValue()));
    assertThat(itemUpdates, not(nullValue()));
    assertThat(polSearches, not(nullValue()));
    assertThat(polUpdates, not(nullValue()));
    // The piece searches should be made 2 times: 1st time to get piece record,
    // 2nd time to calculate expected PO Line status
    assertThat(pieceSearches, hasSize(3));
    assertThat(pieceUpdates, hasSize(1));
    assertThat(itemsSearches, hasSize(1));
    assertThat(itemUpdates, hasSize(1));
    assertThat(polSearches, hasSize(1));
    assertThat(polUpdates, hasSize(1));
    itemUpdates.forEach(item -> {
        assertThat(item.getJsonObject(ITEM_STATUS), notNullValue());
        assertThat(item.getString(ITEM_LEVEL_CALL_NUMBER), is(nullValue()));
        assertThat(item.getJsonObject(ITEM_STATUS).getString(ITEM_STATUS_NAME), equalTo(ON_ORDER.value()));
    });
    polUpdates.forEach(pol -> {
        PoLine poLine = pol.mapTo(PoLine.class);
        assertThat(poLine.getCheckinItems(), is(true));
        assertThat(poLine.getReceiptStatus(), is(PoLine.ReceiptStatus.AWAITING_RECEIPT));
        assertThat(poLine.getReceiptDate(), is(nullValue()));
    });
    // Verify message is sent via event bus
    verifyCheckinOrderStatusUpdateEvent(1);
}
Also used : CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) JsonObject(io.vertx.core.json.JsonObject) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) Test(org.junit.jupiter.api.Test)

Example 13 with CheckinCollection

use of org.folio.rest.jaxrs.model.CheckinCollection in project mod-orders by folio-org.

the class ReceivingCheckinProtectionTest method getCheckInCollection.

private static CheckinCollection getCheckInCollection(List<String> units) {
    CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder().withAcqUnitIds(units).withId(getRandomId());
    addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(order));
    CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId()).withId(EXPECTED_FLOW_PO_LINE_ID);
    addMockEntry(PO_LINES_STORAGE, JsonObject.mapFrom(poLine));
    MockServer.addMockTitles(Collections.singletonList(poLine));
    CheckinCollection toBeCheckedInRq = new CheckinCollection();
    List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>(Arrays.asList(getToBeCheckedIn(poLine.getId(), EXPECTED_FLOW_PIECE_ID_1), getToBeCheckedIn(poLine.getId(), EXPECTED_FLOW_PIECE_ID_2)));
    toBeCheckedInRq.setToBeCheckedIn(toBeCheckedInList);
    toBeCheckedInRq.setTotalRecords(toBeCheckedInList.size());
    return toBeCheckedInRq;
}
Also used : CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) ArrayList(java.util.ArrayList) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) ToBeCheckedIn(org.folio.rest.jaxrs.model.ToBeCheckedIn) TestUtils.getToBeCheckedIn(org.folio.TestUtils.getToBeCheckedIn)

Aggregations

CheckinCollection (org.folio.rest.jaxrs.model.CheckinCollection)13 TestUtils.getMinimalContentCompositePoLine (org.folio.TestUtils.getMinimalContentCompositePoLine)10 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)10 Test (org.junit.jupiter.api.Test)10 ToBeCheckedIn (org.folio.rest.jaxrs.model.ToBeCheckedIn)9 ArrayList (java.util.ArrayList)8 CheckInPiece (org.folio.rest.jaxrs.model.CheckInPiece)7 JsonObject (io.vertx.core.json.JsonObject)6 TestUtils.getMinimalContentCompositePurchaseOrder (org.folio.TestUtils.getMinimalContentCompositePurchaseOrder)6 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)6 Piece (org.folio.rest.jaxrs.model.Piece)5 ReceivingResults (org.folio.rest.jaxrs.model.ReceivingResults)5 Matchers.emptyString (org.hamcrest.Matchers.emptyString)5 PoLine (org.folio.rest.jaxrs.model.PoLine)4 List (java.util.List)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 RestTestUtils.verifyPostResponse (org.folio.RestTestUtils.verifyPostResponse)3 TestUtils.getMinimalContentPiece (org.folio.TestUtils.getMinimalContentPiece)3 PoLineCommonUtil.isHoldingUpdateRequiredForEresource (org.folio.orders.utils.PoLineCommonUtil.isHoldingUpdateRequiredForEresource)3