Search in sources :

Example 1 with ReceivingItemResult

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

the class ReceivingCheckinProtectionTest method testCheckInCompositeFlow.

@Test
void testCheckInCompositeFlow() {
    addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(getMinimalContentCompositePurchaseOrder().withAcqUnitIds(NOT_PROTECTED_UNITS).withId(ORDER_WITH_NOT_PROTECTED_UNITS_ID)));
    addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(getMinimalContentCompositePurchaseOrder().withAcqUnitIds(PROTECTED_UNITS).withId(ORDER_WITH_PROTECTED_UNITS_ID)));
    List<CompositePoLine> poLines = new ArrayList<>();
    poLines.add(getMinimalContentCompositePoLine(ORDER_WITH_NOT_PROTECTED_UNITS_ID).withId(EXPECTED_FLOW_PO_LINE_ID));
    poLines.add(getMinimalContentCompositePoLine(ORDER_WITH_NOT_PROTECTED_UNITS_ID).withId(RANDOM_PO_LINE_ID_1));
    poLines.add(getMinimalContentCompositePoLine(ORDER_WITH_PROTECTED_UNITS_ID).withId(RANDOM_PO_LINE_ID_2));
    poLines.forEach(line -> addMockEntry(PO_LINES_STORAGE, JsonObject.mapFrom(line)));
    MockServer.addMockTitles(poLines);
    CheckinCollection toBeCheckedInRq = new CheckinCollection();
    List<ToBeCheckedIn> toBeCheckedInList = new ArrayList<>();
    toBeCheckedInList.add(getToBeCheckedIn(EXPECTED_FLOW_PO_LINE_ID, EXPECTED_FLOW_PIECE_ID_1));
    toBeCheckedInList.add(getToBeCheckedIn(RANDOM_PO_LINE_ID_1, getRandomId()));
    toBeCheckedInList.add(getToBeCheckedIn(RANDOM_PO_LINE_ID_2, getRandomId()));
    toBeCheckedInList.add(getToBeCheckedIn(EXPECTED_FLOW_PO_LINE_ID, getRandomId()));
    toBeCheckedInRq.setToBeCheckedIn(toBeCheckedInList);
    toBeCheckedInRq.setTotalRecords(toBeCheckedInList.size());
    ReceivingResults results = verifyPostResponse(Entities.CHECK_IN.getEndpoint(), JsonObject.mapFrom(toBeCheckedInRq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_WITH_UNITS_NOT_ASSIGNED_TO_ORDER), APPLICATION_JSON, HttpStatus.HTTP_OK.toInt()).as(ReceivingResults.class);
    List<ProcessingStatus> result = results.getReceivingResults().stream().flatMap(r -> r.getReceivingItemResults().stream().map(ReceivingItemResult::getProcessingStatus)).filter(s -> Objects.isNull(s.getError())).collect(Collectors.toList());
    assertThat(result, hasSize(1));
    List<Error> errors = results.getReceivingResults().stream().flatMap(r -> r.getReceivingItemResults().stream().map(e -> e.getProcessingStatus().getError())).filter(Objects::nonNull).collect(Collectors.toList());
    assertThat(errors, hasSize(toBeCheckedInList.size() - 1));
    assertThat(errors.stream().filter(e -> e.getCode().equals(PIECE_NOT_FOUND.getCode())).count(), is(2L));
    assertThat(errors.stream().filter(e -> e.getCode().equals(USER_HAS_NO_PERMISSIONS.getCode())).count(), is(1L));
}
Also used : Arrays(java.util.Arrays) CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) TimeoutException(java.util.concurrent.TimeoutException) ProcessingStatus(org.folio.rest.jaxrs.model.ProcessingStatus) X_OKAPI_USER_ID(org.folio.TestConstants.X_OKAPI_USER_ID) PIECE_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.PIECE_NOT_FOUND) ApiTestSuite(org.folio.ApiTestSuite) AfterAll(org.junit.jupiter.api.AfterAll) MockServer(org.folio.rest.impl.MockServer) BeforeAll(org.junit.jupiter.api.BeforeAll) JsonObject(io.vertx.core.json.JsonObject) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) Matchers.allOf(org.hamcrest.Matchers.allOf) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) Collectors(java.util.stream.Collectors) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) ReceivingCollection(org.folio.rest.jaxrs.model.ReceivingCollection) List(java.util.List) Logger(org.apache.logging.log4j.Logger) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PO_LINES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) ORDERS_RECEIVING_ENDPOINT(org.folio.TestConstants.ORDERS_RECEIVING_ENDPOINT) USER_HAS_NO_PERMISSIONS(org.folio.rest.core.exceptions.ErrorCodes.USER_HAS_NO_PERMISSIONS) TestUtils.getRandomId(org.folio.TestUtils.getRandomId) TestUtils.getToBeReceived(org.folio.TestUtils.getToBeReceived) EnumSource(org.junit.jupiter.params.provider.EnumSource) ArrayList(java.util.ArrayList) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Every.everyItem(org.hamcrest.core.Every.everyItem) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) RestTestUtils.prepareHeaders(org.folio.RestTestUtils.prepareHeaders) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ReceivingItemResult(org.folio.rest.jaxrs.model.ReceivingItemResult) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10) ToBeCheckedIn(org.folio.rest.jaxrs.model.ToBeCheckedIn) PURCHASE_ORDER_STORAGE(org.folio.orders.utils.ResourcePathResolver.PURCHASE_ORDER_STORAGE) Matchers.empty(org.hamcrest.Matchers.empty) RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) TestUtils.getToBeCheckedIn(org.folio.TestUtils.getToBeCheckedIn) ToBeReceived(org.folio.rest.jaxrs.model.ToBeReceived) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) ExecutionException(java.util.concurrent.ExecutionException) Error(org.folio.rest.jaxrs.model.Error) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ORDERS_CHECKIN_ENDPOINT(org.folio.TestConstants.ORDERS_CHECKIN_ENDPOINT) HttpStatus(org.folio.HttpStatus) ApplicationConfig(org.folio.config.ApplicationConfig) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) ArrayList(java.util.ArrayList) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Error(org.folio.rest.jaxrs.model.Error) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) ProcessingStatus(org.folio.rest.jaxrs.model.ProcessingStatus) ToBeCheckedIn(org.folio.rest.jaxrs.model.ToBeCheckedIn) TestUtils.getToBeCheckedIn(org.folio.TestUtils.getToBeCheckedIn) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with ReceivingItemResult

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

the class ReceivingCheckinProtectionTest method testReceivingCompositeFlow.

@Test
void testReceivingCompositeFlow() {
    addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(getMinimalContentCompositePurchaseOrder().withAcqUnitIds(NOT_PROTECTED_UNITS).withId(ORDER_WITH_NOT_PROTECTED_UNITS_ID)));
    addMockEntry(PURCHASE_ORDER_STORAGE, JsonObject.mapFrom(getMinimalContentCompositePurchaseOrder().withAcqUnitIds(PROTECTED_UNITS).withId(ORDER_WITH_PROTECTED_UNITS_ID)));
    List<CompositePoLine> poLines = new ArrayList<>();
    poLines.add(getMinimalContentCompositePoLine(ORDER_WITH_NOT_PROTECTED_UNITS_ID).withId(EXPECTED_FLOW_PO_LINE_ID));
    poLines.add(getMinimalContentCompositePoLine(ORDER_WITH_NOT_PROTECTED_UNITS_ID).withId(RANDOM_PO_LINE_ID_1));
    poLines.add(getMinimalContentCompositePoLine(ORDER_WITH_PROTECTED_UNITS_ID).withId(RANDOM_PO_LINE_ID_2));
    poLines.forEach(line -> addMockEntry(PO_LINES_STORAGE, JsonObject.mapFrom(line)));
    MockServer.addMockTitles(poLines);
    ReceivingCollection toBeReceivedRq = new ReceivingCollection();
    List<ToBeReceived> toBeReceivedList = new ArrayList<>();
    toBeReceivedList.add(getToBeReceived(EXPECTED_FLOW_PO_LINE_ID, EXPECTED_FLOW_PIECE_ID_1));
    toBeReceivedList.add(getToBeReceived(RANDOM_PO_LINE_ID_1, getRandomId()));
    toBeReceivedList.add(getToBeReceived(RANDOM_PO_LINE_ID_2, getRandomId()));
    toBeReceivedList.add(getToBeReceived(EXPECTED_FLOW_PO_LINE_ID, getRandomId()));
    toBeReceivedRq.setToBeReceived(toBeReceivedList);
    toBeReceivedRq.setTotalRecords(toBeReceivedList.size());
    ReceivingResults results = verifyPostResponse(Entities.RECEIVING.getEndpoint(), JsonObject.mapFrom(toBeReceivedRq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_WITH_UNITS_NOT_ASSIGNED_TO_ORDER), APPLICATION_JSON, HttpStatus.HTTP_OK.toInt()).as(ReceivingResults.class);
    List<ProcessingStatus> result = results.getReceivingResults().stream().flatMap(r -> r.getReceivingItemResults().stream().map(ReceivingItemResult::getProcessingStatus)).filter(s -> Objects.isNull(s.getError())).collect(Collectors.toList());
    assertThat(result, hasSize(1));
    List<Error> errors = results.getReceivingResults().stream().flatMap(r -> r.getReceivingItemResults().stream().map(e -> e.getProcessingStatus().getError())).filter(Objects::nonNull).collect(Collectors.toList());
    assertThat(errors, hasSize(toBeReceivedList.size() - 1));
    assertThat(errors.stream().filter(e -> e.getCode().equals(PIECE_NOT_FOUND.getCode())).count(), is(2L));
    assertThat(errors.stream().filter(e -> e.getCode().equals(USER_HAS_NO_PERMISSIONS.getCode())).count(), is(1L));
}
Also used : Arrays(java.util.Arrays) CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) TimeoutException(java.util.concurrent.TimeoutException) ProcessingStatus(org.folio.rest.jaxrs.model.ProcessingStatus) X_OKAPI_USER_ID(org.folio.TestConstants.X_OKAPI_USER_ID) PIECE_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.PIECE_NOT_FOUND) ApiTestSuite(org.folio.ApiTestSuite) AfterAll(org.junit.jupiter.api.AfterAll) MockServer(org.folio.rest.impl.MockServer) BeforeAll(org.junit.jupiter.api.BeforeAll) JsonObject(io.vertx.core.json.JsonObject) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) Matchers.allOf(org.hamcrest.Matchers.allOf) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) Collectors(java.util.stream.Collectors) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) ReceivingCollection(org.folio.rest.jaxrs.model.ReceivingCollection) List(java.util.List) Logger(org.apache.logging.log4j.Logger) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PO_LINES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) ORDERS_RECEIVING_ENDPOINT(org.folio.TestConstants.ORDERS_RECEIVING_ENDPOINT) USER_HAS_NO_PERMISSIONS(org.folio.rest.core.exceptions.ErrorCodes.USER_HAS_NO_PERMISSIONS) TestUtils.getRandomId(org.folio.TestUtils.getRandomId) TestUtils.getToBeReceived(org.folio.TestUtils.getToBeReceived) EnumSource(org.junit.jupiter.params.provider.EnumSource) ArrayList(java.util.ArrayList) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Every.everyItem(org.hamcrest.core.Every.everyItem) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) RestTestUtils.prepareHeaders(org.folio.RestTestUtils.prepareHeaders) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ReceivingItemResult(org.folio.rest.jaxrs.model.ReceivingItemResult) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10) ToBeCheckedIn(org.folio.rest.jaxrs.model.ToBeCheckedIn) PURCHASE_ORDER_STORAGE(org.folio.orders.utils.ResourcePathResolver.PURCHASE_ORDER_STORAGE) Matchers.empty(org.hamcrest.Matchers.empty) RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) TestUtils.getToBeCheckedIn(org.folio.TestUtils.getToBeCheckedIn) ToBeReceived(org.folio.rest.jaxrs.model.ToBeReceived) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) ExecutionException(java.util.concurrent.ExecutionException) Error(org.folio.rest.jaxrs.model.Error) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ORDERS_CHECKIN_ENDPOINT(org.folio.TestConstants.ORDERS_CHECKIN_ENDPOINT) HttpStatus(org.folio.HttpStatus) ApplicationConfig(org.folio.config.ApplicationConfig) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) TestUtils.getToBeReceived(org.folio.TestUtils.getToBeReceived) ToBeReceived(org.folio.rest.jaxrs.model.ToBeReceived) ArrayList(java.util.ArrayList) ReceivingCollection(org.folio.rest.jaxrs.model.ReceivingCollection) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Error(org.folio.rest.jaxrs.model.Error) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) ProcessingStatus(org.folio.rest.jaxrs.model.ProcessingStatus) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with ReceivingItemResult

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

the class CheckinReceivingApiTest method testPostReceivingPhysicalWithErrors.

@Test
void testPostReceivingPhysicalWithErrors() throws IOException {
    logger.info("=== Test POST Receiving - Receive physical resources with different errors");
    ReceivingCollection receivingRq = getMockAsJson(RECEIVING_RQ_MOCK_DATA_PATH + "receive-physical-resources-6-of-10-with-errors.json").mapTo(ReceivingCollection.class);
    CompositePoLine poLines = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(3).mapTo(CompositePoLine.class);
    MockServer.addMockTitles(Collections.singletonList(poLines));
    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(receivingRq.getTotalRecords()));
    assertThat(results.getReceivingResults(), hasSize(1));
    ReceivingResult receivingResult = results.getReceivingResults().get(0);
    assertThat(receivingResult.getPoLineId(), not(is(emptyString())));
    assertThat(receivingResult.getProcessedSuccessfully(), is(5));
    assertThat(receivingResult.getProcessedWithError(), is(5));
    Set<String> errorCodes = new HashSet<>();
    for (ReceivingItemResult receivingItemResult : receivingResult.getReceivingItemResults()) {
        assertThat(receivingItemResult.getPieceId(), not(is(emptyString())));
        assertThat(receivingItemResult.getProcessingStatus(), not(nullValue()));
        if (receivingItemResult.getProcessingStatus().getType() == SUCCESS) {
            assertThat(receivingItemResult.getProcessingStatus().getError(), nullValue());
        } else {
            assertThat(receivingItemResult.getProcessingStatus().getError(), not(nullValue()));
            errorCodes.add(receivingItemResult.getProcessingStatus().getError().getCode());
        }
    }
    assertThat(errorCodes, containsInAnyOrder(PIECE_ALREADY_RECEIVED.getCode(), PIECE_POL_MISMATCH.getCode(), PIECE_NOT_FOUND.getCode(), ITEM_UPDATE_FAILED.getCode(), PIECE_UPDATE_FAILED.getCode()));
    List<JsonObject> itemUpdates = getItemUpdates();
    List<JsonObject> polUpdates = getPoLineUpdates();
    assertThat(getPoLineSearches(), hasSize(1));
    assertThat(polUpdates, hasSize(1));
    assertThat(itemUpdates, hasSize(6));
    itemUpdates.forEach(item -> {
        assertThat(item.getJsonObject(ITEM_STATUS), notNullValue());
        assertThat(item.getJsonObject(ITEM_STATUS).getString(ITEM_STATUS_NAME), equalTo(ReceivedItem.ItemStatus.IN_PROCESS.value()));
    });
    polUpdates.forEach(pol -> {
        PoLine poLine = pol.mapTo(PoLine.class);
        assertThat(poLine.getReceiptStatus(), is(PoLine.ReceiptStatus.PARTIALLY_RECEIVED));
        assertThat(poLine.getReceiptDate(), is(nullValue()));
    });
    verifyProperQuantityOfHoldingsCreated(receivingRq);
    // Verify messages sent via event bus
    verifyOrderStatusUpdateEvent(1);
}
Also used : ReceivingItemResult(org.folio.rest.jaxrs.model.ReceivingItemResult) ReceivingResult(org.folio.rest.jaxrs.model.ReceivingResult) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PoLine(org.folio.rest.jaxrs.model.PoLine) ReceivingCollection(org.folio.rest.jaxrs.model.ReceivingCollection) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) JsonObject(io.vertx.core.json.JsonObject) Matchers.emptyString(org.hamcrest.Matchers.emptyString) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 4 with ReceivingItemResult

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

the class CheckinReceivingApiTest method testPostCheckInPhysicalWithMissingItem.

@Test
void testPostCheckInPhysicalWithMissingItem() {
    logger.info("=== Test POST Checkin - CheckIn physical resource with only one item updated");
    CompositePoLine poLines = getMockAsJson(POLINES_COLLECTION).getJsonArray("poLines").getJsonObject(7).mapTo(CompositePoLine.class);
    MockServer.addMockTitles(Collections.singletonList(poLines));
    CheckinCollection checkInRq = getMockAsJson(CHECKIN_RQ_MOCK_DATA_PATH + "checkin-pe-mix-2-physical-resources.json").mapTo(CheckinCollection.class);
    ReceivingResults results = verifyPostResponse(ORDERS_CHECKIN_ENDPOINT, JsonObject.mapFrom(checkInRq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, 200).as(ReceivingResults.class);
    assertThat(results.getTotalRecords(), equalTo(checkInRq.getTotalRecords()));
    ReceivingResult receivingResult = results.getReceivingResults().get(0);
    for (ReceivingItemResult receivingItemResult : receivingResult.getReceivingItemResults()) {
        assertThat(receivingItemResult.getPieceId(), not(is(emptyString())));
        assertThat(receivingItemResult.getProcessingStatus(), not(nullValue()));
        assertThat(receivingItemResult.getProcessingStatus().getType(), is(SUCCESS));
        assertThat(receivingItemResult.getProcessingStatus().getError(), nullValue());
    }
    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()));
    assertThat(pieceSearches, hasSize(2));
    assertThat(pieceUpdates, hasSize(2));
    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.getJsonObject(ITEM_STATUS).getString(ITEM_STATUS_NAME), equalTo(CheckInPiece.ItemStatus.IN_PROCESS.value()));
    });
    polUpdates.forEach(pol -> {
        PoLine poLine = pol.mapTo(PoLine.class);
        assertThat(poLine.getCheckinItems(), is(true));
        assertThat(poLine.getReceiptStatus(), is(PoLine.ReceiptStatus.PARTIALLY_RECEIVED));
        assertThat(poLine.getReceiptDate(), is(notNullValue()));
    });
    // Verify message is sent via event bus
    verifyCheckinOrderStatusUpdateEvent(1);
}
Also used : CheckinCollection(org.folio.rest.jaxrs.model.CheckinCollection) ReceivingItemResult(org.folio.rest.jaxrs.model.ReceivingItemResult) ReceivingResult(org.folio.rest.jaxrs.model.ReceivingResult) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) JsonObject(io.vertx.core.json.JsonObject) ReceivingResults(org.folio.rest.jaxrs.model.ReceivingResults) Test(org.junit.jupiter.api.Test)

Example 5 with ReceivingItemResult

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

the class CheckinReceivePiecesHelper method calculateProcessingErrors.

public void calculateProcessingErrors(String poLineId, ReceivingResult result, Map<String, Piece> processedPiecesForPoLine, Map<String, Integer> resultCounts, String pieceId) {
    // Calculate processing status
    ProcessingStatus status = new ProcessingStatus();
    Error error = getError(poLineId, pieceId);
    if (processedPiecesForPoLine.get(pieceId) != null && error == null) {
        status.setType(ProcessingStatus.Type.SUCCESS);
        resultCounts.merge(ProcessingStatus.Type.SUCCESS.toString(), 1, Integer::sum);
    } else {
        status.setType(ProcessingStatus.Type.FAILURE);
        status.setError(error);
        resultCounts.merge(ProcessingStatus.Type.FAILURE.toString(), 1, Integer::sum);
    }
    ReceivingItemResult itemResult = new ReceivingItemResult();
    itemResult.setPieceId(pieceId);
    itemResult.setProcessingStatus(status);
    result.getReceivingItemResults().add(itemResult);
}
Also used : ReceivingItemResult(org.folio.rest.jaxrs.model.ReceivingItemResult) Error(org.folio.rest.jaxrs.model.Error) ProcessingStatus(org.folio.rest.jaxrs.model.ProcessingStatus)

Aggregations

ReceivingItemResult (org.folio.rest.jaxrs.model.ReceivingItemResult)9 ReceivingResults (org.folio.rest.jaxrs.model.ReceivingResults)7 Test (org.junit.jupiter.api.Test)7 TestUtils.getMinimalContentCompositePoLine (org.folio.TestUtils.getMinimalContentCompositePoLine)6 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)6 ReceivingCollection (org.folio.rest.jaxrs.model.ReceivingCollection)6 JsonObject (io.vertx.core.json.JsonObject)5 ReceivingResult (org.folio.rest.jaxrs.model.ReceivingResult)4 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 Collectors (java.util.stream.Collectors)3 APPLICATION_JSON (javax.ws.rs.core.MediaType.APPLICATION_JSON)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 ApiTestSuite (org.folio.ApiTestSuite)3 HttpStatus (org.folio.HttpStatus)3