use of org.folio.rest.jaxrs.model.PoLine in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostReceivingRevertMixedResources.
@Test
void testPostReceivingRevertMixedResources() {
logger.info("=== Test POST Receiving - Revert received P/E Mix resources");
CompositePoLine poLines = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(5).mapTo(CompositePoLine.class);
MockServer.addMockTitles(Collections.singletonList(poLines));
ReceivingCollection receivingRq = getMockAsJson(RECEIVING_RQ_MOCK_DATA_PATH + "revert-pe-mix-4-of-5-resources.json").mapTo(ReceivingCollection.class);
ReceivingResults results = verifyPostResponse(ORDERS_RECEIVING_ENDPOINT, JsonObject.mapFrom(receivingRq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, 200).as(ReceivingResults.class);
assertThat(results.getTotalRecords(), equalTo(receivingRq.getTotalRecords()));
Map<String, Set<String>> pieceIdsByPol = verifyReceivingSuccessRs(results);
List<JsonObject> pieceSearches = getPieceSearches();
List<JsonObject> pieceUpdates = getPieceUpdates();
List<JsonObject> itemsSearches = getItemsSearches();
List<JsonObject> itemUpdates = getItemUpdates();
List<JsonObject> polSearches = getPoLineSearches();
List<JsonObject> polUpdates = getPoLineUpdates();
assertThat(pieceSearches, not(nullValue()));
assertThat(pieceUpdates, not(nullValue()));
assertThat(itemsSearches, not(nullValue()));
assertThat(itemUpdates, not(nullValue()));
assertThat(polSearches, not(nullValue()));
assertThat(polUpdates, not(nullValue()));
// The piece searches should be made 3 times: 1st time to get all required piece records, 2nd and 3rd times to calculate expected PO Line status
assertThat(pieceSearches, hasSize(3));
// In total 4 pieces required update
assertThat(pieceUpdates, hasSize(4));
assertThat(itemsSearches, hasSize(1));
// There are 3 piece records with item id's
assertThat(itemUpdates, hasSize(3));
assertThat(polSearches, hasSize(pieceIdsByPol.size()));
assertThat(polUpdates, hasSize(pieceIdsByPol.size()));
itemUpdates.forEach(item -> {
assertThat(item.getJsonObject(ITEM_STATUS), notNullValue());
assertThat(item.getString(ITEM_LEVEL_CALL_NUMBER), is(nullValue()));
assertThat(item.getJsonObject(ITEM_STATUS).getString(ITEM_STATUS_NAME), equalTo(ReceivedItem.ItemStatus.ON_ORDER.value()));
});
polUpdates.forEach(pol -> {
PoLine poLine = pol.mapTo(PoLine.class);
assertThat(poLine.getReceiptStatus(), is(PoLine.ReceiptStatus.PARTIALLY_RECEIVED));
assertThat(poLine.getReceiptDate(), is(nullValue()));
});
// Verify messages sent via event bus
verifyOrderStatusUpdateEvent(1);
}
Aggregations