Search in sources :

Example 91 with PoLine

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

the class CheckinReceivingApiTest method testPostReceivingRevertMixedResources.

@Test
void testPostReceivingRevertMixedResources() {
    logger.info("=== Test POST Receiving - Revert received P/E Mix resources");
    CompositePoLine poLines = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(5).mapTo(CompositePoLine.class);
    MockServer.addMockTitles(Collections.singletonList(poLines));
    ReceivingCollection receivingRq = getMockAsJson(RECEIVING_RQ_MOCK_DATA_PATH + "revert-pe-mix-4-of-5-resources.json").mapTo(ReceivingCollection.class);
    ReceivingResults results = verifyPostResponse(ORDERS_RECEIVING_ENDPOINT, JsonObject.mapFrom(receivingRq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, 200).as(ReceivingResults.class);
    assertThat(results.getTotalRecords(), equalTo(receivingRq.getTotalRecords()));
    Map<String, Set<String>> pieceIdsByPol = 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 3 times: 1st time to get all required piece records, 2nd and 3rd times to calculate expected PO Line status
    assertThat(pieceSearches, hasSize(3));
    // In total 4 pieces required update
    assertThat(pieceUpdates, hasSize(4));
    assertThat(itemsSearches, hasSize(1));
    // There are 3 piece records with item id's
    assertThat(itemUpdates, hasSize(3));
    assertThat(polSearches, hasSize(pieceIdsByPol.size()));
    assertThat(polUpdates, hasSize(pieceIdsByPol.size()));
    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(ReceivedItem.ItemStatus.ON_ORDER.value()));
    });
    polUpdates.forEach(pol -> {
        PoLine poLine = pol.mapTo(PoLine.class);
        assertThat(poLine.getReceiptStatus(), is(PoLine.ReceiptStatus.PARTIALLY_RECEIVED));
        assertThat(poLine.getReceiptDate(), is(nullValue()));
    });
    // Verify messages sent via event bus
    verifyOrderStatusUpdateEvent(1);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PoLine(org.folio.rest.jaxrs.model.PoLine) ReceivingCollection(org.folio.rest.jaxrs.model.ReceivingCollection) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) JsonObject(io.vertx.core.json.JsonObject) Matchers.emptyString(org.hamcrest.Matchers.emptyString) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) Test(org.junit.jupiter.api.Test)

Aggregations

PoLine (org.folio.rest.jaxrs.model.PoLine)91 Test (org.junit.jupiter.api.Test)65 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)56 PurchaseOrder (org.folio.rest.jaxrs.model.PurchaseOrder)53 Cost (org.folio.rest.jaxrs.model.Cost)52 Piece (org.folio.rest.jaxrs.model.Piece)51 Location (org.folio.rest.jaxrs.model.Location)49 JsonObject (io.vertx.core.json.JsonObject)45 ArrayList (java.util.ArrayList)38 Eresource (org.folio.rest.jaxrs.model.Eresource)35 Physical (org.folio.rest.jaxrs.model.Physical)31 List (java.util.List)23 DisplayName (org.junit.jupiter.api.DisplayName)23 Map (java.util.Map)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 RequestContext (org.folio.rest.core.models.RequestContext)19 CompletableFuture (java.util.concurrent.CompletableFuture)17 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)17 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)15 Context (io.vertx.core.Context)14