Search in sources :

Example 1 with HOLDING_PERMANENT_LOCATION_ID

use of org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID in project mod-orders by folio-org.

the class PieceDeleteFlowManagerTest method shouldUpdateLineQuantityIfPoLineIsNotPackageAndManualPieceCreateFalseAndInventoryInstanceVsHoldingAndDeleteHoldingAndPiece.

@Test
void shouldUpdateLineQuantityIfPoLineIsNotPackageAndManualPieceCreateFalseAndInventoryInstanceVsHoldingAndDeleteHoldingAndPiece() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String holdingId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    JsonObject holding = new JsonObject();
    holding.put(ID, holdingId);
    holding.put(HOLDING_PERMANENT_LOCATION_ID, locationId);
    JsonObject item = new JsonObject().put(ID, itemId);
    item.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, ItemStatus.ON_ORDER.value()));
    Piece piece = new Piece().withId(UUID.randomUUID().toString()).withPoLineId(lineId).withHoldingId(holdingId).withFormat(Piece.Format.ELECTRONIC);
    Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1).withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    PoLine poLine = new PoLine().withIsPackage(false).withCheckinItems(false).withOrderFormat(PoLine.OrderFormat.ELECTRONIC_RESOURCE).withEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE_HOLDING)).withPurchaseOrderId(orderId).withId(lineId).withLocations(List.of(loc)).withCost(cost);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    doReturn(completedFuture(piece)).when(pieceStorageService).getPieceById(piece.getId(), requestContext);
    doReturn(completedFuture(null)).when(protectionService).isOperationRestricted(any(List.class), any(ProtectedOperationType.class), eq(requestContext));
    doReturn(completedFuture(null)).when(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    doReturn(completedFuture(null)).when(inventoryManager).getNumberOfRequestsByItemId(eq(piece.getItemId()), eq(requestContext));
    doReturn(completedFuture(holding)).when(inventoryManager).getHoldingById(holdingId, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).getItemsByHoldingId(holdingId, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).deleteHoldingById(piece.getHoldingId(), true, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).getItemRecordById(itemId, true, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).deleteItem(itemId, true, requestContext);
    doReturn(completedFuture(holding)).when(inventoryManager).getHoldingById(holdingId, true, requestContext);
    doReturn(completedFuture(null)).when(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext);
    doReturn(completedFuture(new ArrayList())).when(inventoryManager).getItemsByHoldingId(holdingId, requestContext);
    final ArgumentCaptor<PieceDeletionHolder> PieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class);
    doAnswer((Answer<CompletableFuture<Void>>) invocation -> {
        PieceDeletionHolder answerHolder = invocation.getArgument(0);
        answerHolder.withOrderInformation(purchaseOrder, poLine);
        return completedFuture(null);
    }).when(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(PieceDeletionHolderCapture.capture(), eq(requestContext));
    final ArgumentCaptor<PieceDeletionHolder> pieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class);
    doReturn(completedFuture(null)).when(pieceDeleteFlowPoLineService).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext));
    // When
    pieceDeleteFlowManager.deletePiece(piece.getId(), true, requestContext).get();
    // Then
    PieceDeletionHolder holder = PieceDeletionHolderCapture.getValue();
    verify(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    verify(inventoryManager, times(0)).deleteItem(itemId, true, requestContext);
    verify(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext);
    verify(pieceStorageService, times(1)).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    verify(pieceDeleteFlowPoLineService).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext));
    verify(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(holder, requestContext);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Cost(org.folio.rest.jaxrs.model.Cost) TestConfig.getVertx(org.folio.TestConfig.getVertx) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) TimeoutException(java.util.concurrent.TimeoutException) Autowired(org.springframework.beans.factory.annotation.Autowired) PoLine(org.folio.rest.jaxrs.model.PoLine) Context(io.vertx.core.Context) ApiTestSuite(org.folio.ApiTestSuite) AfterAll(org.junit.jupiter.api.AfterAll) MockitoAnnotations(org.mockito.MockitoAnnotations) ITEM_STATUS(org.folio.service.inventory.InventoryManager.ITEM_STATUS) ProtectionService(org.folio.service.ProtectionService) BeforeAll(org.junit.jupiter.api.BeforeAll) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) Spy(org.mockito.Spy) JsonObject(io.vertx.core.json.JsonObject) Mockito.doReturn(org.mockito.Mockito.doReturn) PieceStorageService(org.folio.service.pieces.PieceStorageService) ID(org.folio.TestConstants.ID) ItemStatus(org.folio.models.ItemStatus) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) Location(org.folio.rest.jaxrs.model.Location) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) BasePieceFlowHolderBuilder(org.folio.service.pieces.flows.BasePieceFlowHolderBuilder) UUID(java.util.UUID) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) Test(org.junit.jupiter.api.Test) List(java.util.List) Eresource(org.folio.rest.jaxrs.model.Eresource) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestConfig.getFirstContextFromVertx(org.folio.TestConfig.getFirstContextFromVertx) Mock(org.mockito.Mock) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CompletableFuture(java.util.concurrent.CompletableFuture) TestConfig.clearVertxContext(org.folio.TestConfig.clearVertxContext) ArrayList(java.util.ArrayList) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) RequestContext(org.folio.rest.core.models.RequestContext) PieceUpdateInventoryService(org.folio.service.pieces.PieceUpdateInventoryService) HOLDING_PERMANENT_LOCATION_ID(org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID) TestConfig.autowireDependencies(org.folio.TestConfig.autowireDependencies) InventoryManager(org.folio.service.inventory.InventoryManager) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PieceDeletionHolder(org.folio.models.pieces.PieceDeletionHolder) Piece(org.folio.rest.jaxrs.model.Piece) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) Mockito.times(org.mockito.Mockito.times) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) Mockito(org.mockito.Mockito) AfterEach(org.junit.jupiter.api.AfterEach) Bean(org.springframework.context.annotation.Bean) ITEM_STATUS_NAME(org.folio.service.inventory.InventoryManager.ITEM_STATUS_NAME) PieceDeletionHolder(org.folio.models.pieces.PieceDeletionHolder) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) CompletableFuture(java.util.concurrent.CompletableFuture) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) List(java.util.List) ArrayList(java.util.ArrayList) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 2 with HOLDING_PERMANENT_LOCATION_ID

use of org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID in project mod-orders by folio-org.

the class InventoryInteractionTestHelper method verifyOpenOrderPiecesCreated.

public static void verifyOpenOrderPiecesCreated(List<JsonObject> inventoryItems, List<CompositePoLine> compositePoLines, List<JsonObject> pieceJsons, int expectedWithItemQty) {
    // Collect all item id's
    List<String> itemIds = inventoryItems.stream().map(item -> item.getString(ID)).collect(Collectors.toList());
    List<Piece> pieces = pieceJsons.stream().map(pieceObj -> pieceObj.mapTo(Piece.class)).collect(Collectors.toList());
    // Verify quantity of created pieces
    int totalForAllPoLines = 0;
    for (CompositePoLine poLine : compositePoLines) {
        Map<String, List<JsonObject>> createdHoldingsByLocationId = getCreatedHoldings().stream().filter(json -> json.getString("instanceId").equals(poLine.getInstanceId())).collect(groupingBy(json -> json.getString(HOLDING_PERMANENT_LOCATION_ID)));
        List<Location> locations = poLine.getLocations().stream().filter(location -> PoLineCommonUtil.isHoldingCreationRequiredForLocation(poLine, location) && !Objects.equals(location.getLocationId(), ID_FOR_INTERNAL_SERVER_ERROR)).collect(Collectors.toList());
        // Prepare data first
        // Calculated quantities
        int expectedElQty = 0;
        int expectedPhysQty = 0;
        int expectedOthQty = 0;
        if (poLine.getCheckinItems() == null || !poLine.getCheckinItems()) {
            if (poLine.getOrderFormat() == CompositePoLine.OrderFormat.OTHER) {
                // calculatePiecesQuantity(Piece.Format.OTHER, locations);
                expectedOthQty += getPhysicalCostQuantity(poLine);
            } else {
                // calculatePiecesQuantity(Piece.Format.PHYSICAL, locations);
                expectedPhysQty += getPhysicalCostQuantity(poLine);
            }
            // calculatePiecesQuantity(Piece.Format.ELECTRONIC, locations);
            expectedElQty = getElectronicCostQuantity(poLine);
        }
        int expectedWithoutItemQty = calculateInventoryItemsQuantity(poLine, locations);
        int expectedWithoutLocation = calculatePiecesQuantityWithoutLocation(poLine).values().stream().mapToInt(Integer::intValue).sum();
        // Prepare pieces for PO Line
        List<Piece> poLinePieces = pieces.stream().filter(piece -> piece.getPoLineId().equals(poLine.getId())).collect(Collectors.toList());
        Map<String, Long> piecesByLocationIdQuantity = poLinePieces.stream().filter(piece -> Objects.nonNull(piece.getLocationId())).collect(groupingBy(Piece::getLocationId, Collectors.counting()));
        int expectedTotal = expectedWithItemQty + expectedWithoutItemQty + expectedWithoutLocation;
        // Make sure that quantities by piece type and by item presence are the same
        assertThat(expectedPhysQty + expectedElQty + expectedOthQty, is(expectedTotal));
        assertThat(poLinePieces, hasSize(expectedTotal));
        // Verify each piece individually
        poLinePieces.forEach(piece -> {
            // Check if itemId in inventoryItems match itemId in piece record
            if (poLine.getCheckinItems() != null && Boolean.FALSE.equals(poLine.getCheckinItems())) {
                if (piece.getLocationId() != null) {
                    String pieceLocationId = piece.getLocationId();
                    List<JsonObject> createdHoldingsForLocation = createdHoldingsByLocationId.get(pieceLocationId);
                    assertNotNull(createdHoldingsForLocation);
                }
            }
            assertThat(piece.getReceivingStatus(), equalTo(Piece.ReceivingStatus.EXPECTED));
            if (piece.getItemId() != null) {
                assertThat(itemIds, hasItem(piece.getItemId()));
            }
            assertThat(piece.getFormat(), notNullValue());
        });
        totalForAllPoLines += expectedTotal;
    }
    // Make sure that none of pieces missed
    assertThat(pieceJsons, hasSize(totalForAllPoLines));
}
Also used : MockServer.getCreatedHoldings(org.folio.rest.impl.MockServer.getCreatedHoldings) CONFIG_NAME_INSTANCE_STATUS_CODE(org.folio.service.inventory.InventoryManager.CONFIG_NAME_INSTANCE_STATUS_CODE) CONFIG_NAME_INSTANCE_TYPE_CODE(org.folio.service.inventory.InventoryManager.CONFIG_NAME_INSTANCE_TYPE_CODE) HelperUtils.calculateTotalQuantity(org.folio.orders.utils.HelperUtils.calculateTotalQuantity) CONFIG_NAME_LOAN_TYPE_NAME(org.folio.service.inventory.InventoryManager.CONFIG_NAME_LOAN_TYPE_NAME) Matchers.not(org.hamcrest.Matchers.not) Header(io.restassured.http.Header) LOAN_TYPES(org.folio.service.inventory.InventoryManager.LOAN_TYPES) StringUtils(org.apache.commons.lang3.StringUtils) INSTANCE_TYPES_MOCK_DATA_PATH(org.folio.rest.impl.MockServer.INSTANCE_TYPES_MOCK_DATA_PATH) PoLineCommonUtil(org.folio.orders.utils.PoLineCommonUtil) CONFIG_NAME(org.folio.orders.utils.HelperUtils.CONFIG_NAME) Map(java.util.Map) INSTANCE_STATUSES_MOCK_DATA_PATH(org.folio.rest.impl.MockServer.INSTANCE_STATUSES_MOCK_DATA_PATH) JsonObject(io.vertx.core.json.JsonObject) DEFAULT_LOAN_TYPE_NAME(org.folio.service.inventory.InventoryManager.DEFAULT_LOAN_TYPE_NAME) ID_FOR_INTERNAL_SERVER_ERROR(org.folio.TestConstants.ID_FOR_INTERNAL_SERVER_ERROR) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Assertions.fail(org.assertj.core.api.Assertions.fail) Logger(org.apache.logging.log4j.Logger) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) INSTANCE_STATUSES(org.folio.service.inventory.InventoryManager.INSTANCE_STATUSES) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) DEFAULT_INSTANCE_STATUS_CODE(org.folio.service.inventory.InventoryManager.DEFAULT_INSTANCE_STATUS_CODE) Matchers.is(org.hamcrest.Matchers.is) INSTANCE_CONTRIBUTORS(org.folio.service.inventory.InventoryManager.INSTANCE_CONTRIBUTORS) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) HelperUtils.calculateInventoryItemsQuantity(org.folio.orders.utils.HelperUtils.calculateInventoryItemsQuantity) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Contributor(org.folio.rest.jaxrs.model.Contributor) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) LOAN_TYPES_MOCK_DATA_PATH(org.folio.rest.impl.MockServer.LOAN_TYPES_MOCK_DATA_PATH) INSTANCE_IDENTIFIERS(org.folio.service.inventory.InventoryManager.INSTANCE_IDENTIFIERS) MockServer.getHoldingsSearches(org.folio.rest.impl.MockServer.getHoldingsSearches) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) HOLDING_PERMANENT_LOCATION_ID(org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) INSTANCE_DATE_OF_PUBLICATION(org.folio.service.inventory.InventoryManager.INSTANCE_DATE_OF_PUBLICATION) CONTRIBUTOR_NAME_TYPE_ID(org.folio.service.inventory.InventoryManager.CONTRIBUTOR_NAME_TYPE_ID) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10) MockServer.getPieceSearches(org.folio.rest.impl.MockServer.getPieceSearches) INSTANCE_PUBLISHER(org.folio.service.inventory.InventoryManager.INSTANCE_PUBLISHER) Piece(org.folio.rest.jaxrs.model.Piece) HelperUtils(org.folio.orders.utils.HelperUtils) PieceUtil.calculatePiecesQuantityWithoutLocation(org.folio.service.pieces.PieceUtil.calculatePiecesQuantityWithoutLocation) IOException(java.io.IOException) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) ITEM_MATERIAL_TYPE_ID(org.folio.service.inventory.InventoryManager.ITEM_MATERIAL_TYPE_ID) JsonArray(io.vertx.core.json.JsonArray) Matchers.hasItem(org.hamcrest.Matchers.hasItem) MockServer.getInstancesSearches(org.folio.rest.impl.MockServer.getInstancesSearches) PoLineCommonUtil.getPhysicalCostQuantity(org.folio.orders.utils.PoLineCommonUtil.getPhysicalCostQuantity) ITEM_STATUS_NAME(org.folio.service.inventory.InventoryManager.ITEM_STATUS_NAME) INSTANCE_TITLE(org.folio.service.inventory.InventoryManager.INSTANCE_TITLE) MockServer.getItemsSearches(org.folio.rest.impl.MockServer.getItemsSearches) ITEM_PERMANENT_LOAN_TYPE_ID(org.folio.service.inventory.InventoryManager.ITEM_PERMANENT_LOAN_TYPE_ID) INSTANCE_STATUS_ID(org.folio.service.inventory.InventoryManager.INSTANCE_STATUS_ID) MockServer.getPurchaseOrderRetrievals(org.folio.rest.impl.MockServer.getPurchaseOrderRetrievals) PoLine(org.folio.rest.jaxrs.model.PoLine) MockServer.getPurchaseOrderUpdates(org.folio.rest.impl.MockServer.getPurchaseOrderUpdates) MockServer.getCreatedItems(org.folio.rest.impl.MockServer.getCreatedItems) ITEM_STATUS(org.folio.service.inventory.InventoryManager.ITEM_STATUS) Location(org.folio.rest.jaxrs.model.Location) CONFIGS(org.folio.orders.utils.HelperUtils.CONFIGS) CONTRIBUTOR_NAME(org.folio.service.inventory.InventoryManager.CONTRIBUTOR_NAME) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) PoLineCommonUtil.getElectronicCostQuantity(org.folio.orders.utils.PoLineCommonUtil.getElectronicCostQuantity) Optional(java.util.Optional) INSTANCE_SOURCE(org.folio.service.inventory.InventoryManager.INSTANCE_SOURCE) INSTANCE_TYPE_ID(org.folio.service.inventory.InventoryManager.INSTANCE_TYPE_ID) INSTANCE_IDENTIFIER_TYPE_ID(org.folio.service.inventory.InventoryManager.INSTANCE_IDENTIFIER_TYPE_ID) INSTANCE_PUBLICATION(org.folio.service.inventory.InventoryManager.INSTANCE_PUBLICATION) ID(org.folio.service.inventory.InventoryManager.ID) MockServer.getCreatedInstances(org.folio.rest.impl.MockServer.getCreatedInstances) TestUtils.getMockData(org.folio.TestUtils.getMockData) MockServer.getCreatedPieces(org.folio.rest.impl.MockServer.getCreatedPieces) ITEM_HOLDINGS_RECORD_ID(org.folio.service.inventory.InventoryManager.ITEM_HOLDINGS_RECORD_ID) ITEM_PURCHASE_ORDER_LINE_IDENTIFIER(org.folio.service.inventory.InventoryManager.ITEM_PURCHASE_ORDER_LINE_IDENTIFIER) INSTANCE_IDENTIFIER_TYPE_VALUE(org.folio.service.inventory.InventoryManager.INSTANCE_IDENTIFIER_TYPE_VALUE) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) CONFIG_VALUE(org.folio.orders.utils.HelperUtils.CONFIG_VALUE) INSTANCE_TYPES(org.folio.service.inventory.InventoryManager.INSTANCE_TYPES) ReceivedItem(org.folio.rest.jaxrs.model.ReceivedItem) CONFIG_MOCK_PATH(org.folio.rest.impl.MockServer.CONFIG_MOCK_PATH) HOLDING_INSTANCE_ID(org.folio.service.inventory.InventoryManager.HOLDING_INSTANCE_ID) MockServer.getPoLineSearches(org.folio.rest.impl.MockServer.getPoLineSearches) PoLineCommonUtil.groupLocationsByLocationId(org.folio.orders.utils.PoLineCommonUtil.groupLocationsByLocationId) MockServer.getPoLineUpdates(org.folio.rest.impl.MockServer.getPoLineUpdates) DEFAULT_INSTANCE_TYPE_CODE(org.folio.service.inventory.InventoryManager.DEFAULT_INSTANCE_TYPE_CODE) LogManager(org.apache.logging.log4j.LogManager) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) JsonObject(io.vertx.core.json.JsonObject) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) Piece(org.folio.rest.jaxrs.model.Piece) ArrayList(java.util.ArrayList) List(java.util.List) PieceUtil.calculatePiecesQuantityWithoutLocation(org.folio.service.pieces.PieceUtil.calculatePiecesQuantityWithoutLocation) Location(org.folio.rest.jaxrs.model.Location)

Example 3 with HOLDING_PERMANENT_LOCATION_ID

use of org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID in project mod-orders by folio-org.

the class InventoryManagerTest method shouldCheckIfTheHoldingExistsWhenLocationIdAlwaysNewHoldingShouldBeCreated.

@Test
void shouldCheckIfTheHoldingExistsWhenLocationIdAlwaysNewHoldingShouldBeCreated() throws IOException {
    String instanceId = UUID.randomUUID().toString();
    JsonObject holdingsCollection = new JsonObject(getMockData(HOLDINGS_OLD_NEW_PATH));
    String holdingIdExp = extractId(getFirstObjectFromResponse(holdingsCollection, HOLDINGS_RECORDS));
    List<JsonObject> holdings = holdingsCollection.getJsonArray(HOLDINGS_RECORDS).stream().map(o -> ((JsonObject) o)).collect(toList());
    List<String> locationIds = holdings.stream().map(holding -> holding.getString(HOLDING_PERMANENT_LOCATION_ID)).collect(toList());
    Location location = new Location().withLocationId(locationIds.get(0)).withQuantity(1).withQuantityPhysical(1);
    doReturn(completedFuture(holdingIdExp)).when(restClient).post(any(RequestEntry.class), any(JsonObject.class), eq(PostResponseType.UUID), eq(String.class), eq(requestContext));
    String holdingIdAct = inventoryManager.getOrCreateHoldingsRecord(instanceId, location, requestContext).join();
    assertThat(holdingIdAct, equalTo(holdingIdExp));
    verify(restClient, times(1)).post(any(RequestEntry.class), any(JsonObject.class), eq(PostResponseType.UUID), eq(String.class), eq(requestContext));
}
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) JsonObject(io.vertx.core.json.JsonObject) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RequestEntry(org.folio.rest.core.models.RequestEntry) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 4 with HOLDING_PERMANENT_LOCATION_ID

use of org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID in project mod-orders by folio-org.

the class PieceDeleteFlowManagerTest method shouldNotUpdateLineQuantityIfPoLineIsPackageAndShouldDeleteHoldingAndItemAndPiece.

@Test
void shouldNotUpdateLineQuantityIfPoLineIsPackageAndShouldDeleteHoldingAndItemAndPiece() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String holdingId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    JsonObject item = new JsonObject().put(ID, itemId);
    item.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, ItemStatus.ON_ORDER.value()));
    JsonObject holding = new JsonObject().put(ID, holdingId);
    holding.put(HOLDING_PERMANENT_LOCATION_ID, locationId);
    Piece piece = new Piece().withId(UUID.randomUUID().toString()).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(holdingId).withFormat(Piece.Format.ELECTRONIC);
    Cost cost = new Cost().withQuantityElectronic(1).withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
    PoLine poLine = new PoLine().withIsPackage(true).withPurchaseOrderId(orderId).withId(lineId).withLocations(List.of(loc)).withCost(cost);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    doReturn(completedFuture(piece)).when(pieceStorageService).getPieceById(piece.getId(), requestContext);
    doReturn(completedFuture(null)).when(protectionService).isOperationRestricted(any(List.class), any(ProtectedOperationType.class), eq(requestContext));
    doReturn(completedFuture(null)).when(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    doReturn(completedFuture(null)).when(inventoryManager).getNumberOfRequestsByItemId(eq(piece.getItemId()), eq(requestContext));
    doReturn(completedFuture(item)).when(inventoryManager).getItemRecordById(itemId, true, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).deleteItem(itemId, true, requestContext);
    final ArgumentCaptor<PieceDeletionHolder> PieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class);
    doAnswer((Answer<CompletableFuture<Void>>) invocation -> {
        PieceDeletionHolder answerHolder = invocation.getArgument(0);
        answerHolder.withOrderInformation(purchaseOrder, poLine);
        return completedFuture(null);
    }).when(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(PieceDeletionHolderCapture.capture(), eq(requestContext));
    doReturn(completedFuture(holding)).when(inventoryManager).getHoldingById(holdingId, true, requestContext);
    doReturn(completedFuture(null)).when(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext);
    doReturn(completedFuture(new ArrayList())).when(inventoryManager).getItemsByHoldingId(holdingId, requestContext);
    final ArgumentCaptor<PieceDeletionHolder> pieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class);
    doReturn(completedFuture(null)).when(pieceDeleteFlowPoLineService).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext));
    // When
    pieceDeleteFlowManager.deletePiece(piece.getId(), true, requestContext).get();
    // Then
    PieceDeletionHolder holder = PieceDeletionHolderCapture.getValue();
    assertNull(poLine.getLocations().get(0).getLocationId());
    assertEquals(holdingId, poLine.getLocations().get(0).getHoldingId());
    verify(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    verify(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext);
    // Then
    assertNull(poLine.getLocations().get(0).getLocationId());
    assertEquals(holdingId, poLine.getLocations().get(0).getHoldingId());
    verify(pieceDeleteFlowPoLineService, times(0)).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext));
    verify(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(holder, requestContext);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Cost(org.folio.rest.jaxrs.model.Cost) TestConfig.getVertx(org.folio.TestConfig.getVertx) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) TimeoutException(java.util.concurrent.TimeoutException) Autowired(org.springframework.beans.factory.annotation.Autowired) PoLine(org.folio.rest.jaxrs.model.PoLine) Context(io.vertx.core.Context) ApiTestSuite(org.folio.ApiTestSuite) AfterAll(org.junit.jupiter.api.AfterAll) MockitoAnnotations(org.mockito.MockitoAnnotations) ITEM_STATUS(org.folio.service.inventory.InventoryManager.ITEM_STATUS) ProtectionService(org.folio.service.ProtectionService) BeforeAll(org.junit.jupiter.api.BeforeAll) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) Spy(org.mockito.Spy) JsonObject(io.vertx.core.json.JsonObject) Mockito.doReturn(org.mockito.Mockito.doReturn) PieceStorageService(org.folio.service.pieces.PieceStorageService) ID(org.folio.TestConstants.ID) ItemStatus(org.folio.models.ItemStatus) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) Location(org.folio.rest.jaxrs.model.Location) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) BasePieceFlowHolderBuilder(org.folio.service.pieces.flows.BasePieceFlowHolderBuilder) UUID(java.util.UUID) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) Test(org.junit.jupiter.api.Test) List(java.util.List) Eresource(org.folio.rest.jaxrs.model.Eresource) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestConfig.getFirstContextFromVertx(org.folio.TestConfig.getFirstContextFromVertx) Mock(org.mockito.Mock) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CompletableFuture(java.util.concurrent.CompletableFuture) TestConfig.clearVertxContext(org.folio.TestConfig.clearVertxContext) ArrayList(java.util.ArrayList) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) RequestContext(org.folio.rest.core.models.RequestContext) PieceUpdateInventoryService(org.folio.service.pieces.PieceUpdateInventoryService) HOLDING_PERMANENT_LOCATION_ID(org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID) TestConfig.autowireDependencies(org.folio.TestConfig.autowireDependencies) InventoryManager(org.folio.service.inventory.InventoryManager) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PieceDeletionHolder(org.folio.models.pieces.PieceDeletionHolder) Piece(org.folio.rest.jaxrs.model.Piece) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) Mockito.times(org.mockito.Mockito.times) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) Mockito(org.mockito.Mockito) AfterEach(org.junit.jupiter.api.AfterEach) Bean(org.springframework.context.annotation.Bean) ITEM_STATUS_NAME(org.folio.service.inventory.InventoryManager.ITEM_STATUS_NAME) PieceDeletionHolder(org.folio.models.pieces.PieceDeletionHolder) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) Cost(org.folio.rest.jaxrs.model.Cost) CompletableFuture(java.util.concurrent.CompletableFuture) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) List(java.util.List) ArrayList(java.util.ArrayList) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 5 with HOLDING_PERMANENT_LOCATION_ID

use of org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID in project mod-orders by folio-org.

the class PieceDeleteFlowManagerTest method shouldNotUpdateLineQuantityIfPoLineIsNotPackageAndManualPieceCreateTrueAndDeleteHoldingAndItemAndPiece.

@Test
void shouldNotUpdateLineQuantityIfPoLineIsNotPackageAndManualPieceCreateTrueAndDeleteHoldingAndItemAndPiece() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String holdingId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    JsonObject item = new JsonObject().put(ID, itemId);
    item.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, ItemStatus.ON_ORDER.value()));
    JsonObject holding = new JsonObject().put(ID, holdingId);
    holding.put(HOLDING_PERMANENT_LOCATION_ID, locationId);
    Piece piece = new Piece().withId(UUID.randomUUID().toString()).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(holdingId).withFormat(Piece.Format.ELECTRONIC);
    Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1).withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    PoLine poLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withLocations(List.of(loc)).withCost(cost).withCheckinItems(true);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    doReturn(completedFuture(piece)).when(pieceStorageService).getPieceById(piece.getId(), requestContext);
    doReturn(completedFuture(null)).when(protectionService).isOperationRestricted(any(List.class), any(ProtectedOperationType.class), eq(requestContext));
    doReturn(completedFuture(null)).when(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    doReturn(completedFuture(null)).when(inventoryManager).getNumberOfRequestsByItemId(eq(piece.getItemId()), eq(requestContext));
    doReturn(completedFuture(item)).when(inventoryManager).getItemRecordById(itemId, true, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).deleteItem(itemId, true, requestContext);
    doReturn(completedFuture(holding)).when(inventoryManager).getHoldingById(holdingId, true, requestContext);
    doReturn(completedFuture(null)).when(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext);
    doReturn(completedFuture(new ArrayList())).when(inventoryManager).getItemsByHoldingId(holdingId, requestContext);
    final ArgumentCaptor<PieceDeletionHolder> PieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class);
    doAnswer((Answer<CompletableFuture<Void>>) invocation -> {
        PieceDeletionHolder answerHolder = invocation.getArgument(0);
        answerHolder.withOrderInformation(purchaseOrder, poLine);
        return completedFuture(null);
    }).when(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(PieceDeletionHolderCapture.capture(), eq(requestContext));
    final ArgumentCaptor<PieceDeletionHolder> pieceDeletionHolderCapture = ArgumentCaptor.forClass(PieceDeletionHolder.class);
    doReturn(completedFuture(null)).when(pieceDeleteFlowPoLineService).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext));
    // When
    pieceDeleteFlowManager.deletePiece(piece.getId(), true, requestContext).get();
    // Then
    PieceDeletionHolder holder = PieceDeletionHolderCapture.getValue();
    assertNull(poLine.getLocations().get(0).getLocationId());
    assertEquals(holdingId, poLine.getLocations().get(0).getHoldingId());
    verify(pieceStorageService).deletePiece(eq(piece.getId()), eq(true), eq(requestContext));
    verify(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(piece, requestContext);
    verify(inventoryManager).deleteItem(itemId, true, requestContext);
    verify(pieceDeleteFlowPoLineService, times(0)).updatePoLine(pieceDeletionHolderCapture.capture(), eq(requestContext));
    verify(basePieceFlowHolderBuilder).updateHolderWithOrderInformation(holder, requestContext);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Cost(org.folio.rest.jaxrs.model.Cost) TestConfig.getVertx(org.folio.TestConfig.getVertx) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) TimeoutException(java.util.concurrent.TimeoutException) Autowired(org.springframework.beans.factory.annotation.Autowired) PoLine(org.folio.rest.jaxrs.model.PoLine) Context(io.vertx.core.Context) ApiTestSuite(org.folio.ApiTestSuite) AfterAll(org.junit.jupiter.api.AfterAll) MockitoAnnotations(org.mockito.MockitoAnnotations) ITEM_STATUS(org.folio.service.inventory.InventoryManager.ITEM_STATUS) ProtectionService(org.folio.service.ProtectionService) BeforeAll(org.junit.jupiter.api.BeforeAll) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) Spy(org.mockito.Spy) JsonObject(io.vertx.core.json.JsonObject) Mockito.doReturn(org.mockito.Mockito.doReturn) PieceStorageService(org.folio.service.pieces.PieceStorageService) ID(org.folio.TestConstants.ID) ItemStatus(org.folio.models.ItemStatus) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) Location(org.folio.rest.jaxrs.model.Location) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) BasePieceFlowHolderBuilder(org.folio.service.pieces.flows.BasePieceFlowHolderBuilder) UUID(java.util.UUID) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) Test(org.junit.jupiter.api.Test) List(java.util.List) Eresource(org.folio.rest.jaxrs.model.Eresource) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestConfig.getFirstContextFromVertx(org.folio.TestConfig.getFirstContextFromVertx) Mock(org.mockito.Mock) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CompletableFuture(java.util.concurrent.CompletableFuture) TestConfig.clearVertxContext(org.folio.TestConfig.clearVertxContext) ArrayList(java.util.ArrayList) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) RequestContext(org.folio.rest.core.models.RequestContext) PieceUpdateInventoryService(org.folio.service.pieces.PieceUpdateInventoryService) HOLDING_PERMANENT_LOCATION_ID(org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID) TestConfig.autowireDependencies(org.folio.TestConfig.autowireDependencies) InventoryManager(org.folio.service.inventory.InventoryManager) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PieceDeletionHolder(org.folio.models.pieces.PieceDeletionHolder) Piece(org.folio.rest.jaxrs.model.Piece) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) Mockito.times(org.mockito.Mockito.times) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) Mockito(org.mockito.Mockito) AfterEach(org.junit.jupiter.api.AfterEach) Bean(org.springframework.context.annotation.Bean) ITEM_STATUS_NAME(org.folio.service.inventory.InventoryManager.ITEM_STATUS_NAME) PieceDeletionHolder(org.folio.models.pieces.PieceDeletionHolder) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) Cost(org.folio.rest.jaxrs.model.Cost) CompletableFuture(java.util.concurrent.CompletableFuture) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) List(java.util.List) ArrayList(java.util.ArrayList) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)12 List (java.util.List)12 Map (java.util.Map)12 Location (org.folio.rest.jaxrs.model.Location)12 Piece (org.folio.rest.jaxrs.model.Piece)12 HOLDING_PERMANENT_LOCATION_ID (org.folio.service.inventory.InventoryManager.HOLDING_PERMANENT_LOCATION_ID)12 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)12 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)12 Context (io.vertx.core.Context)10 UUID (java.util.UUID)10 CompletableFuture (java.util.concurrent.CompletableFuture)10 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)10 ExecutionException (java.util.concurrent.ExecutionException)10 TimeoutException (java.util.concurrent.TimeoutException)10 ApiTestSuite (org.folio.ApiTestSuite)10 TestConfig.autowireDependencies (org.folio.TestConfig.autowireDependencies)10 TestConfig.clearServiceInteractions (org.folio.TestConfig.clearServiceInteractions)10 TestConfig.clearVertxContext (org.folio.TestConfig.clearVertxContext)10 TestConfig.getFirstContextFromVertx (org.folio.TestConfig.getFirstContextFromVertx)10 TestConfig.getVertx (org.folio.TestConfig.getVertx)10