Search in sources :

Example 21 with Physical

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

the class PieceUpdateFlowInventoryManagerTest method shouldDeleteHoldingWhenPhysPieceUpdateForNonPackagePoLineWithCreateInventoryAllAndPieceContainsNewHoldingAndLineWithInstanceId.

@Test
void shouldDeleteHoldingWhenPhysPieceUpdateForNonPackagePoLineWithCreateInventoryAllAndPieceContainsNewHoldingAndLineWithInstanceId() {
    String orderId = UUID.randomUUID().toString();
    String holdingFromStorageId = UUID.randomUUID().toString();
    String holdingId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String pieceId = UUID.randomUUID().toString();
    String instanceId = UUID.randomUUID().toString();
    JsonObject holding = new JsonObject().put(ID, holdingFromStorageId);
    holding.put(HOLDING_PERMANENT_LOCATION_ID, UUID.randomUUID().toString());
    Piece pieceFromStorage = new Piece().withId(pieceId).withTitleId(titleId).withItemId(itemId).withPoLineId(lineId).withHoldingId(holdingFromStorageId).withFormat(Piece.Format.PHYSICAL);
    Piece pieceToUpdate = new Piece().withId(pieceId).withTitleId(titleId).withItemId(itemId).withPoLineId(lineId).withHoldingId(holdingId).withFormat(Piece.Format.PHYSICAL);
    Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1);
    PoLine poLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withInstanceId(instanceId).withOrderFormat(PoLine.OrderFormat.PHYSICAL_RESOURCE).withId(lineId).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM)).withLocations(List.of(loc)).withCost(cost);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    PieceUpdateHolder holder = new PieceUpdateHolder().withPieceToUpdate(pieceToUpdate).withPieceFromStorage(pieceFromStorage).withCreateItem(true).withDeleteHolding(true);
    holder.withOrderInformation(purchaseOrder, poLine);
    doReturn(completedFuture(new JsonObject())).when(inventoryManager).getItemRecordById(pieceToUpdate.getItemId(), true, requestContext);
    doReturn(completedFuture(List.of(itemId))).when(inventoryManager).createMissingPhysicalItems(holder.getPoLineToSave(), pieceToUpdate, 1, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).updateItemWithPieceFields(holder.getPieceToUpdate(), requestContext);
    doReturn(completedFuture(holding)).when(inventoryManager).getHoldingById(holder.getPieceFromStorage().getHoldingId(), true, requestContext);
    doReturn(completedFuture(new ArrayList())).when(inventoryManager).getItemsByHoldingId(holder.getPieceFromStorage().getHoldingId(), requestContext);
    doReturn(completedFuture(null)).when(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(holder.getPieceFromStorage(), requestContext);
    doReturn(completedFuture(itemId)).when(pieceUpdateInventoryService).manualPieceFlowCreateItemRecord(pieceToUpdate, holder.getPoLineToSave(), requestContext);
    pieceUpdateFlowInventoryManager.processInventory(holder, requestContext).join();
    verify(titlesService, times(0)).getTitleById(pieceToUpdate.getTitleId(), requestContext);
    verify(inventoryManager, times(0)).getOrCreateHoldingsRecord(eq(holder.getInstanceId()), any(Location.class), eq(requestContext));
    verify(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(holder.getPieceFromStorage(), requestContext);
    verify(inventoryManager).updateItemWithPieceFields(holder.getPieceToUpdate(), requestContext);
    verify(pieceUpdateInventoryService).manualPieceFlowCreateItemRecord(pieceToUpdate, holder.getPoLineToSave(), requestContext);
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PieceUpdateHolder(org.folio.models.pieces.PieceUpdateHolder) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) Cost(org.folio.rest.jaxrs.model.Cost) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 22 with Physical

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

the class PieceUpdateFlowInventoryManagerTest method shouldUpdateItemWithNewHoldingIdWhenPhysPieceUpdateForNonPackagePoLineWithCreateInventoryAllAndPieceContainsNewHoldingAndLineWithInstanceId.

@Test
void shouldUpdateItemWithNewHoldingIdWhenPhysPieceUpdateForNonPackagePoLineWithCreateInventoryAllAndPieceContainsNewHoldingAndLineWithInstanceId() {
    String orderId = UUID.randomUUID().toString();
    String holdingFromStorageId = UUID.randomUUID().toString();
    String holdingId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String pieceId = UUID.randomUUID().toString();
    String instanceId = UUID.randomUUID().toString();
    JsonObject item = new JsonObject().put(ID, itemId);
    item.put(ITEM_STATUS, new JsonObject().put(ITEM_STATUS_NAME, ItemStatus.ON_ORDER.value()));
    item.put(ITEM_HOLDINGS_RECORD_ID, holdingFromStorageId);
    JsonObject holding = new JsonObject().put(ID, holdingFromStorageId);
    holding.put(HOLDING_PERMANENT_LOCATION_ID, UUID.randomUUID().toString());
    Piece pieceFromStorage = new Piece().withId(pieceId).withTitleId(titleId).withItemId(itemId).withPoLineId(lineId).withHoldingId(holdingFromStorageId).withFormat(Piece.Format.PHYSICAL);
    Piece pieceToUpdate = new Piece().withId(pieceId).withTitleId(titleId).withItemId(itemId).withPoLineId(lineId).withHoldingId(holdingId).withFormat(Piece.Format.PHYSICAL);
    Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1);
    PoLine poLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withInstanceId(instanceId).withOrderFormat(PoLine.OrderFormat.PHYSICAL_RESOURCE).withId(lineId).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM)).withLocations(List.of(loc)).withCost(cost);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    PieceUpdateHolder holder = new PieceUpdateHolder().withPieceToUpdate(pieceToUpdate).withPieceFromStorage(pieceFromStorage).withCreateItem(true).withDeleteHolding(true);
    holder.withOrderInformation(purchaseOrder, poLine);
    doReturn(completedFuture(item)).when(inventoryManager).getItemRecordById(pieceToUpdate.getItemId(), true, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).updateItem(item, requestContext);
    doReturn(completedFuture(List.of(itemId))).when(inventoryManager).createMissingPhysicalItems(holder.getPoLineToSave(), pieceToUpdate, 1, requestContext);
    doReturn(completedFuture(null)).when(inventoryManager).updateItemWithPieceFields(holder.getPieceToUpdate(), requestContext);
    doReturn(completedFuture(holding)).when(inventoryManager).getHoldingById(holder.getPieceFromStorage().getHoldingId(), true, requestContext);
    doReturn(completedFuture(new ArrayList())).when(inventoryManager).getItemsByHoldingId(holder.getPieceFromStorage().getHoldingId(), requestContext);
    doReturn(completedFuture(null)).when(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(holder.getPieceFromStorage(), requestContext);
    pieceUpdateFlowInventoryManager.processInventory(holder, requestContext).join();
    assertEquals(holdingId, item.getString(ITEM_HOLDINGS_RECORD_ID));
    assertEquals(holder.getPoLineToSave().getId(), item.getString(ITEM_PURCHASE_ORDER_LINE_IDENTIFIER));
    verify(titlesService, times(0)).getTitleById(pieceToUpdate.getTitleId(), requestContext);
    verify(inventoryManager, times(0)).getOrCreateHoldingsRecord(eq(holder.getInstanceId()), any(Location.class), eq(requestContext));
    verify(pieceUpdateInventoryService).deleteHoldingConnectedToPiece(holder.getPieceFromStorage(), requestContext);
    verify(inventoryManager).updateItemWithPieceFields(holder.getPieceToUpdate(), requestContext);
    verify(pieceUpdateInventoryService, times(0)).manualPieceFlowCreateItemRecord(pieceToUpdate, holder.getPoLineToSave(), requestContext);
    verify(inventoryManager).updateItem(item, requestContext);
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PieceUpdateHolder(org.folio.models.pieces.PieceUpdateHolder) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) Cost(org.folio.rest.jaxrs.model.Cost) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 23 with Physical

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

the class PieceUpdateFlowPoLineServiceTest method shouldUpdateLineQuantityWithAddNeHoldingIfMixedPoLineIsNotPackageAndHoldingReferenceChanged.

@Test
void shouldUpdateLineQuantityWithAddNeHoldingIfMixedPoLineIsNotPackageAndHoldingReferenceChanged() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String oldHoldingId = UUID.randomUUID().toString();
    String holdingToUpdate = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String pieceId = UUID.randomUUID().toString();
    Piece pieceFromStorage = new Piece().withId(pieceId).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(oldHoldingId).withFormat(Piece.Format.ELECTRONIC);
    Piece pieceToUpdate = new Piece().withId(pieceId).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(holdingToUpdate).withFormat(Piece.Format.ELECTRONIC);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    Location loc = new Location().withHoldingId(oldHoldingId).withQuantityPhysical(1).withQuantityElectronic(1).withQuantity(2);
    PoLine poLineFromStorage = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withEresource(new Eresource().withCreateInventory(INSTANCE_HOLDING)).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM)).withLocations(List.of(loc)).withCost(cost);
    PurchaseOrder purchaseOrderFromStorage = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    PieceUpdateHolder incomingUpdateHolder = new PieceUpdateHolder().withPieceToUpdate(pieceToUpdate).withPieceFromStorage(pieceFromStorage);
    incomingUpdateHolder.withOrderInformation(purchaseOrderFromStorage, poLineFromStorage);
    ArgumentCaptor<CompositePoLine> poLineToSaveCapture = ArgumentCaptor.forClass(CompositePoLine.class);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(poLineToSaveCapture.capture(), eq(requestContext));
    // When
    pieceUpdateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToUpdate = poLineToSaveCapture.getValue();
    assertEquals(holdingToUpdate, pieceToUpdate.getHoldingId());
    assertNull(pieceToUpdate.getLocationId());
    List<Location> locations = poLineToUpdate.getLocations();
    assertEquals(2, locations.size());
    Location physicalLocationToSave = poLineToUpdate.getLocations().stream().filter(location -> location.getQuantityPhysical() != null).findAny().get();
    assertNull(physicalLocationToSave.getQuantityElectronic());
    assertNull(physicalLocationToSave.getLocationId());
    assertEquals(1, physicalLocationToSave.getQuantity());
    assertEquals(oldHoldingId, physicalLocationToSave.getHoldingId());
    Location elecLocationToSave = poLineToUpdate.getLocations().stream().filter(location -> location.getQuantityElectronic() != null).findAny().get();
    assertNull(elecLocationToSave.getQuantityPhysical());
    assertNull(elecLocationToSave.getLocationId());
    assertEquals(1, elecLocationToSave.getQuantity());
    assertEquals(holdingToUpdate, elecLocationToSave.getHoldingId());
    Cost costToSave = poLineToUpdate.getCost();
    assertEquals(1, costToSave.getQuantityElectronic());
    assertEquals(1, costToSave.getQuantityPhysical());
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PieceUpdateHolder(org.folio.models.pieces.PieceUpdateHolder) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 24 with Physical

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

the class PieceUpdateFlowPoLineServiceTest method shouldUpdateLineQuantityWithAddNeHoldingIfMixedPoLineWith2LocationsIsNotPackageAndHoldingReferenceChanged.

@Test
void shouldUpdateLineQuantityWithAddNeHoldingIfMixedPoLineWith2LocationsIsNotPackageAndHoldingReferenceChanged() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String oldHoldingId = UUID.randomUUID().toString();
    String holdingToUpdate = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String pieceId = UUID.randomUUID().toString();
    Piece pieceFromStorage = new Piece().withId(pieceId).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(oldHoldingId).withFormat(Piece.Format.ELECTRONIC);
    Piece pieceToUpdate = new Piece().withId(pieceId).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(holdingToUpdate).withFormat(Piece.Format.ELECTRONIC);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(2d);
    Location loc1 = new Location().withHoldingId(oldHoldingId).withQuantityElectronic(1).withQuantity(1);
    Location loc2 = new Location().withHoldingId(oldHoldingId).withQuantityPhysical(1).withQuantity(1);
    PoLine poLineFromStorage = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withEresource(new Eresource().withCreateInventory(INSTANCE_HOLDING)).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM)).withLocations(List.of(loc1, loc2)).withCost(cost);
    PurchaseOrder purchaseOrderFromStorage = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    PieceUpdateHolder incomingUpdateHolder = new PieceUpdateHolder().withPieceToUpdate(pieceToUpdate).withPieceFromStorage(pieceFromStorage);
    incomingUpdateHolder.withOrderInformation(purchaseOrderFromStorage, poLineFromStorage);
    ArgumentCaptor<CompositePoLine> poLineToSaveCapture = ArgumentCaptor.forClass(CompositePoLine.class);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(poLineToSaveCapture.capture(), eq(requestContext));
    // When
    pieceUpdateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToUpdate = poLineToSaveCapture.getValue();
    assertEquals(holdingToUpdate, pieceToUpdate.getHoldingId());
    assertNull(pieceToUpdate.getLocationId());
    List<Location> locations = poLineToUpdate.getLocations();
    assertEquals(2, locations.size());
    Location physicalLocationToSave = poLineToUpdate.getLocations().stream().filter(location -> location.getQuantityPhysical() != null).findAny().get();
    assertNull(physicalLocationToSave.getQuantityElectronic());
    assertNull(physicalLocationToSave.getLocationId());
    assertEquals(1, physicalLocationToSave.getQuantity());
    assertEquals(oldHoldingId, physicalLocationToSave.getHoldingId());
    Location elecLocationToSave = poLineToUpdate.getLocations().stream().filter(location -> location.getQuantityElectronic() != null).findAny().get();
    assertNull(elecLocationToSave.getQuantityPhysical());
    assertNull(elecLocationToSave.getLocationId());
    assertEquals(1, elecLocationToSave.getQuantity());
    assertEquals(holdingToUpdate, elecLocationToSave.getHoldingId());
    Cost costToSave = poLineToUpdate.getCost();
    assertEquals(1, costToSave.getQuantityElectronic());
    assertEquals(1, costToSave.getQuantityPhysical());
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PieceUpdateHolder(org.folio.models.pieces.PieceUpdateHolder) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Example 25 with Physical

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

the class PieceUpdateFlowPoLineServiceTest method shouldUpdateLineQuantityWithAddNeLocationIfMixedPoLineIsNotPackageAndLocationReferenceChanged.

@Test
void shouldUpdateLineQuantityWithAddNeLocationIfMixedPoLineIsNotPackageAndLocationReferenceChanged() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String oldHoldingId = UUID.randomUUID().toString();
    String locationToUpdate = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    String titleId = UUID.randomUUID().toString();
    String itemId = UUID.randomUUID().toString();
    String pieceId = UUID.randomUUID().toString();
    Piece pieceFromStorage = new Piece().withId(pieceId).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withHoldingId(oldHoldingId).withFormat(Piece.Format.ELECTRONIC);
    Piece pieceToUpdate = new Piece().withId(pieceId).withPoLineId(lineId).withItemId(itemId).withTitleId(titleId).withLocationId(locationToUpdate).withFormat(Piece.Format.ELECTRONIC);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withListUnitPriceElectronic(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    Location loc = new Location().withHoldingId(oldHoldingId).withQuantityPhysical(1).withQuantityElectronic(1).withQuantity(2);
    PoLine poLineFromStorage = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withId(lineId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withEresource(new Eresource().withCreateInventory(INSTANCE)).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM)).withLocations(List.of(loc)).withCost(cost);
    PurchaseOrder purchaseOrderFromStorage = new PurchaseOrder().withId(orderId).withWorkflowStatus(PurchaseOrder.WorkflowStatus.OPEN);
    PieceUpdateHolder incomingUpdateHolder = new PieceUpdateHolder().withPieceToUpdate(pieceToUpdate).withPieceFromStorage(pieceFromStorage);
    incomingUpdateHolder.withOrderInformation(purchaseOrderFromStorage, poLineFromStorage);
    ArgumentCaptor<CompositePoLine> poLineToSaveCapture = ArgumentCaptor.forClass(CompositePoLine.class);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(poLineToSaveCapture.capture(), eq(requestContext));
    // When
    pieceUpdateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToUpdate = poLineToSaveCapture.getValue();
    assertEquals(locationToUpdate, pieceToUpdate.getLocationId());
    assertNull(pieceToUpdate.getHoldingId());
    List<Location> locations = poLineToUpdate.getLocations();
    assertEquals(2, locations.size());
    Location physicalLocationToSave = poLineToUpdate.getLocations().stream().filter(location -> location.getQuantityPhysical() != null).findAny().get();
    assertNull(physicalLocationToSave.getQuantityElectronic());
    assertNull(physicalLocationToSave.getLocationId());
    assertEquals(1, physicalLocationToSave.getQuantity());
    assertEquals(oldHoldingId, physicalLocationToSave.getHoldingId());
    Location elecLocationToSave = poLineToUpdate.getLocations().stream().filter(location -> location.getQuantityElectronic() != null).findAny().get();
    assertNull(elecLocationToSave.getQuantityPhysical());
    assertNull(elecLocationToSave.getHoldingId());
    assertEquals(1, elecLocationToSave.getQuantity());
    assertEquals(locationToUpdate, elecLocationToSave.getLocationId());
    Cost costToSave = poLineToUpdate.getCost();
    assertEquals(1, costToSave.getQuantityElectronic());
    assertEquals(1, costToSave.getQuantityPhysical());
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PieceUpdateHolder(org.folio.models.pieces.PieceUpdateHolder) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test)

Aggregations

Physical (org.folio.rest.jaxrs.model.Physical)54 Test (org.junit.jupiter.api.Test)51 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)43 Cost (org.folio.rest.jaxrs.model.Cost)42 Piece (org.folio.rest.jaxrs.model.Piece)42 Location (org.folio.rest.jaxrs.model.Location)39 PoLine (org.folio.rest.jaxrs.model.PoLine)28 PurchaseOrder (org.folio.rest.jaxrs.model.PurchaseOrder)27 Eresource (org.folio.rest.jaxrs.model.Eresource)25 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)24 ArrayList (java.util.ArrayList)23 JsonObject (io.vertx.core.json.JsonObject)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Title (org.folio.rest.jaxrs.model.Title)15 DisplayName (org.junit.jupiter.api.DisplayName)15 Context (io.vertx.core.Context)11 Collections (java.util.Collections)11 List (java.util.List)11 Map (java.util.Map)11 UUID (java.util.UUID)11