use of org.folio.rest.jaxrs.model.ReceivingResults 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.ReceivingResults in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostReceivingWithErrorSearchingForItem.
@Test
void testPostReceivingWithErrorSearchingForItem() {
logger.info("=== Test POST Receiving - Receive resources with error searching for item");
ReceivingCollection receivingRq = getMockAsJson(RECEIVING_RQ_MOCK_DATA_PATH + "receive-500-error-for-items-lookup.json").mapTo(ReceivingCollection.class);
receivingRq.getToBeReceived().forEach(toBeReceived -> {
CompositePoLine poLine = getMinimalContentCompositePoLine().withId(toBeReceived.getPoLineId());
addMockEntry(PO_LINES_STORAGE, poLine);
addMockTitles(Collections.singletonList(poLine));
});
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(), is(1));
assertThat(results.getReceivingResults(), hasSize(1));
ReceivingResult receivingResult = results.getReceivingResults().get(0);
assertThat(receivingResult.getPoLineId(), not(is(emptyString())));
assertThat(receivingResult.getProcessedSuccessfully(), is(0));
assertThat(receivingResult.getProcessedWithError(), is(1));
for (ReceivingItemResult receivingItemResult : receivingResult.getReceivingItemResults()) {
assertThat(receivingItemResult.getPieceId(), not(is(emptyString())));
assertThat(receivingItemResult.getProcessingStatus(), not(nullValue()));
assertThat(receivingItemResult.getProcessingStatus().getType(), is(ProcessingStatus.Type.FAILURE));
assertThat(receivingItemResult.getProcessingStatus().getError().getCode(), is(ITEM_NOT_RETRIEVED.getCode()));
}
assertThat(getPieceSearches(), not(nullValue()));
assertThat(getItemsSearches(), not(nullValue()));
assertThat(getPieceUpdates(), is(nullValue()));
assertThat(getItemUpdates(), is(nullValue()));
assertThat(getPoLineSearches(), not(nullValue()));
assertThat(getPoLineUpdates(), is(nullValue()));
// Verify messages sent via event bus
verifyOrderStatusUpdateEvent(0);
}
use of org.folio.rest.jaxrs.model.ReceivingResults in project mod-orders by folio-org.
the class CheckinReceivingApiTest method testPostReceivingWithErrorSearchingForPiece.
@Test
void testPostReceivingWithErrorSearchingForPiece() {
logger.info("=== Test POST Receiving - Receive resources with error searching for piece");
ReceivingCollection receivingRq = getMockAsJson(RECEIVING_RQ_MOCK_DATA_PATH + "receive-500-error-for-pieces-lookup.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(), is(1));
assertThat(results.getReceivingResults(), hasSize(1));
ReceivingResult receivingResult = results.getReceivingResults().get(0);
assertThat(receivingResult.getPoLineId(), not(is(emptyString())));
assertThat(receivingResult.getProcessedSuccessfully(), is(0));
assertThat(receivingResult.getProcessedWithError(), is(1));
for (ReceivingItemResult receivingItemResult : receivingResult.getReceivingItemResults()) {
assertThat(receivingItemResult.getPieceId(), not(is(emptyString())));
assertThat(receivingItemResult.getProcessingStatus(), not(nullValue()));
assertThat(receivingItemResult.getProcessingStatus().getType(), is(ProcessingStatus.Type.FAILURE));
assertThat(receivingItemResult.getProcessingStatus().getError().getCode(), is(PIECE_NOT_RETRIEVED.getCode()));
}
assertThat(getPieceSearches(), not(nullValue()));
assertThat(getPieceUpdates(), is(nullValue()));
assertThat(getItemsSearches(), is(nullValue()));
assertThat(getItemUpdates(), is(nullValue()));
assertThat(getPoLineSearches(), hasSize(1));
assertThat(getPoLineUpdates(), is(nullValue()));
// Verify messages sent via event bus
verifyOrderStatusUpdateEvent(0);
}
use of org.folio.rest.jaxrs.model.ReceivingResults 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);
}
use of org.folio.rest.jaxrs.model.ReceivingResults in project mod-orders by folio-org.
the class ReceivingCheckinProtectionTest method testFlowWithRestrictedUnitsAndAllowedUser.
@ParameterizedTest
@EnumSource(value = Entities.class)
void testFlowWithRestrictedUnitsAndAllowedUser(Entities entity) {
logger.info("=== Test check-in/receiving flow - protecting units and allowed user ===");
ReceivingResults results = verifyPostResponse(entity.getEndpoint(), entity.getJsonRequest(PROTECTED_UNITS), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_WITH_UNITS_ASSIGNED_TO_ORDER), APPLICATION_JSON, HttpStatus.HTTP_OK.toInt()).as(ReceivingResults.class);
verifyAllowedCase(results);
validateNumberOfRequests(1, 1);
}
Aggregations