Search in sources :

Example 1 with PoLineUpdateHolder

use of org.folio.models.PoLineUpdateHolder in project mod-orders by folio-org.

the class InventoryManager method handleItemRecords.

/**
 * Handles Inventory items for passed list of locations. Items are either retrieved from Inventory or new ones are created
 * if no corresponding item records exist yet.
 * Returns list of {@link Piece} records with populated item id (and other info) corresponding to given PO line.
 *
 * @param compPOL PO line to retrieve/create Item Records for
 * @param holder  pair of new location provided from POl and location from storage
 * @return future with list of piece objects
 */
public CompletableFuture<List<Piece>> handleItemRecords(CompositePoLine compPOL, PoLineUpdateHolder holder, RequestContext requestContext) {
    List<Location> polLocations = compPOL.getLocations().stream().filter(location -> location.getLocationId().equals(holder.getNewLocationId())).collect(toList());
    Map<Piece.Format, Integer> piecesWithItemsQuantities = HelperUtils.calculatePiecesWithItemIdQuantity(compPOL, polLocations);
    int piecesWithItemsQty = IntStreamEx.of(piecesWithItemsQuantities.values()).sum();
    String polId = compPOL.getId();
    logger.debug("Handling {} items for PO Line with id={} and holdings with id={}", piecesWithItemsQty, polId, holder.getOldHoldingId());
    if (piecesWithItemsQty == 0) {
        return completedFuture(Collections.emptyList());
    }
    return pieceStorageService.getExpectedPiecesByLineId(compPOL.getId(), requestContext).thenApply(existingPieces -> {
        List<Piece> needUpdatePieces = new ArrayList<>();
        List<Piece> pieces = existingPieces.getPieces().stream().filter(piece -> piece.getLocationId().equals(holder.getOldLocationId())).map(piece -> piece.withLocationId(holder.getNewLocationId())).collect(toList());
        if (!pieces.isEmpty()) {
            needUpdatePieces.addAll(pieces);
        }
        return needUpdatePieces;
    }).thenCompose(needUpdatePieces -> {
        if (!needUpdatePieces.isEmpty()) {
            return getItemRecordsByIds(needUpdatePieces.stream().map(Piece::getItemId).collect(toList()), requestContext).thenApply(items -> buildPieceItemPairList(needUpdatePieces, items));
        }
        return completedFuture(Collections.<PieceItemPair>emptyList());
    }).thenCompose(pieceItemPairs -> {
        List<CompletableFuture<String>> updatedItemIds = new ArrayList<>(pieceItemPairs.size());
        pieceItemPairs.forEach(pair -> {
            JsonObject item = pair.getItem();
            if (isLocationContainsItemLocation(polLocations, item)) {
                item.put(ITEM_HOLDINGS_RECORD_ID, holder.getNewHoldingId());
                updatedItemIds.add(saveItem(item, requestContext));
            }
        });
        // Wait for all items to be created and corresponding updatedItemIds are built
        return collectResultsOnSuccess(updatedItemIds).thenApply(results -> {
            validateItemsCreation(compPOL.getId(), updatedItemIds.size(), results.size());
            return pieceItemPairs.stream().map(PieceItemPair::getPiece).collect(toList());
        });
    });
}
Also used : CheckInPiece(org.folio.rest.jaxrs.model.CheckInPiece) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) HelperUtils.collectResultsOnSuccess(org.folio.orders.utils.HelperUtils.collectResultsOnSuccess) StringUtils(org.apache.commons.lang3.StringUtils) Context(io.vertx.core.Context) StreamEx.ofSubLists(one.util.streamex.StreamEx.ofSubLists) MISSING_INSTANCE_TYPE(org.folio.rest.core.exceptions.ErrorCodes.MISSING_INSTANCE_TYPE) Collections.singletonList(java.util.Collections.singletonList) ISBN_NOT_VALID(org.folio.rest.core.exceptions.ErrorCodes.ISBN_NOT_VALID) PoLineCommonUtil(org.folio.orders.utils.PoLineCommonUtil) HelperUtils.convertIdsToCqlQuery(org.folio.orders.utils.HelperUtils.convertIdsToCqlQuery) Map(java.util.Map) ListUtils(org.apache.commons.collections4.ListUtils) HOLDINGS_BY_ID_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.HOLDINGS_BY_ID_NOT_FOUND) PARTIALLY_RETURNED_COLLECTION(org.folio.rest.core.exceptions.ErrorCodes.PARTIALLY_RETURNED_COLLECTION) JsonObject(io.vertx.core.json.JsonObject) ORDER_CONFIG_MODULE_NAME(org.folio.orders.utils.HelperUtils.ORDER_CONFIG_MODULE_NAME) PieceStorageService(org.folio.service.pieces.PieceStorageService) LANG(org.folio.orders.utils.HelperUtils.LANG) Location(org.folio.rest.jaxrs.model.Location) Collection(java.util.Collection) ErrorCodes(org.folio.rest.core.exceptions.ErrorCodes) CompletionException(java.util.concurrent.CompletionException) HelperUtils.handleGetRequest(org.folio.orders.utils.HelperUtils.handleGetRequest) Collectors(java.util.stream.Collectors) TenantTool(org.folio.rest.tools.utils.TenantTool) Collectors.joining(java.util.stream.Collectors.joining) ConfigurationEntriesService(org.folio.service.configuration.ConfigurationEntriesService) Objects(java.util.Objects) List(java.util.List) CollectionUtils.isNotEmpty(org.apache.commons.collections4.CollectionUtils.isNotEmpty) Logger(org.apache.logging.log4j.Logger) Response(javax.ws.rs.core.Response) PieceItemPair(org.folio.models.PieceItemPair) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) StreamEx(one.util.streamex.StreamEx) HelperUtils.getFirstObjectFromResponse(org.folio.orders.utils.HelperUtils.getFirstObjectFromResponse) Optional(java.util.Optional) Parameter(org.folio.rest.jaxrs.model.Parameter) IntStreamEx(one.util.streamex.IntStreamEx) ITEM_CREATION_FAILED(org.folio.rest.core.exceptions.ErrorCodes.ITEM_CREATION_FAILED) MISSING_INSTANCE_STATUS(org.folio.rest.core.exceptions.ErrorCodes.MISSING_INSTANCE_STATUS) ELECTRONIC_RESOURCE(org.folio.rest.jaxrs.model.CompositePoLine.OrderFormat.ELECTRONIC_RESOURCE) RestClient(org.folio.rest.core.RestClient) HttpException(org.folio.rest.core.exceptions.HttpException) ProductId(org.folio.rest.jaxrs.model.ProductId) CompletableFuture(java.util.concurrent.CompletableFuture) FolioVertxCompletableFuture(org.folio.completablefuture.FolioVertxCompletableFuture) Contributor(org.folio.rest.jaxrs.model.Contributor) CollectionUtils(org.apache.commons.collections4.CollectionUtils) SharedData(io.vertx.core.shareddata.SharedData) ArrayList(java.util.ArrayList) MAX_IDS_FOR_GET_RQ(org.folio.rest.RestConstants.MAX_IDS_FOR_GET_RQ) MISSING_LOAN_TYPE(org.folio.rest.core.exceptions.ErrorCodes.MISSING_LOAN_TYPE) PoLineUpdateHolder(org.folio.models.PoLineUpdateHolder) Title(org.folio.rest.jaxrs.model.Title) HelperUtils.extractId(org.folio.orders.utils.HelperUtils.extractId) CompletableFuture.allOf(java.util.concurrent.CompletableFuture.allOf) RequestContext(org.folio.rest.core.models.RequestContext) ReceivedItem(org.folio.rest.jaxrs.model.ReceivedItem) HelperUtils.isProductIdsExist(org.folio.orders.utils.HelperUtils.isProductIdsExist) Piece(org.folio.rest.jaxrs.model.Piece) HelperUtils(org.folio.orders.utils.HelperUtils) MISSING_CONTRIBUTOR_NAME_TYPE(org.folio.rest.core.exceptions.ErrorCodes.MISSING_CONTRIBUTOR_NAME_TYPE) RequestEntry(org.folio.rest.core.models.RequestEntry) PostResponseType(org.folio.rest.core.PostResponseType) InventoryException(org.folio.rest.core.exceptions.InventoryException) NOT_FOUND(org.folio.rest.RestConstants.NOT_FOUND) Error(org.folio.rest.jaxrs.model.Error) JsonArray(io.vertx.core.json.JsonArray) Collectors.toList(java.util.stream.Collectors.toList) Lock(io.vertx.core.shareddata.Lock) HelperUtils.encodeQuery(org.folio.orders.utils.HelperUtils.encodeQuery) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) PieceItemPair(org.folio.models.PieceItemPair) CompletableFuture(java.util.concurrent.CompletableFuture) FolioVertxCompletableFuture(org.folio.completablefuture.FolioVertxCompletableFuture) CheckInPiece(org.folio.rest.jaxrs.model.CheckInPiece) Piece(org.folio.rest.jaxrs.model.Piece) Location(org.folio.rest.jaxrs.model.Location)

Example 2 with PoLineUpdateHolder

use of org.folio.models.PoLineUpdateHolder in project mod-orders by folio-org.

the class LocationUtil method convertToOldNewLocationIdPair.

public static List<PoLineUpdateHolder> convertToOldNewLocationIdPair(List<Location> newLocations, List<Location> oldLocations) {
    Map<String, Integer> newLocationQty = LocationUtil.groupLocationQtyByLocationId(newLocations);
    Map<String, Integer> storageLocationQty = LocationUtil.groupLocationQtyByLocationId(oldLocations);
    int newLocationsQty = newLocations.stream().map(Location::getQuantity).mapToInt(Number::intValue).sum();
    int storeLocationsQty = oldLocations.stream().map(Location::getQuantity).mapToInt(Number::intValue).sum();
    List<PoLineUpdateHolder> poLineUpdateHolders = new ArrayList<>();
    if (newLocationsQty == storeLocationsQty && newLocationQty.size() == storageLocationQty.size()) {
        List<String> originNewLocationIds = newLocations.stream().map(Location::getLocationId).collect(toList());
        originNewLocationIds.retainAll(storageLocationQty.keySet());
        if (!originNewLocationIds.isEmpty()) {
            newLocationQty.entrySet().removeIf(e -> originNewLocationIds.contains(e.getKey()));
            storageLocationQty.entrySet().removeIf(e -> originNewLocationIds.contains(e.getKey()));
        }
        List<String> remNewLocationIds = new ArrayList<>(newLocationQty.keySet());
        List<String> remOldLocationIds = new ArrayList<>(storageLocationQty.keySet());
        IntStream.range(0, newLocationQty.size()).forEach(i -> {
            String newLocationId = remNewLocationIds.get(i);
            String oldLocationId = remOldLocationIds.get(i);
            PoLineUpdateHolder holder = new PoLineUpdateHolder().withNewLocationId(newLocationId).withOldLocationId(oldLocationId);
            poLineUpdateHolders.add(holder);
        });
    }
    return poLineUpdateHolders;
}
Also used : PoLineUpdateHolder(org.folio.models.PoLineUpdateHolder) ArrayList(java.util.ArrayList) Location(org.folio.rest.jaxrs.model.Location)

Example 3 with PoLineUpdateHolder

use of org.folio.models.PoLineUpdateHolder in project mod-orders by folio-org.

the class InventoryManagerTest method testShouldHandleItemRecordsIfPhysycPresentInUpdatePoLineTime.

@Test
void testShouldHandleItemRecordsIfPhysycPresentInUpdatePoLineTime() throws IOException {
    CompositePoLine reqData = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, "c0d08448-347b-418a-8c2f-5fb50248d67e").mapTo(CompositePoLine.class);
    String poLineId = "c0d08448-347b-418a-8c2f-5fb50248d67d";
    String itemId = "86481a22-633e-4b97-8061-0dc5fdaaeabb";
    String materialType = "1a54b431-2e4f-452d-9cae-9cee66c9a892";
    String locationId = "758258bc-ecc1-41b8-abca-f7b610822fff";
    String oldLocationId = "fcd64ce1-6995-48f0-840e-89ffa2288371";
    reqData.setId(poLineId);
    reqData.setPurchaseOrderId("9d56b621-202d-414b-9e7f-5fefe4422ab3");
    reqData.getPhysical().setMaterialType(materialType);
    reqData.getPhysical().setMaterialSupplier(ACTIVE_ACCESS_PROVIDER_B);
    reqData.getPhysical().setCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM);
    reqData.getLocations().get(0).setQuantityPhysical(1);
    reqData.getLocations().get(0).setQuantity(1);
    reqData.getCost().setQuantityPhysical(1);
    reqData.getLocations().get(0).setLocationId(locationId);
    CompositePoLine storagePoLineCom = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, "c0d08448-347b-418a-8c2f-5fb50248d67e").mapTo(CompositePoLine.class);
    storagePoLineCom.setAlerts(null);
    storagePoLineCom.setReportingCodes(null);
    storagePoLineCom.getLocations().get(0).setQuantityPhysical(1);
    storagePoLineCom.getLocations().get(0).setQuantity(1);
    storagePoLineCom.getCost().setQuantityPhysical(1);
    JsonObject items = new JsonObject(getMockData(ITEMS_RECORDS_MOCK_DATA_PATH + "inventoryItemsCollection.json"));
    List<JsonObject> needUpdateItems = items.getJsonArray(ITEMS).stream().map(o -> ((JsonObject) o)).filter(item -> item.getString(TestConstants.ID).equals(itemId)).map(item -> item.put(ITEM_PURCHASE_ORDER_LINE_IDENTIFIER, poLineId)).collect(toList());
    ;
    String path = PIECE_RECORDS_MOCK_DATA_PATH + String.format("pieceRecords-%s.json", poLineId);
    PieceCollection existedPieces = new JsonObject(getMockData(path)).mapTo(PieceCollection.class);
    existedPieces.getPieces().get(0).setItemId(itemId);
    existedPieces.getPieces().get(0).setFormat(Piece.Format.PHYSICAL);
    existedPieces.getPieces().get(0).setPoLineId(poLineId);
    // given
    doReturn(completedFuture(existedPieces)).when(pieceStorageService).getExpectedPiecesByLineId(poLineId, requestContext);
    doReturn(completedFuture(needUpdateItems)).when(inventoryManager).getItemRecordsByIds(Collections.singletonList(itemId), requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).updateItemRecords(any(), eq(requestContext));
    doReturn(completedFuture(null)).when(restClient).put(any(RequestEntry.class), any(JsonObject.class), eq(requestContext));
    // When
    PoLineUpdateHolder poLineUpdateHolder = new PoLineUpdateHolder().withOldLocationId(oldLocationId).withNewLocationId(locationId);
    List<Piece> pieces = inventoryManager.handleItemRecords(reqData, poLineUpdateHolder, requestContext).join();
    assertEquals(1, pieces.size());
    assertEquals(itemId, pieces.get(0).getItemId());
    assertEquals(locationId, pieces.get(0).getLocationId());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) TestConfig.getVertx(org.folio.TestConfig.getVertx) TestConstants(org.folio.TestConstants) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiTestSuite(org.folio.ApiTestSuite) AfterAll(org.junit.jupiter.api.AfterAll) PIECE_RECORDS_MOCK_DATA_PATH(org.folio.rest.impl.MockServer.PIECE_RECORDS_MOCK_DATA_PATH) MockitoAnnotations(org.mockito.MockitoAnnotations) CALLS_REAL_METHODS(org.mockito.Mockito.CALLS_REAL_METHODS) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) PARTIALLY_RETURNED_COLLECTION(org.folio.rest.core.exceptions.ErrorCodes.PARTIALLY_RETURNED_COLLECTION) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) Mockito.doReturn(org.mockito.Mockito.doReturn) PieceStorageService(org.folio.service.pieces.PieceStorageService) BASE_MOCK_DATA_PATH(org.folio.rest.impl.MockServer.BASE_MOCK_DATA_PATH) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) HttpClientFactory(org.folio.rest.tools.client.HttpClientFactory) ConfigurationEntriesService(org.folio.service.configuration.ConfigurationEntriesService) TestConfig.mockPort(org.folio.TestConfig.mockPort) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) X_OKAPI_TOKEN(org.folio.TestConstants.X_OKAPI_TOKEN) Logger(org.apache.logging.log4j.Logger) Eresource(org.folio.rest.jaxrs.model.Eresource) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PieceCollection(org.folio.rest.jaxrs.model.PieceCollection) HttpClientInterface(org.folio.rest.tools.client.interfaces.HttpClientInterface) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) RestClient(org.folio.rest.core.RestClient) HOLDINGS_RECORDS(org.folio.service.inventory.InventoryManager.HOLDINGS_RECORDS) X_OKAPI_TENANT(org.folio.rest.impl.PurchaseOrdersApiTest.X_OKAPI_TENANT) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) TestConfig.clearVertxContext(org.folio.TestConfig.clearVertxContext) Mockito.spy(org.mockito.Mockito.spy) HelperUtils.extractId(org.folio.orders.utils.HelperUtils.extractId) INSTANCE_HOLDING(org.folio.rest.jaxrs.model.Eresource.CreateInventory.INSTANCE_HOLDING) HOLDING_PERMANENT_LOCATION_ID(org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID) TestConfig.autowireDependencies(org.folio.TestConfig.autowireDependencies) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Physical(org.folio.rest.jaxrs.model.Physical) COMP_PO_LINES_MOCK_DATA_PATH(org.folio.rest.impl.PurchaseOrderLinesApiTest.COMP_PO_LINES_MOCK_DATA_PATH) Piece(org.folio.rest.jaxrs.model.Piece) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) RequestEntry(org.folio.rest.core.models.RequestEntry) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) PostResponseType(org.folio.rest.core.PostResponseType) ExecutionException(java.util.concurrent.ExecutionException) NOT_FOUND(org.folio.rest.RestConstants.NOT_FOUND) JsonArray(io.vertx.core.json.JsonArray) Mockito.never(org.mockito.Mockito.never) AfterEach(org.junit.jupiter.api.AfterEach) TestUtils.getMockAsJson(org.folio.TestUtils.getMockAsJson) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) TimeoutException(java.util.concurrent.TimeoutException) X_OKAPI_USER_ID(org.folio.TestConstants.X_OKAPI_USER_ID) Context(io.vertx.core.Context) HOLDINGS_BY_ID_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.HOLDINGS_BY_ID_NOT_FOUND) Location(org.folio.rest.jaxrs.model.Location) CompletionException(java.util.concurrent.CompletionException) UUID(java.util.UUID) HOLDINGS_OLD_NEW_PATH(org.folio.rest.impl.MockServer.HOLDINGS_OLD_NEW_PATH) Test(org.junit.jupiter.api.Test) List(java.util.List) HelperUtils.getFirstObjectFromResponse(org.folio.orders.utils.HelperUtils.getFirstObjectFromResponse) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_B) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestConfig.getFirstContextFromVertx(org.folio.TestConfig.getFirstContextFromVertx) ITEMS_RECORDS_MOCK_DATA_PATH(org.folio.rest.impl.MockServer.ITEMS_RECORDS_MOCK_DATA_PATH) ID(org.folio.service.inventory.InventoryManager.ID) HttpException(org.folio.rest.core.exceptions.HttpException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) TestUtils.getMockData(org.folio.TestUtils.getMockData) PoLineUpdateHolder(org.folio.models.PoLineUpdateHolder) ITEM_PURCHASE_ORDER_LINE_IDENTIFIER(org.folio.service.inventory.InventoryManager.ITEM_PURCHASE_ORDER_LINE_IDENTIFIER) Title(org.folio.rest.jaxrs.model.Title) PIECE_PATH(org.folio.TestConstants.PIECE_PATH) RequestContext(org.folio.rest.core.models.RequestContext) ITEMS(org.folio.service.inventory.InventoryManager.ITEMS) IsInstanceOf(org.hamcrest.core.IsInstanceOf) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Error(org.folio.rest.jaxrs.model.Error) Collectors.toList(java.util.stream.Collectors.toList) PieceService(org.folio.service.pieces.PieceService) Bean(org.springframework.context.annotation.Bean) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) PoLineUpdateHolder(org.folio.models.PoLineUpdateHolder) PieceCollection(org.folio.rest.jaxrs.model.PieceCollection) Piece(org.folio.rest.jaxrs.model.Piece) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) JsonObject(io.vertx.core.json.JsonObject) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RequestEntry(org.folio.rest.core.models.RequestEntry) Test(org.junit.jupiter.api.Test)

Example 4 with PoLineUpdateHolder

use of org.folio.models.PoLineUpdateHolder in project mod-orders by folio-org.

the class InventoryManagerTest method testShouldNotHandleItemRecordsIfCheckinItemsIsTrueInUpdatePoLIneTime.

@Test
void testShouldNotHandleItemRecordsIfCheckinItemsIsTrueInUpdatePoLIneTime() {
    CompositePoLine reqData = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, "c2755a78-2f8d-47d0-a218-059a9b7391b4").mapTo(CompositePoLine.class);
    String poLineId = "c0d08448-347b-418a-8c2f-5fb50248d67e";
    reqData.setId(poLineId);
    reqData.setPurchaseOrderId("9d56b621-202d-414b-9e7f-5fefe4422ab3");
    reqData.getEresource().setAccessProvider(ACTIVE_ACCESS_PROVIDER_B);
    reqData.getEresource().setCreateInventory(INSTANCE_HOLDING);
    reqData.getLocations().get(0).setLocationId("758258bc-ecc1-41b8-abca-f7b610822fff");
    reqData.setCheckinItems(true);
    CompositePoLine storagePoLineCom = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, "c0d08448-347b-418a-8c2f-5fb50248d67e").mapTo(CompositePoLine.class);
    storagePoLineCom.setAlerts(null);
    storagePoLineCom.setReportingCodes(null);
    storagePoLineCom.getLocations().get(0).setQuantityPhysical(1);
    storagePoLineCom.getLocations().get(0).setQuantity(1);
    storagePoLineCom.getCost().setQuantityPhysical(1);
    // When
    PoLineUpdateHolder poLineUpdateHolder = new PoLineUpdateHolder().withNewLocationId(NEW_LOCATION_ID);
    List<Piece> pieces = inventoryManager.handleItemRecords(reqData, poLineUpdateHolder, requestContext).join();
    assertEquals(0, pieces.size());
}
Also used : PoLineUpdateHolder(org.folio.models.PoLineUpdateHolder) Piece(org.folio.rest.jaxrs.model.Piece) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

PoLineUpdateHolder (org.folio.models.PoLineUpdateHolder)4 Context (io.vertx.core.Context)2 JsonArray (io.vertx.core.json.JsonArray)2 JsonObject (io.vertx.core.json.JsonObject)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)2 CompletionException (java.util.concurrent.CompletionException)2 Collectors.toList (java.util.stream.Collectors.toList)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)2 Location (org.folio.rest.jaxrs.model.Location)2 Piece (org.folio.rest.jaxrs.model.Piece)2 Test (org.junit.jupiter.api.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Lock (io.vertx.core.shareddata.Lock)1