use of org.folio.rest.jaxrs.model.CheckinCollection in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostCheckinMultipleTitlesError.
@Test
void testPostCheckinMultipleTitlesError() {
logger.info("=== Test POST check-in multiple titles error for non-packages ===");
CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder();
CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId());
poLine.setOrderFormat(CompositePoLine.OrderFormat.P_E_MIX);
poLine.setEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE_HOLDING_ITEM));
poLine.setPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING_ITEM));
String locationForPhysical = UUID.randomUUID().toString();
String locationForElectronic = UUID.randomUUID().toString();
String titleIdForPhysical = UUID.randomUUID().toString();
MockServer.addMockTitleWithId(poLine, titleIdForPhysical);
String titleIdForElectronic = UUID.randomUUID().toString();
MockServer.addMockTitleWithId(poLine, titleIdForElectronic);
Piece physicalPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.PHYSICAL).withLocationId(locationForPhysical).withId(UUID.randomUUID().toString()).withTitleId(titleIdForPhysical).withItemId(UUID.randomUUID().toString());
Piece electronicPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.EXPECTED).withFormat(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC).withId(UUID.randomUUID().toString()).withTitleId(titleIdForElectronic).withItemId(UUID.randomUUID().toString());
addMockEntry(PURCHASE_ORDER_STORAGE, order.withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN));
addMockEntry(PO_LINES_STORAGE, poLine);
addMockEntry(PIECES_STORAGE, physicalPiece);
addMockEntry(PIECES_STORAGE, electronicPiece);
List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>();
toBeCheckedInList.add(new ToBeCheckedIn().withCheckedIn(2).withPoLineId(poLine.getId()).withCheckInPieces(Arrays.asList(new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER), new CheckInPiece().withItemStatus(CheckInPiece.ItemStatus.ON_ORDER))));
CheckinCollection request = new CheckinCollection().withToBeCheckedIn(toBeCheckedInList).withTotalRecords(2);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setId(physicalPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(0).setLocationId(locationForPhysical);
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setId(electronicPiece.getId());
request.getToBeCheckedIn().get(0).getCheckInPieces().get(1).setLocationId(locationForElectronic);
Response response = verifyPostResponse(ORDERS_CHECKIN_ENDPOINT, JsonObject.mapFrom(request).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, HttpStatus.HTTP_BAD_REQUEST.toInt());
assertThat(response.as(Errors.class).getErrors().get(0).getMessage(), is(MULTIPLE_NONPACKAGE_TITLES.getDescription()));
}
use of org.folio.rest.jaxrs.model.CheckinCollection in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostCheckinRevertPhysicalResource.
@Test
void testPostCheckinRevertPhysicalResource() {
logger.info("=== Test POST Check-in - Revert received Physical resource");
CompositePoLine poLines = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(8).mapTo(CompositePoLine.class);
MockServer.addMockTitles(Collections.singletonList(poLines));
CheckinCollection checkinReq = getMockAsJson(CHECKIN_RQ_MOCK_DATA_PATH + "revert-checkin-physical-1-resource.json").mapTo(CheckinCollection.class);
ReceivingResults results = verifyPostResponse(ORDERS_CHECKIN_ENDPOINT, JsonObject.mapFrom(checkinReq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, 200).as(ReceivingResults.class);
assertThat(results.getTotalRecords(), equalTo(checkinReq.getTotalRecords()));
verifyReceivingSuccessRs(results);
List<JsonObject> pieceSearches = getPieceSearches();
List<JsonObject> pieceUpdates = getPieceUpdates();
List<JsonObject> itemsSearches = getItemsSearches();
List<JsonObject> itemUpdates = getItemUpdates();
List<JsonObject> polSearches = getPoLineSearches();
List<JsonObject> polUpdates = getPoLineUpdates();
assertThat(pieceSearches, not(nullValue()));
assertThat(pieceUpdates, not(nullValue()));
assertThat(itemsSearches, not(nullValue()));
assertThat(itemUpdates, not(nullValue()));
assertThat(polSearches, not(nullValue()));
assertThat(polUpdates, not(nullValue()));
// The piece searches should be made 2 times: 1st time to get piece record,
// 2nd time to calculate expected PO Line status
assertThat(pieceSearches, hasSize(3));
assertThat(pieceUpdates, hasSize(1));
assertThat(itemsSearches, hasSize(1));
assertThat(itemUpdates, hasSize(1));
assertThat(polSearches, hasSize(1));
assertThat(polUpdates, hasSize(1));
itemUpdates.forEach(item -> {
assertThat(item.getJsonObject(ITEM_STATUS), notNullValue());
assertThat(item.getString(ITEM_LEVEL_CALL_NUMBER), is(nullValue()));
assertThat(item.getJsonObject(ITEM_STATUS).getString(ITEM_STATUS_NAME), equalTo(ON_ORDER.value()));
});
polUpdates.forEach(pol -> {
PoLine poLine = pol.mapTo(PoLine.class);
assertThat(poLine.getCheckinItems(), is(true));
assertThat(poLine.getReceiptStatus(), is(PoLine.ReceiptStatus.AWAITING_RECEIPT));
assertThat(poLine.getReceiptDate(), is(nullValue()));
});
// Verify message is sent via event bus
verifyCheckinOrderStatusUpdateEvent(1);
}
use of org.folio.rest.jaxrs.model.CheckinCollection in project mod-orders by folio-org.
the class ReceivingCheckinProtectionTest method getCheckInCollection.
private static CheckinCollection getCheckInCollection(List<String> units) {
CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder().withAcqUnitIds(units).withId(getRandomId());
addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(order));
CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId()).withId(EXPECTED_FLOW_PO_LINE_ID);
addMockEntry(PO_LINES_STORAGE, JsonObject.mapFrom(poLine));
MockServer.addMockTitles(Collections.singletonList(poLine));
CheckinCollection toBeCheckedInRq = new CheckinCollection();
List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>(Arrays.asList(getToBeCheckedIn(poLine.getId(), EXPECTED_FLOW_PIECE_ID_1), getToBeCheckedIn(poLine.getId(), EXPECTED_FLOW_PIECE_ID_2)));
toBeCheckedInRq.setToBeCheckedIn(toBeCheckedInList);
toBeCheckedInRq.setTotalRecords(toBeCheckedInList.size());
return toBeCheckedInRq;
}
Aggregations