Search in sources :

Example 1 with EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10

use of org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10 in project mod-orders by folio-org.

the class PurchaseOrdersApiTest method testPostListedPrintSerialInOpenStatus.

@Test
@Disabled
// TODO Must be fixed in scope of https://issues.folio.org/browse/MODORDERS-587
void testPostListedPrintSerialInOpenStatus() throws Exception {
    logger.info("=== Test Listed Print Monograph in Open status ===");
    CompositePurchaseOrder reqData = new JsonObject(getMockData(LISTED_PRINT_SERIAL_PATH)).mapTo(CompositePurchaseOrder.class);
    String orderId = UUID.randomUUID().toString();
    reqData.setWorkflowStatus(WorkflowStatus.OPEN);
    MockServer.addMockTitles(reqData.getCompositePoLines());
    prepareOrderForPostRequest(reqData);
    reqData.setId(orderId);
    reqData.getCompositePoLines().forEach(poLine -> {
        poLine.setPaymentStatus(CompositePoLine.PaymentStatus.PENDING);
        poLine.setReceiptStatus(ReceiptStatus.PENDING);
    });
    LocalDate now = LocalDate.now();
    final CompositePurchaseOrder resp = verifyPostResponse(COMPOSITE_ORDERS_PATH, JsonObject.mapFrom(reqData).toString(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_ID), APPLICATION_JSON, 201).as(CompositePurchaseOrder.class);
    LocalDate dateOrdered = resp.getDateOrdered().toInstant().atZone(ZoneId.of(ZoneOffset.UTC.getId())).toLocalDate();
    assertThat(dateOrdered.getMonth(), equalTo(now.getMonth()));
    assertThat(dateOrdered.getYear(), equalTo(now.getYear()));
    logger.info(JsonObject.mapFrom(resp));
    String poId = resp.getId();
    String poNumber = resp.getPoNumber();
    assertNotNull(poId);
    assertNotNull(poNumber);
    assertEquals(reqData.getCompositePoLines().size(), resp.getCompositePoLines().size());
    for (int i = 0; i < resp.getCompositePoLines().size(); i++) {
        CompositePoLine line = resp.getCompositePoLines().get(i);
        String polNumber = line.getPoLineNumber();
        String polId = line.getId();
        assertEquals(poId, line.getPurchaseOrderId());
        assertNotNull(polId);
        assertNotNull(polNumber);
        assertTrue(polNumber.startsWith(poNumber));
        assertNotNull(line.getInstanceId());
        line.getLocations().forEach(location -> verifyLocationQuantity(location, line.getOrderFormat()));
        line.getLocations().forEach(location -> {
            assertNull(location.getLocationId());
            assertNotNull(location.getHoldingId());
        });
    }
    int polCount = resp.getCompositePoLines().size();
    List<JsonObject> instancesSearches = getInstancesSearches();
    assertNotNull(instancesSearches);
    assertEquals(polCount, instancesSearches.size());
    CompositePoLine respLine1 = resp.getCompositePoLines().get(0);
    List<JsonObject> createdInstances = getCreatedInstances();
    assertEquals(1, createdInstances.size(), "Quantity of created instance must be equal of line, if create inventory include instance");
    assertNotNull("Line must be connected to instance, if create inventory include instance", respLine1.getInstanceId());
    List<JsonObject> createdHoldings = getCreatedHoldings();
    assertEquals(1, createdHoldings.size(), "Quantity of created holding must be depended of quantity in the locations and create inventory include holding");
    verifyHoldingsCreated(1, createdHoldings, respLine1);
    // All existing and created items
    List<JsonObject> items = joinExistingAndNewItems();
    verifyItemsCreated(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, 1, items, respLine1);
    List<JsonObject> createdPieces = getCreatedPieces();
    verifyOpenOrderPiecesCreated(items, resp.getCompositePoLines(), createdPieces, 0);
    createdPieces.stream().map(json -> json.mapTo(Piece.class)).filter(piece -> PHYSICAL.equals(piece.getFormat())).forEach(piece -> {
        assertNull(piece.getLocationId());
        assertNotNull(piece.getHoldingId());
    });
    createdPieces.stream().map(json -> json.mapTo(Piece.class)).filter(piece -> ELECTRONIC.equals(piece.getFormat())).forEach(piece -> {
        assertNotNull(piece.getLocationId());
        assertNull(piece.getHoldingId());
    });
    verifyEncumbrancesOnPoCreation(reqData, resp);
    assertThat(getExistingOrderSummaries(), hasSize(0));
    verifyCalculatedData(resp);
    // MODORDERS-459 - check status changed to ONGOING
    verifyReceiptStatusChangedTo(ReceiptStatus.ONGOING.value(), reqData.getCompositePoLines().size());
    verifyPaymentStatusChangedTo(CompositePoLine.PaymentStatus.ONGOING.value(), reqData.getCompositePoLines().size());
}
Also used : PO_ID_OPEN_TO_BE_CLOSED(org.folio.TestConstants.PO_ID_OPEN_TO_BE_CLOSED) BeforeEach(org.junit.jupiter.api.BeforeEach) PO_WFD_ID_OPEN_STATUS(org.folio.TestConstants.PO_WFD_ID_OPEN_STATUS) ID_BAD_FORMAT(org.folio.TestConstants.ID_BAD_FORMAT) TestUtils.validatePoLineCreationErrorForNonPendingOrder(org.folio.TestUtils.validatePoLineCreationErrorForNonPendingOrder) INVALID_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.INVALID_CONFIG_X_OKAPI_TENANT) StringUtils(org.apache.commons.lang3.StringUtils) ApiTestSuite(org.folio.ApiTestSuite) ZERO_LOCATION_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_LOCATION_QTY) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) EMPTY_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.EMPTY_CONFIG_X_OKAPI_TENANT) ZoneOffset(java.time.ZoneOffset) ORDER_VENDOR_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.ORDER_VENDOR_NOT_FOUND) Errors(org.folio.rest.jaxrs.model.Errors) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) ID_FOR_INTERNAL_SERVER_ERROR(org.folio.TestConstants.ID_FOR_INTERNAL_SERVER_ERROR) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ORDER_CLOSED(org.folio.rest.core.exceptions.ErrorCodes.ORDER_CLOSED) Metadata(org.folio.rest.acq.model.finance.Metadata) VENDOR_ISSUE(org.folio.rest.core.exceptions.ErrorCodes.VENDOR_ISSUE) ErrorCodes(org.folio.rest.core.exceptions.ErrorCodes) OTHER(org.folio.rest.jaxrs.model.Piece.Format.OTHER) ZoneId(java.time.ZoneId) TestConfig.mockPort(org.folio.TestConfig.mockPort) Logger(org.apache.logging.log4j.Logger) Eresource(org.folio.rest.jaxrs.model.Eresource) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) MIN_PO_ID(org.folio.TestConstants.MIN_PO_ID) PO_LINES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) POProtectedFields(org.folio.orders.utils.POProtectedFields) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) RestClient(org.folio.rest.core.RestClient) INACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.INACTIVE_ACCESS_PROVIDER_B) INACTIVE_ACCESS_PROVIDER_A(org.folio.TestConstants.INACTIVE_ACCESS_PROVIDER_A) HelperUtils.calculateInventoryItemsQuantity(org.folio.orders.utils.HelperUtils.calculateInventoryItemsQuantity) PaymentStatus(org.folio.rest.acq.model.PaymentStatus) BUDGET_IS_INACTIVE_TENANT(org.folio.rest.impl.MockServer.BUDGET_IS_INACTIVE_TENANT) ACQUISITIONS_MEMBERSHIPS(org.folio.orders.utils.ResourcePathResolver.ACQUISITIONS_MEMBERSHIPS) Contributor(org.folio.rest.jaxrs.model.Contributor) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) ZERO_COST_ELECTRONIC_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_COST_ELECTRONIC_QTY) OrderFormat(org.folio.rest.jaxrs.model.CompositePoLine.OrderFormat) Answer(org.mockito.stubbing.Answer) MockServer.getHoldingsSearches(org.folio.rest.impl.MockServer.getHoldingsSearches) RestTestUtils.verifySuccessGet(org.folio.RestTestUtils.verifySuccessGet) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PO_LINES_EMPTY_COLLECTION_ID(org.folio.rest.impl.MockServer.PO_LINES_EMPTY_COLLECTION_ID) Physical(org.folio.rest.jaxrs.model.Physical) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10) RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) ELECTRONIC_COST_LOC_QTY_MISMATCH(org.folio.rest.core.exceptions.ErrorCodes.ELECTRONIC_COST_LOC_QTY_MISMATCH) MockServer.getPieceSearches(org.folio.rest.impl.MockServer.getPieceSearches) MockServer.getCreatedOrderSummaries(org.folio.rest.impl.MockServer.getCreatedOrderSummaries) PO_LINE_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_LINE_NUMBER) HelperUtils(org.folio.orders.utils.HelperUtils) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) Vertx(io.vertx.core.Vertx) RequestEntry(org.folio.rest.core.models.RequestEntry) IOException(java.io.IOException) X_OKAPI_URL(org.folio.TestConfig.X_OKAPI_URL) BUDGET_NOT_FOUND_FOR_TRANSACTION(org.folio.rest.core.exceptions.ErrorCodes.BUDGET_NOT_FOUND_FOR_TRANSACTION) ITEM_RECORDS(org.folio.rest.impl.MockServer.ITEM_RECORDS) ACQUISITIONS_UNITS(org.folio.orders.utils.ResourcePathResolver.ACQUISITIONS_UNITS) ExecutionException(java.util.concurrent.ExecutionException) PO_LINE_ID_FOR_SUCCESS_CASE(org.folio.TestConstants.PO_LINE_ID_FOR_SUCCESS_CASE) LEDGER_NOT_FOUND_FOR_TRANSACTION_TENANT(org.folio.rest.impl.MockServer.LEDGER_NOT_FOUND_FOR_TRANSACTION_TENANT) AfterEach(org.junit.jupiter.api.AfterEach) BUDGET_NOT_FOUND_FOR_TRANSACTION_TENANT(org.folio.rest.impl.MockServer.BUDGET_NOT_FOUND_FOR_TRANSACTION_TENANT) InventoryInteractionTestHelper.verifyPiecesCreated(org.folio.helper.InventoryInteractionTestHelper.verifyPiecesCreated) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PHYSICAL(org.folio.rest.jaxrs.model.Piece.Format.PHYSICAL) ENCUMBRANCE_PATH(org.folio.rest.impl.MockServer.ENCUMBRANCE_PATH) MockServer.getInstancesSearches(org.folio.rest.impl.MockServer.getInstancesSearches) PO_ID_PENDING_STATUS_WITH_PO_LINES(org.folio.TestConstants.PO_ID_PENDING_STATUS_WITH_PO_LINES) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_1(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_1) FUND_CANNOT_BE_PAID_TENANT(org.folio.rest.impl.MockServer.FUND_CANNOT_BE_PAID_TENANT) Date(java.util.Date) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) X_OKAPI_USER_ID(org.folio.TestConstants.X_OKAPI_USER_ID) TITLES(org.folio.orders.utils.ResourcePathResolver.TITLES) TestUtils.getInstanceId(org.folio.TestUtils.getInstanceId) Context(io.vertx.core.Context) ISBN_NOT_VALID(org.folio.rest.core.exceptions.ErrorCodes.ISBN_NOT_VALID) MockServer.getPurchaseOrderUpdates(org.folio.rest.impl.MockServer.getPurchaseOrderUpdates) MockServer.getCreatedItems(org.folio.rest.impl.MockServer.getCreatedItems) ReceiptStatus(org.folio.rest.jaxrs.model.CompositePoLine.ReceiptStatus) TestUtils(org.folio.TestUtils) ID(org.folio.TestConstants.ID) Location(org.folio.rest.jaxrs.model.Location) ORDER_VENDOR_IS_INACTIVE(org.folio.rest.core.exceptions.ErrorCodes.ORDER_VENDOR_IS_INACTIVE) ONGOING_NOT_ALLOWED(org.folio.rest.core.exceptions.ErrorCodes.ONGOING_NOT_ALLOWED) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) UUID(java.util.UUID) PO_ID_CLOSED_STATUS(org.folio.TestConstants.PO_ID_CLOSED_STATUS) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) ERROR_CAUSE(org.folio.helper.AbstractHelper.ERROR_CAUSE) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LocalDate(java.time.LocalDate) POLineFieldNames(org.folio.orders.utils.POLineFieldNames) ACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_B) POL_LINES_LIMIT_EXCEEDED(org.folio.rest.core.exceptions.ErrorCodes.POL_LINES_LIMIT_EXCEEDED) ACTIVE_ACCESS_PROVIDER_A(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_A) InventoryInteractionTestHelper.verifyPiecesQuantityForSuccessCase(org.folio.helper.InventoryInteractionTestHelper.verifyPiecesQuantityForSuccessCase) ZERO_COST_PHYSICAL_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_COST_PHYSICAL_QTY) TestUtils.getMockData(org.folio.TestUtils.getMockData) InventoryInteractionTestHelper.verifyHoldingsCreated(org.folio.helper.InventoryInteractionTestHelper.verifyHoldingsCreated) VENDOR_ID(org.folio.orders.utils.ResourcePathResolver.VENDOR_ID) MISSING_MATERIAL_TYPE(org.folio.rest.core.exceptions.ErrorCodes.MISSING_MATERIAL_TYPE) Encumbrance(org.folio.rest.acq.model.finance.Encumbrance) Matchers.empty(org.hamcrest.Matchers.empty) TestUtils.verifyLocationQuantity(org.folio.TestUtils.verifyLocationQuantity) PO_ID_PENDING_STATUS_WITHOUT_PO_LINES(org.folio.TestConstants.PO_ID_PENDING_STATUS_WITHOUT_PO_LINES) InventoryInteractionTestHelper.verifyItemsCreated(org.folio.helper.InventoryInteractionTestHelper.verifyItemsCreated) MockServer.getLoanTypesSearches(org.folio.rest.impl.MockServer.getLoanTypesSearches) CloseReason(org.folio.rest.jaxrs.model.CloseReason) NON_ZERO_COST_ELECTRONIC_QTY(org.folio.rest.core.exceptions.ErrorCodes.NON_ZERO_COST_ELECTRONIC_QTY) Error(org.folio.rest.jaxrs.model.Error) Collectors.toList(java.util.stream.Collectors.toList) Response(io.restassured.response.Response) ApplicationConfig(org.folio.config.ApplicationConfig) INVALID_LANG(org.folio.TestConstants.INVALID_LANG) POL_ACCESS_PROVIDER_IS_INACTIVE(org.folio.rest.core.exceptions.ErrorCodes.POL_ACCESS_PROVIDER_IS_INACTIVE) LogManager(org.apache.logging.log4j.LogManager) MockServer.getCreatedHoldings(org.folio.rest.impl.MockServer.getCreatedHoldings) MockServer.getInstanceTypesSearches(org.folio.rest.impl.MockServer.getInstanceTypesSearches) Arrays(java.util.Arrays) HelperUtils.calculateTotalQuantity(org.folio.orders.utils.HelperUtils.calculateTotalQuantity) COST_UNIT_PRICE_ELECTRONIC_INVALID(org.folio.rest.core.exceptions.ErrorCodes.COST_UNIT_PRICE_ELECTRONIC_INVALID) Matchers.not(org.hamcrest.Matchers.not) Header(io.restassured.http.Header) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.NON_EXIST_CONFIG_X_OKAPI_TENANT) Disabled(org.junit.jupiter.api.Disabled) TransactionCollection(org.folio.rest.acq.model.finance.TransactionCollection) Is(org.hamcrest.core.Is) AfterAll(org.junit.jupiter.api.AfterAll) BigDecimal(java.math.BigDecimal) MockitoAnnotations(org.mockito.MockitoAnnotations) InventoryInteractionTestHelper.joinExistingAndNewItems(org.folio.helper.InventoryInteractionTestHelper.joinExistingAndNewItems) Matcher(java.util.regex.Matcher) BUDGET_EXPENSE_CLASS_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.BUDGET_EXPENSE_CLASS_NOT_FOUND) BeforeAll(org.junit.jupiter.api.BeforeAll) Matchers.nullValue(org.hamcrest.Matchers.nullValue) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) Mockito.doReturn(org.mockito.Mockito.doReturn) MISSING_ONGOING(org.folio.rest.core.exceptions.ErrorCodes.MISSING_ONGOING) RestTestUtils.verifyPut(org.folio.RestTestUtils.verifyPut) Set(java.util.Set) RestTestUtils.verifyDeleteResponse(org.folio.RestTestUtils.verifyDeleteResponse) Fund(org.folio.rest.acq.model.finance.Fund) Matchers.startsWith(org.hamcrest.Matchers.startsWith) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) COST_UNIT_PRICE_INVALID(org.folio.rest.core.exceptions.ErrorCodes.COST_UNIT_PRICE_INVALID) PROTECTED_READ_ONLY_TENANT(org.folio.TestConstants.PROTECTED_READ_ONLY_TENANT) X_OKAPI_TOKEN(org.folio.TestConstants.X_OKAPI_TOKEN) PO_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_NUMBER) FinanceInteractionsTestHelper.verifyEncumbrancesOnPoUpdate(org.folio.helper.FinanceInteractionsTestHelper.verifyEncumbrancesOnPoUpdate) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) COMPOSITE_PO_LINES_PREFIX(org.folio.TestConstants.COMPOSITE_PO_LINES_PREFIX) CreateInventory(org.folio.rest.jaxrs.model.Physical.CreateInventory) Mock(org.mockito.Mock) ID_DOES_NOT_EXIST(org.folio.TestConstants.ID_DOES_NOT_EXIST) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) TransactionService(org.folio.service.finance.transaction.TransactionService) MockServer.getExistingOrderSummaries(org.folio.rest.impl.MockServer.getExistingOrderSummaries) Transaction(org.folio.rest.acq.model.finance.Transaction) MockServer.getCreatedEncumbrances(org.folio.rest.impl.MockServer.getCreatedEncumbrances) PAYMENT_STATUS(org.folio.orders.utils.ResourcePathResolver.PAYMENT_STATUS) ArrayList(java.util.ArrayList) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) INSTANCE_TYPE_CONTAINS_CODE_AS_INSTANCE_STATUS_TENANT_HEADER(org.folio.TestConstants.INSTANCE_TYPE_CONTAINS_CODE_AS_INSTANCE_STATUS_TENANT_HEADER) InvocationOnMock(org.mockito.invocation.InvocationOnMock) OKAPI_HEADER_PERMISSIONS(org.folio.helper.PurchaseOrderHelper.OKAPI_HEADER_PERMISSIONS) Matchers.lessThan(org.hamcrest.Matchers.lessThan) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InventoryInteractionTestHelper.verifyInventoryInteraction(org.folio.helper.InventoryInteractionTestHelper.verifyInventoryInteraction) InjectMocks(org.mockito.InjectMocks) COMP_ORDER_MOCK_DATA_PATH(org.folio.TestConstants.COMP_ORDER_MOCK_DATA_PATH) RestTestUtils.verifyGet(org.folio.RestTestUtils.verifyGet) Piece(org.folio.rest.jaxrs.model.Piece) COMPOSITE_PO_LINES(org.folio.orders.utils.HelperUtils.COMPOSITE_PO_LINES) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) JsonArray(io.vertx.core.json.JsonArray) AcqDesiredPermissions(org.folio.orders.utils.AcqDesiredPermissions) TestUtils.getMockAsJson(org.folio.TestUtils.getMockAsJson) GENERIC_ERROR_CODE(org.folio.rest.core.exceptions.ErrorCodes.GENERIC_ERROR_CODE) Cost(org.folio.rest.jaxrs.model.Cost) MockServer.getItemsSearches(org.folio.rest.impl.MockServer.getItemsSearches) MockServer.getContributorNameTypesSearches(org.folio.rest.impl.MockServer.getContributorNameTypesSearches) TimeoutException(java.util.concurrent.TimeoutException) PoLine(org.folio.rest.jaxrs.model.PoLine) Ongoing(org.folio.rest.acq.model.Ongoing) MISMATCH_BETWEEN_ID_IN_PATH_AND_BODY(org.folio.rest.core.exceptions.ErrorCodes.MISMATCH_BETWEEN_ID_IN_PATH_AND_BODY) MockServer.getItemUpdates(org.folio.rest.impl.MockServer.getItemUpdates) FUNDS(org.folio.orders.utils.ResourcePathResolver.FUNDS) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) StringUtils.containsAny(org.apache.commons.lang3.StringUtils.containsAny) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) InventoryInteractionTestHelper.verifyOpenOrderPiecesCreated(org.folio.helper.InventoryInteractionTestHelper.verifyOpenOrderPiecesCreated) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) BAD_QUERY(org.folio.TestConstants.BAD_QUERY) NON_EXIST_LOAN_TYPE_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_LOAN_TYPE_TENANT_HEADER) RestTestUtils.checkPreventProtectedFieldsModificationRule(org.folio.RestTestUtils.checkPreventProtectedFieldsModificationRule) PIECES_TO_BE_DELETED(org.folio.rest.core.exceptions.ErrorCodes.PIECES_TO_BE_DELETED) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) INSTANCE_ID_NOT_ALLOWED_FOR_PACKAGE_POLINE(org.folio.rest.core.exceptions.ErrorCodes.INSTANCE_ID_NOT_ALLOWED_FOR_PACKAGE_POLINE) InventoryInteractionTestHelper.verifyInventoryNonInteraction(org.folio.helper.InventoryInteractionTestHelper.verifyInventoryNonInteraction) InventoryInteractionTestHelper.verifyInstanceLinksForUpdatedOrder(org.folio.helper.InventoryInteractionTestHelper.verifyInstanceLinksForUpdatedOrder) PO_ID_OPEN_STATUS(org.folio.TestConstants.PO_ID_OPEN_STATUS) List(java.util.List) DistributionType(org.folio.rest.jaxrs.model.FundDistribution.DistributionType) EncumbranceService(org.folio.service.finance.transaction.EncumbranceService) Parameter(org.folio.rest.jaxrs.model.Parameter) Pattern(java.util.regex.Pattern) AcquisitionsUnitMembershipCollection(org.folio.rest.jaxrs.model.AcquisitionsUnitMembershipCollection) PIECES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PIECES_STORAGE) RECEIPT_STATUS(org.folio.orders.utils.ResourcePathResolver.RECEIPT_STATUS) ORGANIZATION_NOT_A_VENDOR(org.folio.rest.core.exceptions.ErrorCodes.ORGANIZATION_NOT_A_VENDOR) X_ECHO_STATUS(org.folio.TestConstants.X_ECHO_STATUS) OKAPI_HEADER_TENANT(org.folio.rest.RestVerticle.OKAPI_HEADER_TENANT) HashMap(java.util.HashMap) PO_LINE_NUMBER_VALUE(org.folio.TestConstants.PO_LINE_NUMBER_VALUE) MockServer.getCreatedInstances(org.folio.rest.impl.MockServer.getCreatedInstances) MockServer.getCreatedPieces(org.folio.rest.impl.MockServer.getCreatedPieces) Title(org.folio.rest.jaxrs.model.Title) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) ObjectUtils(org.apache.commons.lang3.ObjectUtils) RequestContext(org.folio.rest.core.models.RequestContext) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) RestTestUtils.prepareHeaders(org.folio.RestTestUtils.prepareHeaders) PURCHASE_ORDER_STORAGE(org.folio.orders.utils.ResourcePathResolver.PURCHASE_ORDER_STORAGE) PO_ID_OPEN_TO_CANCEL(org.folio.TestConstants.PO_ID_OPEN_TO_CANCEL) INCORRECT_FUND_DISTRIBUTION_TOTAL(org.folio.rest.core.exceptions.ErrorCodes.INCORRECT_FUND_DISTRIBUTION_TOTAL) PHYSICAL_COST_LOC_QTY_MISMATCH(org.folio.rest.core.exceptions.ErrorCodes.PHYSICAL_COST_LOC_QTY_MISMATCH) NON_EXIST_INSTANCE_STATUS_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_INSTANCE_STATUS_TENANT_HEADER) INACTIVE_EXPENSE_CLASS(org.folio.rest.core.exceptions.ErrorCodes.INACTIVE_EXPENSE_CLASS) MockServer.getInstanceStatusesSearches(org.folio.rest.impl.MockServer.getInstanceStatusesSearches) PurchaseOrderCollection(org.folio.rest.jaxrs.model.PurchaseOrderCollection) HttpMethod(io.vertx.core.http.HttpMethod) HttpStatus(org.folio.HttpStatus) X_OKAPI_USER_ID_WITH_ACQ_UNITS(org.folio.TestConstants.X_OKAPI_USER_ID_WITH_ACQ_UNITS) NON_EXIST_INSTANCE_TYPE_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_INSTANCE_TYPE_TENANT_HEADER) WorkflowStatus(org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus) ELECTRONIC(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC) Collections(java.util.Collections) ORDER_OPEN(org.folio.rest.core.exceptions.ErrorCodes.ORDER_OPEN) FinanceInteractionsTestHelper.verifyEncumbrancesOnPoCreation(org.folio.helper.FinanceInteractionsTestHelper.verifyEncumbrancesOnPoCreation) Piece(org.folio.rest.jaxrs.model.Piece) JsonObject(io.vertx.core.json.JsonObject) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Matchers.containsString(org.hamcrest.Matchers.containsString) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 2 with EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10

use of org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10 in project mod-orders by folio-org.

the class PurchaseOrdersApiTest method testPostOpenOrderInventoryUpdateWithOrderFormatOther.

@Test
@Disabled
// TODO must be fixed in scope of https://issues.folio.org/browse/MODORDERS-587
void testPostOpenOrderInventoryUpdateWithOrderFormatOther() throws Exception {
    logger.info("=== Test POST Order By Id to change status of Order to Open - inventory interaction required only for first POL ===");
    // Get Open Order
    CompositePurchaseOrder reqData = getMockDraftOrder().mapTo(CompositePurchaseOrder.class);
    MockServer.addMockTitles(reqData.getCompositePoLines());
    // Make sure that mock po has 2 po lines
    assertThat(reqData.getCompositePoLines(), hasSize(2));
    // Make sure that mock po has the first PO line with 3 locations
    assertThat(reqData.getCompositePoLines().get(0).getLocations(), hasSize(3));
    // Make sure that Order moves to Open
    reqData.setWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN);
    // Prepare second POL
    CompositePoLine secondPol = reqData.getCompositePoLines().get(1);
    List<Location> secondPolLocations = secondPol.getLocations();
    // MODORDERS-117 Setting OrderFormat to OTHER which means it behaves similar
    // to Physical order
    secondPol.setOrderFormat(CompositePoLine.OrderFormat.OTHER);
    Physical physical = new Physical();
    physical.setCreateInventory(CreateInventory.NONE);
    secondPol.setPhysical(physical);
    // Specify correct quantities for OTHER format
    secondPol.getCost().setQuantityElectronic(0);
    secondPol.getCost().setListUnitPriceElectronic(null);
    secondPol.getCost().setListUnitPrice(10d);
    secondPol.getCost().setQuantityPhysical(secondPolLocations.size());
    secondPol.setEresource(null);
    secondPolLocations.forEach(location -> {
        location.setQuantityElectronic(0);
        location.setQuantityPhysical(1);
    });
    LocalDate now = LocalDate.now();
    final CompositePurchaseOrder resp = verifyPostResponse(COMPOSITE_ORDERS_PATH, JsonObject.mapFrom(reqData).toString(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_ID), APPLICATION_JSON, 201).as(CompositePurchaseOrder.class);
    LocalDate dateOrdered = resp.getDateOrdered().toInstant().atZone(ZoneId.of(ZoneOffset.UTC.getId())).toLocalDate();
    assertThat(dateOrdered.getMonth(), equalTo(now.getMonth()));
    assertThat(dateOrdered.getYear(), equalTo(now.getYear()));
    // Check that search of the existing instances and items was done for first PO line only
    List<JsonObject> instancesSearches = getInstancesSearches();
    List<JsonObject> holdingsSearches = getHoldingsSearches();
    List<JsonObject> itemsSearches = getItemsSearches();
    assertNotNull(instancesSearches);
    assertNull(holdingsSearches);
    assertNotNull(itemsSearches);
    assertEquals(1, instancesSearches.size());
    CompositePoLine respLine1 = resp.getCompositePoLines().get(0);
    respLine1.getLocations().forEach(location -> {
        assertNull(location.getLocationId());
        assertNotNull(location.getHoldingId());
    });
    CompositePoLine respLine2 = resp.getCompositePoLines().get(1);
    respLine2.getLocations().forEach(location -> {
        assertNotNull(location.getLocationId());
        assertNull(location.getHoldingId());
    });
    List<JsonObject> createdInstances = getCreatedInstances();
    assertEquals(1, createdInstances.size(), "Quantity of created instance must be equal of line, if create inventory include instance");
    assertNotNull("Line must be connected to instance, if create inventory include instance", respLine1.getInstanceId());
    assertNotNull("Line must be connected to instance, if create inventory include instance", respLine2.getInstanceId());
    List<JsonObject> createdHoldings = getCreatedHoldings();
    assertEquals(3, createdHoldings.size(), "Quantity of created instance must be depended of quantity in the locations and create inventory include holding");
    verifyHoldingsCreated(3, createdHoldings, respLine1);
    verifyHoldingsCreated(0, createdHoldings, respLine2);
    // All existing and created items
    List<JsonObject> items = joinExistingAndNewItems();
    verifyItemsCreated(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, 4, items, respLine1);
    verifyItemsCreated(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, 0, items, respLine2);
    List<JsonObject> createdPieces = getCreatedPieces();
    createdPieces.stream().map(json -> json.mapTo(Piece.class)).filter(piece -> !OTHER.equals(piece.getFormat())).forEach(piece -> {
        assertNull(piece.getLocationId());
        assertNotNull(piece.getHoldingId());
    });
    createdPieces.stream().map(json -> json.mapTo(Piece.class)).filter(piece -> OTHER.equals(piece.getFormat())).forEach(piece -> {
        assertNotNull(piece.getLocationId());
        assertNull(piece.getHoldingId());
    });
    verifyOpenOrderPiecesCreated(items, resp.getCompositePoLines(), createdPieces, 4);
    verifyCalculatedData(resp);
}
Also used : PO_ID_OPEN_TO_BE_CLOSED(org.folio.TestConstants.PO_ID_OPEN_TO_BE_CLOSED) BeforeEach(org.junit.jupiter.api.BeforeEach) PO_WFD_ID_OPEN_STATUS(org.folio.TestConstants.PO_WFD_ID_OPEN_STATUS) ID_BAD_FORMAT(org.folio.TestConstants.ID_BAD_FORMAT) TestUtils.validatePoLineCreationErrorForNonPendingOrder(org.folio.TestUtils.validatePoLineCreationErrorForNonPendingOrder) INVALID_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.INVALID_CONFIG_X_OKAPI_TENANT) StringUtils(org.apache.commons.lang3.StringUtils) ApiTestSuite(org.folio.ApiTestSuite) ZERO_LOCATION_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_LOCATION_QTY) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) EMPTY_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.EMPTY_CONFIG_X_OKAPI_TENANT) ZoneOffset(java.time.ZoneOffset) ORDER_VENDOR_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.ORDER_VENDOR_NOT_FOUND) Errors(org.folio.rest.jaxrs.model.Errors) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) ID_FOR_INTERNAL_SERVER_ERROR(org.folio.TestConstants.ID_FOR_INTERNAL_SERVER_ERROR) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ORDER_CLOSED(org.folio.rest.core.exceptions.ErrorCodes.ORDER_CLOSED) Metadata(org.folio.rest.acq.model.finance.Metadata) VENDOR_ISSUE(org.folio.rest.core.exceptions.ErrorCodes.VENDOR_ISSUE) ErrorCodes(org.folio.rest.core.exceptions.ErrorCodes) OTHER(org.folio.rest.jaxrs.model.Piece.Format.OTHER) ZoneId(java.time.ZoneId) TestConfig.mockPort(org.folio.TestConfig.mockPort) Logger(org.apache.logging.log4j.Logger) Eresource(org.folio.rest.jaxrs.model.Eresource) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) MIN_PO_ID(org.folio.TestConstants.MIN_PO_ID) PO_LINES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) POProtectedFields(org.folio.orders.utils.POProtectedFields) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) RestClient(org.folio.rest.core.RestClient) INACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.INACTIVE_ACCESS_PROVIDER_B) INACTIVE_ACCESS_PROVIDER_A(org.folio.TestConstants.INACTIVE_ACCESS_PROVIDER_A) HelperUtils.calculateInventoryItemsQuantity(org.folio.orders.utils.HelperUtils.calculateInventoryItemsQuantity) PaymentStatus(org.folio.rest.acq.model.PaymentStatus) BUDGET_IS_INACTIVE_TENANT(org.folio.rest.impl.MockServer.BUDGET_IS_INACTIVE_TENANT) ACQUISITIONS_MEMBERSHIPS(org.folio.orders.utils.ResourcePathResolver.ACQUISITIONS_MEMBERSHIPS) Contributor(org.folio.rest.jaxrs.model.Contributor) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) ZERO_COST_ELECTRONIC_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_COST_ELECTRONIC_QTY) OrderFormat(org.folio.rest.jaxrs.model.CompositePoLine.OrderFormat) Answer(org.mockito.stubbing.Answer) MockServer.getHoldingsSearches(org.folio.rest.impl.MockServer.getHoldingsSearches) RestTestUtils.verifySuccessGet(org.folio.RestTestUtils.verifySuccessGet) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PO_LINES_EMPTY_COLLECTION_ID(org.folio.rest.impl.MockServer.PO_LINES_EMPTY_COLLECTION_ID) Physical(org.folio.rest.jaxrs.model.Physical) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10) RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) ELECTRONIC_COST_LOC_QTY_MISMATCH(org.folio.rest.core.exceptions.ErrorCodes.ELECTRONIC_COST_LOC_QTY_MISMATCH) MockServer.getPieceSearches(org.folio.rest.impl.MockServer.getPieceSearches) MockServer.getCreatedOrderSummaries(org.folio.rest.impl.MockServer.getCreatedOrderSummaries) PO_LINE_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_LINE_NUMBER) HelperUtils(org.folio.orders.utils.HelperUtils) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) Vertx(io.vertx.core.Vertx) RequestEntry(org.folio.rest.core.models.RequestEntry) IOException(java.io.IOException) X_OKAPI_URL(org.folio.TestConfig.X_OKAPI_URL) BUDGET_NOT_FOUND_FOR_TRANSACTION(org.folio.rest.core.exceptions.ErrorCodes.BUDGET_NOT_FOUND_FOR_TRANSACTION) ITEM_RECORDS(org.folio.rest.impl.MockServer.ITEM_RECORDS) ACQUISITIONS_UNITS(org.folio.orders.utils.ResourcePathResolver.ACQUISITIONS_UNITS) ExecutionException(java.util.concurrent.ExecutionException) PO_LINE_ID_FOR_SUCCESS_CASE(org.folio.TestConstants.PO_LINE_ID_FOR_SUCCESS_CASE) LEDGER_NOT_FOUND_FOR_TRANSACTION_TENANT(org.folio.rest.impl.MockServer.LEDGER_NOT_FOUND_FOR_TRANSACTION_TENANT) AfterEach(org.junit.jupiter.api.AfterEach) BUDGET_NOT_FOUND_FOR_TRANSACTION_TENANT(org.folio.rest.impl.MockServer.BUDGET_NOT_FOUND_FOR_TRANSACTION_TENANT) InventoryInteractionTestHelper.verifyPiecesCreated(org.folio.helper.InventoryInteractionTestHelper.verifyPiecesCreated) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PHYSICAL(org.folio.rest.jaxrs.model.Piece.Format.PHYSICAL) ENCUMBRANCE_PATH(org.folio.rest.impl.MockServer.ENCUMBRANCE_PATH) MockServer.getInstancesSearches(org.folio.rest.impl.MockServer.getInstancesSearches) PO_ID_PENDING_STATUS_WITH_PO_LINES(org.folio.TestConstants.PO_ID_PENDING_STATUS_WITH_PO_LINES) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_1(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_1) FUND_CANNOT_BE_PAID_TENANT(org.folio.rest.impl.MockServer.FUND_CANNOT_BE_PAID_TENANT) Date(java.util.Date) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) X_OKAPI_USER_ID(org.folio.TestConstants.X_OKAPI_USER_ID) TITLES(org.folio.orders.utils.ResourcePathResolver.TITLES) TestUtils.getInstanceId(org.folio.TestUtils.getInstanceId) Context(io.vertx.core.Context) ISBN_NOT_VALID(org.folio.rest.core.exceptions.ErrorCodes.ISBN_NOT_VALID) MockServer.getPurchaseOrderUpdates(org.folio.rest.impl.MockServer.getPurchaseOrderUpdates) MockServer.getCreatedItems(org.folio.rest.impl.MockServer.getCreatedItems) ReceiptStatus(org.folio.rest.jaxrs.model.CompositePoLine.ReceiptStatus) TestUtils(org.folio.TestUtils) ID(org.folio.TestConstants.ID) Location(org.folio.rest.jaxrs.model.Location) ORDER_VENDOR_IS_INACTIVE(org.folio.rest.core.exceptions.ErrorCodes.ORDER_VENDOR_IS_INACTIVE) ONGOING_NOT_ALLOWED(org.folio.rest.core.exceptions.ErrorCodes.ONGOING_NOT_ALLOWED) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) UUID(java.util.UUID) PO_ID_CLOSED_STATUS(org.folio.TestConstants.PO_ID_CLOSED_STATUS) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) ERROR_CAUSE(org.folio.helper.AbstractHelper.ERROR_CAUSE) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LocalDate(java.time.LocalDate) POLineFieldNames(org.folio.orders.utils.POLineFieldNames) ACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_B) POL_LINES_LIMIT_EXCEEDED(org.folio.rest.core.exceptions.ErrorCodes.POL_LINES_LIMIT_EXCEEDED) ACTIVE_ACCESS_PROVIDER_A(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_A) InventoryInteractionTestHelper.verifyPiecesQuantityForSuccessCase(org.folio.helper.InventoryInteractionTestHelper.verifyPiecesQuantityForSuccessCase) ZERO_COST_PHYSICAL_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_COST_PHYSICAL_QTY) TestUtils.getMockData(org.folio.TestUtils.getMockData) InventoryInteractionTestHelper.verifyHoldingsCreated(org.folio.helper.InventoryInteractionTestHelper.verifyHoldingsCreated) VENDOR_ID(org.folio.orders.utils.ResourcePathResolver.VENDOR_ID) MISSING_MATERIAL_TYPE(org.folio.rest.core.exceptions.ErrorCodes.MISSING_MATERIAL_TYPE) Encumbrance(org.folio.rest.acq.model.finance.Encumbrance) Matchers.empty(org.hamcrest.Matchers.empty) TestUtils.verifyLocationQuantity(org.folio.TestUtils.verifyLocationQuantity) PO_ID_PENDING_STATUS_WITHOUT_PO_LINES(org.folio.TestConstants.PO_ID_PENDING_STATUS_WITHOUT_PO_LINES) InventoryInteractionTestHelper.verifyItemsCreated(org.folio.helper.InventoryInteractionTestHelper.verifyItemsCreated) MockServer.getLoanTypesSearches(org.folio.rest.impl.MockServer.getLoanTypesSearches) CloseReason(org.folio.rest.jaxrs.model.CloseReason) NON_ZERO_COST_ELECTRONIC_QTY(org.folio.rest.core.exceptions.ErrorCodes.NON_ZERO_COST_ELECTRONIC_QTY) Error(org.folio.rest.jaxrs.model.Error) Collectors.toList(java.util.stream.Collectors.toList) Response(io.restassured.response.Response) ApplicationConfig(org.folio.config.ApplicationConfig) INVALID_LANG(org.folio.TestConstants.INVALID_LANG) POL_ACCESS_PROVIDER_IS_INACTIVE(org.folio.rest.core.exceptions.ErrorCodes.POL_ACCESS_PROVIDER_IS_INACTIVE) LogManager(org.apache.logging.log4j.LogManager) MockServer.getCreatedHoldings(org.folio.rest.impl.MockServer.getCreatedHoldings) MockServer.getInstanceTypesSearches(org.folio.rest.impl.MockServer.getInstanceTypesSearches) Arrays(java.util.Arrays) HelperUtils.calculateTotalQuantity(org.folio.orders.utils.HelperUtils.calculateTotalQuantity) COST_UNIT_PRICE_ELECTRONIC_INVALID(org.folio.rest.core.exceptions.ErrorCodes.COST_UNIT_PRICE_ELECTRONIC_INVALID) Matchers.not(org.hamcrest.Matchers.not) Header(io.restassured.http.Header) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.NON_EXIST_CONFIG_X_OKAPI_TENANT) Disabled(org.junit.jupiter.api.Disabled) TransactionCollection(org.folio.rest.acq.model.finance.TransactionCollection) Is(org.hamcrest.core.Is) AfterAll(org.junit.jupiter.api.AfterAll) BigDecimal(java.math.BigDecimal) MockitoAnnotations(org.mockito.MockitoAnnotations) InventoryInteractionTestHelper.joinExistingAndNewItems(org.folio.helper.InventoryInteractionTestHelper.joinExistingAndNewItems) Matcher(java.util.regex.Matcher) BUDGET_EXPENSE_CLASS_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.BUDGET_EXPENSE_CLASS_NOT_FOUND) BeforeAll(org.junit.jupiter.api.BeforeAll) Matchers.nullValue(org.hamcrest.Matchers.nullValue) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) Mockito.doReturn(org.mockito.Mockito.doReturn) MISSING_ONGOING(org.folio.rest.core.exceptions.ErrorCodes.MISSING_ONGOING) RestTestUtils.verifyPut(org.folio.RestTestUtils.verifyPut) Set(java.util.Set) RestTestUtils.verifyDeleteResponse(org.folio.RestTestUtils.verifyDeleteResponse) Fund(org.folio.rest.acq.model.finance.Fund) Matchers.startsWith(org.hamcrest.Matchers.startsWith) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) COST_UNIT_PRICE_INVALID(org.folio.rest.core.exceptions.ErrorCodes.COST_UNIT_PRICE_INVALID) PROTECTED_READ_ONLY_TENANT(org.folio.TestConstants.PROTECTED_READ_ONLY_TENANT) X_OKAPI_TOKEN(org.folio.TestConstants.X_OKAPI_TOKEN) PO_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_NUMBER) FinanceInteractionsTestHelper.verifyEncumbrancesOnPoUpdate(org.folio.helper.FinanceInteractionsTestHelper.verifyEncumbrancesOnPoUpdate) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) COMPOSITE_PO_LINES_PREFIX(org.folio.TestConstants.COMPOSITE_PO_LINES_PREFIX) CreateInventory(org.folio.rest.jaxrs.model.Physical.CreateInventory) Mock(org.mockito.Mock) ID_DOES_NOT_EXIST(org.folio.TestConstants.ID_DOES_NOT_EXIST) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) TransactionService(org.folio.service.finance.transaction.TransactionService) MockServer.getExistingOrderSummaries(org.folio.rest.impl.MockServer.getExistingOrderSummaries) Transaction(org.folio.rest.acq.model.finance.Transaction) MockServer.getCreatedEncumbrances(org.folio.rest.impl.MockServer.getCreatedEncumbrances) PAYMENT_STATUS(org.folio.orders.utils.ResourcePathResolver.PAYMENT_STATUS) ArrayList(java.util.ArrayList) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) INSTANCE_TYPE_CONTAINS_CODE_AS_INSTANCE_STATUS_TENANT_HEADER(org.folio.TestConstants.INSTANCE_TYPE_CONTAINS_CODE_AS_INSTANCE_STATUS_TENANT_HEADER) InvocationOnMock(org.mockito.invocation.InvocationOnMock) OKAPI_HEADER_PERMISSIONS(org.folio.helper.PurchaseOrderHelper.OKAPI_HEADER_PERMISSIONS) Matchers.lessThan(org.hamcrest.Matchers.lessThan) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InventoryInteractionTestHelper.verifyInventoryInteraction(org.folio.helper.InventoryInteractionTestHelper.verifyInventoryInteraction) InjectMocks(org.mockito.InjectMocks) COMP_ORDER_MOCK_DATA_PATH(org.folio.TestConstants.COMP_ORDER_MOCK_DATA_PATH) RestTestUtils.verifyGet(org.folio.RestTestUtils.verifyGet) Piece(org.folio.rest.jaxrs.model.Piece) COMPOSITE_PO_LINES(org.folio.orders.utils.HelperUtils.COMPOSITE_PO_LINES) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) JsonArray(io.vertx.core.json.JsonArray) AcqDesiredPermissions(org.folio.orders.utils.AcqDesiredPermissions) TestUtils.getMockAsJson(org.folio.TestUtils.getMockAsJson) GENERIC_ERROR_CODE(org.folio.rest.core.exceptions.ErrorCodes.GENERIC_ERROR_CODE) Cost(org.folio.rest.jaxrs.model.Cost) MockServer.getItemsSearches(org.folio.rest.impl.MockServer.getItemsSearches) MockServer.getContributorNameTypesSearches(org.folio.rest.impl.MockServer.getContributorNameTypesSearches) TimeoutException(java.util.concurrent.TimeoutException) PoLine(org.folio.rest.jaxrs.model.PoLine) Ongoing(org.folio.rest.acq.model.Ongoing) MISMATCH_BETWEEN_ID_IN_PATH_AND_BODY(org.folio.rest.core.exceptions.ErrorCodes.MISMATCH_BETWEEN_ID_IN_PATH_AND_BODY) MockServer.getItemUpdates(org.folio.rest.impl.MockServer.getItemUpdates) FUNDS(org.folio.orders.utils.ResourcePathResolver.FUNDS) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) StringUtils.containsAny(org.apache.commons.lang3.StringUtils.containsAny) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) InventoryInteractionTestHelper.verifyOpenOrderPiecesCreated(org.folio.helper.InventoryInteractionTestHelper.verifyOpenOrderPiecesCreated) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) BAD_QUERY(org.folio.TestConstants.BAD_QUERY) NON_EXIST_LOAN_TYPE_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_LOAN_TYPE_TENANT_HEADER) RestTestUtils.checkPreventProtectedFieldsModificationRule(org.folio.RestTestUtils.checkPreventProtectedFieldsModificationRule) PIECES_TO_BE_DELETED(org.folio.rest.core.exceptions.ErrorCodes.PIECES_TO_BE_DELETED) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) INSTANCE_ID_NOT_ALLOWED_FOR_PACKAGE_POLINE(org.folio.rest.core.exceptions.ErrorCodes.INSTANCE_ID_NOT_ALLOWED_FOR_PACKAGE_POLINE) InventoryInteractionTestHelper.verifyInventoryNonInteraction(org.folio.helper.InventoryInteractionTestHelper.verifyInventoryNonInteraction) InventoryInteractionTestHelper.verifyInstanceLinksForUpdatedOrder(org.folio.helper.InventoryInteractionTestHelper.verifyInstanceLinksForUpdatedOrder) PO_ID_OPEN_STATUS(org.folio.TestConstants.PO_ID_OPEN_STATUS) List(java.util.List) DistributionType(org.folio.rest.jaxrs.model.FundDistribution.DistributionType) EncumbranceService(org.folio.service.finance.transaction.EncumbranceService) Parameter(org.folio.rest.jaxrs.model.Parameter) Pattern(java.util.regex.Pattern) AcquisitionsUnitMembershipCollection(org.folio.rest.jaxrs.model.AcquisitionsUnitMembershipCollection) PIECES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PIECES_STORAGE) RECEIPT_STATUS(org.folio.orders.utils.ResourcePathResolver.RECEIPT_STATUS) ORGANIZATION_NOT_A_VENDOR(org.folio.rest.core.exceptions.ErrorCodes.ORGANIZATION_NOT_A_VENDOR) X_ECHO_STATUS(org.folio.TestConstants.X_ECHO_STATUS) OKAPI_HEADER_TENANT(org.folio.rest.RestVerticle.OKAPI_HEADER_TENANT) HashMap(java.util.HashMap) PO_LINE_NUMBER_VALUE(org.folio.TestConstants.PO_LINE_NUMBER_VALUE) MockServer.getCreatedInstances(org.folio.rest.impl.MockServer.getCreatedInstances) MockServer.getCreatedPieces(org.folio.rest.impl.MockServer.getCreatedPieces) Title(org.folio.rest.jaxrs.model.Title) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) ObjectUtils(org.apache.commons.lang3.ObjectUtils) RequestContext(org.folio.rest.core.models.RequestContext) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) RestTestUtils.prepareHeaders(org.folio.RestTestUtils.prepareHeaders) PURCHASE_ORDER_STORAGE(org.folio.orders.utils.ResourcePathResolver.PURCHASE_ORDER_STORAGE) PO_ID_OPEN_TO_CANCEL(org.folio.TestConstants.PO_ID_OPEN_TO_CANCEL) INCORRECT_FUND_DISTRIBUTION_TOTAL(org.folio.rest.core.exceptions.ErrorCodes.INCORRECT_FUND_DISTRIBUTION_TOTAL) PHYSICAL_COST_LOC_QTY_MISMATCH(org.folio.rest.core.exceptions.ErrorCodes.PHYSICAL_COST_LOC_QTY_MISMATCH) NON_EXIST_INSTANCE_STATUS_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_INSTANCE_STATUS_TENANT_HEADER) INACTIVE_EXPENSE_CLASS(org.folio.rest.core.exceptions.ErrorCodes.INACTIVE_EXPENSE_CLASS) MockServer.getInstanceStatusesSearches(org.folio.rest.impl.MockServer.getInstanceStatusesSearches) PurchaseOrderCollection(org.folio.rest.jaxrs.model.PurchaseOrderCollection) HttpMethod(io.vertx.core.http.HttpMethod) HttpStatus(org.folio.HttpStatus) X_OKAPI_USER_ID_WITH_ACQ_UNITS(org.folio.TestConstants.X_OKAPI_USER_ID_WITH_ACQ_UNITS) NON_EXIST_INSTANCE_TYPE_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_INSTANCE_TYPE_TENANT_HEADER) WorkflowStatus(org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus) ELECTRONIC(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC) Collections(java.util.Collections) ORDER_OPEN(org.folio.rest.core.exceptions.ErrorCodes.ORDER_OPEN) FinanceInteractionsTestHelper.verifyEncumbrancesOnPoCreation(org.folio.helper.FinanceInteractionsTestHelper.verifyEncumbrancesOnPoCreation) Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) JsonObject(io.vertx.core.json.JsonObject) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) LocalDate(java.time.LocalDate) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10

use of org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10 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 4 with EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10

use of org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10 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 5 with EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10

use of org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10 in project mod-orders by folio-org.

the class PurchaseOrdersApiTest method testPutOrdersByIdToChangeStatusToOpenWithCheckinItems.

@Test
void testPutOrdersByIdToChangeStatusToOpenWithCheckinItems() throws Exception {
    logger.info("=== Test Put Order By Id to change status of Order to Open ===");
    // Get Open Order
    CompositePurchaseOrder reqData = getMockDraftOrder().mapTo(CompositePurchaseOrder.class);
    reqData.setId(ID_FOR_PRINT_MONOGRAPH_ORDER);
    MockServer.addMockTitles(reqData.getCompositePoLines());
    // Make sure that mock PO has 2 po lines
    assertThat(reqData.getCompositePoLines(), hasSize(2));
    reqData.setWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN);
    // MODORDERS-183 Set the second POLine checkinItems true
    CompositePoLine line1 = reqData.getCompositePoLines().get(0);
    CompositePoLine line2 = reqData.getCompositePoLines().get(1);
    line2.setCheckinItems(true);
    reqData.getCompositePoLines().forEach(s -> s.setReceiptStatus(CompositePoLine.ReceiptStatus.PENDING));
    verifyPut(String.format(COMPOSITE_ORDERS_BY_ID_PATH, reqData.getId()), JsonObject.mapFrom(reqData), "", 204);
    List<JsonObject> respOrder = MockServer.serverRqRs.get(PURCHASE_ORDER_STORAGE, HttpMethod.GET);
    CompositePurchaseOrder compPo = respOrder.get(0).mapTo(CompositePurchaseOrder.class);
    List<JsonObject> respLines = MockServer.serverRqRs.get(PO_LINES_STORAGE, HttpMethod.PUT);
    CompositePoLine respLine1 = respLines.stream().filter(line -> line.getString(ID).equals(line1.getId())).peek(line -> line.remove("reportingCodes")).map(line -> line.mapTo(CompositePoLine.class)).filter(line -> Objects.nonNull(line.getLocations().get(0).getHoldingId())).distinct().findAny().get();
    CompositePoLine respLine2 = respLines.stream().filter(line -> line.getString(ID).equals(line2.getId())).peek(line -> line.remove("reportingCodes")).map(line -> line.mapTo(CompositePoLine.class)).filter(line -> Objects.nonNull(line.getLocations().get(0).getHoldingId())).findAny().get();
    compPo.setCompositePoLines(List.of(respLine1, respLine2));
    int polCount = compPo.getCompositePoLines().size();
    List<JsonObject> createdInstances = getCreatedInstances();
    assertEquals(2, createdInstances.size(), "Quantity of created instance must be equal of line, if create inventory include instance");
    assertNotNull("Line must be connected to instance, if create inventory include instance", respLine1.getInstanceId());
    assertNotNull("Line must be connected to instance, if create inventory include instance", respLine2.getInstanceId());
    List<JsonObject> createdHoldings = getCreatedHoldings();
    assertEquals(5, createdHoldings.size(), "Quantity of created instance must be depended of quantity in the locations and create inventory include holding");
    verifyHoldingsCreated(3, createdHoldings, respLine1);
    verifyHoldingsCreated(2, createdHoldings, respLine2);
    // All existing and created items
    List<JsonObject> items = joinExistingAndNewItems();
    verifyItemsCreated(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, 4, items, respLine1);
    verifyItemsCreated(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, 0, items, respLine2);
    List<JsonObject> createdPieces = getCreatedPieces();
    verifyOpenOrderPiecesCreated(items, compPo.getCompositePoLines(), createdPieces, 0);
    verifyReceiptStatusChangedTo(CompositePoLine.ReceiptStatus.AWAITING_RECEIPT.value(), compPo.getCompositePoLines().size());
    verifyPaymentStatusChangedTo(CompositePoLine.PaymentStatus.AWAITING_PAYMENT.value(), compPo.getCompositePoLines().size());
}
Also used : PO_ID_OPEN_TO_BE_CLOSED(org.folio.TestConstants.PO_ID_OPEN_TO_BE_CLOSED) BeforeEach(org.junit.jupiter.api.BeforeEach) PO_WFD_ID_OPEN_STATUS(org.folio.TestConstants.PO_WFD_ID_OPEN_STATUS) ID_BAD_FORMAT(org.folio.TestConstants.ID_BAD_FORMAT) TestUtils.validatePoLineCreationErrorForNonPendingOrder(org.folio.TestUtils.validatePoLineCreationErrorForNonPendingOrder) INVALID_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.INVALID_CONFIG_X_OKAPI_TENANT) StringUtils(org.apache.commons.lang3.StringUtils) ApiTestSuite(org.folio.ApiTestSuite) ZERO_LOCATION_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_LOCATION_QTY) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) EMPTY_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.EMPTY_CONFIG_X_OKAPI_TENANT) ZoneOffset(java.time.ZoneOffset) ORDER_VENDOR_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.ORDER_VENDOR_NOT_FOUND) Errors(org.folio.rest.jaxrs.model.Errors) TestConfig.clearServiceInteractions(org.folio.TestConfig.clearServiceInteractions) ID_FOR_INTERNAL_SERVER_ERROR(org.folio.TestConstants.ID_FOR_INTERNAL_SERVER_ERROR) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) ORDER_CLOSED(org.folio.rest.core.exceptions.ErrorCodes.ORDER_CLOSED) Metadata(org.folio.rest.acq.model.finance.Metadata) VENDOR_ISSUE(org.folio.rest.core.exceptions.ErrorCodes.VENDOR_ISSUE) ErrorCodes(org.folio.rest.core.exceptions.ErrorCodes) OTHER(org.folio.rest.jaxrs.model.Piece.Format.OTHER) ZoneId(java.time.ZoneId) TestConfig.mockPort(org.folio.TestConfig.mockPort) Logger(org.apache.logging.log4j.Logger) Eresource(org.folio.rest.jaxrs.model.Eresource) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) MIN_PO_ID(org.folio.TestConstants.MIN_PO_ID) PO_LINES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE) MockServer.addMockEntry(org.folio.rest.impl.MockServer.addMockEntry) POProtectedFields(org.folio.orders.utils.POProtectedFields) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) RestClient(org.folio.rest.core.RestClient) INACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.INACTIVE_ACCESS_PROVIDER_B) INACTIVE_ACCESS_PROVIDER_A(org.folio.TestConstants.INACTIVE_ACCESS_PROVIDER_A) HelperUtils.calculateInventoryItemsQuantity(org.folio.orders.utils.HelperUtils.calculateInventoryItemsQuantity) PaymentStatus(org.folio.rest.acq.model.PaymentStatus) BUDGET_IS_INACTIVE_TENANT(org.folio.rest.impl.MockServer.BUDGET_IS_INACTIVE_TENANT) ACQUISITIONS_MEMBERSHIPS(org.folio.orders.utils.ResourcePathResolver.ACQUISITIONS_MEMBERSHIPS) Contributor(org.folio.rest.jaxrs.model.Contributor) Every(org.hamcrest.core.Every) Headers(io.restassured.http.Headers) ZERO_COST_ELECTRONIC_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_COST_ELECTRONIC_QTY) OrderFormat(org.folio.rest.jaxrs.model.CompositePoLine.OrderFormat) Answer(org.mockito.stubbing.Answer) MockServer.getHoldingsSearches(org.folio.rest.impl.MockServer.getHoldingsSearches) RestTestUtils.verifySuccessGet(org.folio.RestTestUtils.verifySuccessGet) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PO_LINES_EMPTY_COLLECTION_ID(org.folio.rest.impl.MockServer.PO_LINES_EMPTY_COLLECTION_ID) Physical(org.folio.rest.jaxrs.model.Physical) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10) RestTestUtils.verifyPostResponse(org.folio.RestTestUtils.verifyPostResponse) ELECTRONIC_COST_LOC_QTY_MISMATCH(org.folio.rest.core.exceptions.ErrorCodes.ELECTRONIC_COST_LOC_QTY_MISMATCH) MockServer.getPieceSearches(org.folio.rest.impl.MockServer.getPieceSearches) MockServer.getCreatedOrderSummaries(org.folio.rest.impl.MockServer.getCreatedOrderSummaries) PO_LINE_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_LINE_NUMBER) HelperUtils(org.folio.orders.utils.HelperUtils) TestConfig.initSpringContext(org.folio.TestConfig.initSpringContext) Vertx(io.vertx.core.Vertx) RequestEntry(org.folio.rest.core.models.RequestEntry) IOException(java.io.IOException) X_OKAPI_URL(org.folio.TestConfig.X_OKAPI_URL) BUDGET_NOT_FOUND_FOR_TRANSACTION(org.folio.rest.core.exceptions.ErrorCodes.BUDGET_NOT_FOUND_FOR_TRANSACTION) ITEM_RECORDS(org.folio.rest.impl.MockServer.ITEM_RECORDS) ACQUISITIONS_UNITS(org.folio.orders.utils.ResourcePathResolver.ACQUISITIONS_UNITS) ExecutionException(java.util.concurrent.ExecutionException) PO_LINE_ID_FOR_SUCCESS_CASE(org.folio.TestConstants.PO_LINE_ID_FOR_SUCCESS_CASE) LEDGER_NOT_FOUND_FOR_TRANSACTION_TENANT(org.folio.rest.impl.MockServer.LEDGER_NOT_FOUND_FOR_TRANSACTION_TENANT) AfterEach(org.junit.jupiter.api.AfterEach) BUDGET_NOT_FOUND_FOR_TRANSACTION_TENANT(org.folio.rest.impl.MockServer.BUDGET_NOT_FOUND_FOR_TRANSACTION_TENANT) InventoryInteractionTestHelper.verifyPiecesCreated(org.folio.helper.InventoryInteractionTestHelper.verifyPiecesCreated) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) PHYSICAL(org.folio.rest.jaxrs.model.Piece.Format.PHYSICAL) ENCUMBRANCE_PATH(org.folio.rest.impl.MockServer.ENCUMBRANCE_PATH) MockServer.getInstancesSearches(org.folio.rest.impl.MockServer.getInstancesSearches) PO_ID_PENDING_STATUS_WITH_PO_LINES(org.folio.TestConstants.PO_ID_PENDING_STATUS_WITH_PO_LINES) EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_1(org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_1) FUND_CANNOT_BE_PAID_TENANT(org.folio.rest.impl.MockServer.FUND_CANNOT_BE_PAID_TENANT) Date(java.util.Date) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) X_OKAPI_USER_ID(org.folio.TestConstants.X_OKAPI_USER_ID) TITLES(org.folio.orders.utils.ResourcePathResolver.TITLES) TestUtils.getInstanceId(org.folio.TestUtils.getInstanceId) Context(io.vertx.core.Context) ISBN_NOT_VALID(org.folio.rest.core.exceptions.ErrorCodes.ISBN_NOT_VALID) MockServer.getPurchaseOrderUpdates(org.folio.rest.impl.MockServer.getPurchaseOrderUpdates) MockServer.getCreatedItems(org.folio.rest.impl.MockServer.getCreatedItems) ReceiptStatus(org.folio.rest.jaxrs.model.CompositePoLine.ReceiptStatus) TestUtils(org.folio.TestUtils) ID(org.folio.TestConstants.ID) Location(org.folio.rest.jaxrs.model.Location) ORDER_VENDOR_IS_INACTIVE(org.folio.rest.core.exceptions.ErrorCodes.ORDER_VENDOR_IS_INACTIVE) ONGOING_NOT_ALLOWED(org.folio.rest.core.exceptions.ErrorCodes.ONGOING_NOT_ALLOWED) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) UUID(java.util.UUID) PO_ID_CLOSED_STATUS(org.folio.TestConstants.PO_ID_CLOSED_STATUS) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) ERROR_CAUSE(org.folio.helper.AbstractHelper.ERROR_CAUSE) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LocalDate(java.time.LocalDate) POLineFieldNames(org.folio.orders.utils.POLineFieldNames) ACTIVE_ACCESS_PROVIDER_B(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_B) POL_LINES_LIMIT_EXCEEDED(org.folio.rest.core.exceptions.ErrorCodes.POL_LINES_LIMIT_EXCEEDED) ACTIVE_ACCESS_PROVIDER_A(org.folio.TestConstants.ACTIVE_ACCESS_PROVIDER_A) InventoryInteractionTestHelper.verifyPiecesQuantityForSuccessCase(org.folio.helper.InventoryInteractionTestHelper.verifyPiecesQuantityForSuccessCase) ZERO_COST_PHYSICAL_QTY(org.folio.rest.core.exceptions.ErrorCodes.ZERO_COST_PHYSICAL_QTY) TestUtils.getMockData(org.folio.TestUtils.getMockData) InventoryInteractionTestHelper.verifyHoldingsCreated(org.folio.helper.InventoryInteractionTestHelper.verifyHoldingsCreated) VENDOR_ID(org.folio.orders.utils.ResourcePathResolver.VENDOR_ID) MISSING_MATERIAL_TYPE(org.folio.rest.core.exceptions.ErrorCodes.MISSING_MATERIAL_TYPE) Encumbrance(org.folio.rest.acq.model.finance.Encumbrance) Matchers.empty(org.hamcrest.Matchers.empty) TestUtils.verifyLocationQuantity(org.folio.TestUtils.verifyLocationQuantity) PO_ID_PENDING_STATUS_WITHOUT_PO_LINES(org.folio.TestConstants.PO_ID_PENDING_STATUS_WITHOUT_PO_LINES) InventoryInteractionTestHelper.verifyItemsCreated(org.folio.helper.InventoryInteractionTestHelper.verifyItemsCreated) MockServer.getLoanTypesSearches(org.folio.rest.impl.MockServer.getLoanTypesSearches) CloseReason(org.folio.rest.jaxrs.model.CloseReason) NON_ZERO_COST_ELECTRONIC_QTY(org.folio.rest.core.exceptions.ErrorCodes.NON_ZERO_COST_ELECTRONIC_QTY) Error(org.folio.rest.jaxrs.model.Error) Collectors.toList(java.util.stream.Collectors.toList) Response(io.restassured.response.Response) ApplicationConfig(org.folio.config.ApplicationConfig) INVALID_LANG(org.folio.TestConstants.INVALID_LANG) POL_ACCESS_PROVIDER_IS_INACTIVE(org.folio.rest.core.exceptions.ErrorCodes.POL_ACCESS_PROVIDER_IS_INACTIVE) LogManager(org.apache.logging.log4j.LogManager) MockServer.getCreatedHoldings(org.folio.rest.impl.MockServer.getCreatedHoldings) MockServer.getInstanceTypesSearches(org.folio.rest.impl.MockServer.getInstanceTypesSearches) Arrays(java.util.Arrays) HelperUtils.calculateTotalQuantity(org.folio.orders.utils.HelperUtils.calculateTotalQuantity) COST_UNIT_PRICE_ELECTRONIC_INVALID(org.folio.rest.core.exceptions.ErrorCodes.COST_UNIT_PRICE_ELECTRONIC_INVALID) Matchers.not(org.hamcrest.Matchers.not) Header(io.restassured.http.Header) NON_EXIST_CONFIG_X_OKAPI_TENANT(org.folio.TestConstants.NON_EXIST_CONFIG_X_OKAPI_TENANT) Disabled(org.junit.jupiter.api.Disabled) TransactionCollection(org.folio.rest.acq.model.finance.TransactionCollection) Is(org.hamcrest.core.Is) AfterAll(org.junit.jupiter.api.AfterAll) BigDecimal(java.math.BigDecimal) MockitoAnnotations(org.mockito.MockitoAnnotations) InventoryInteractionTestHelper.joinExistingAndNewItems(org.folio.helper.InventoryInteractionTestHelper.joinExistingAndNewItems) Matcher(java.util.regex.Matcher) BUDGET_EXPENSE_CLASS_NOT_FOUND(org.folio.rest.core.exceptions.ErrorCodes.BUDGET_EXPENSE_CLASS_NOT_FOUND) BeforeAll(org.junit.jupiter.api.BeforeAll) Matchers.nullValue(org.hamcrest.Matchers.nullValue) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) Mockito.doReturn(org.mockito.Mockito.doReturn) MISSING_ONGOING(org.folio.rest.core.exceptions.ErrorCodes.MISSING_ONGOING) RestTestUtils.verifyPut(org.folio.RestTestUtils.verifyPut) Set(java.util.Set) RestTestUtils.verifyDeleteResponse(org.folio.RestTestUtils.verifyDeleteResponse) Fund(org.folio.rest.acq.model.finance.Fund) Matchers.startsWith(org.hamcrest.Matchers.startsWith) TestConfig.isVerticleNotDeployed(org.folio.TestConfig.isVerticleNotDeployed) COST_UNIT_PRICE_INVALID(org.folio.rest.core.exceptions.ErrorCodes.COST_UNIT_PRICE_INVALID) PROTECTED_READ_ONLY_TENANT(org.folio.TestConstants.PROTECTED_READ_ONLY_TENANT) X_OKAPI_TOKEN(org.folio.TestConstants.X_OKAPI_TOKEN) PO_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_NUMBER) FinanceInteractionsTestHelper.verifyEncumbrancesOnPoUpdate(org.folio.helper.FinanceInteractionsTestHelper.verifyEncumbrancesOnPoUpdate) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.endsWith(org.hamcrest.Matchers.endsWith) COMPOSITE_PO_LINES_PREFIX(org.folio.TestConstants.COMPOSITE_PO_LINES_PREFIX) CreateInventory(org.folio.rest.jaxrs.model.Physical.CreateInventory) Mock(org.mockito.Mock) ID_DOES_NOT_EXIST(org.folio.TestConstants.ID_DOES_NOT_EXIST) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) TransactionService(org.folio.service.finance.transaction.TransactionService) MockServer.getExistingOrderSummaries(org.folio.rest.impl.MockServer.getExistingOrderSummaries) Transaction(org.folio.rest.acq.model.finance.Transaction) MockServer.getCreatedEncumbrances(org.folio.rest.impl.MockServer.getCreatedEncumbrances) PAYMENT_STATUS(org.folio.orders.utils.ResourcePathResolver.PAYMENT_STATUS) ArrayList(java.util.ArrayList) MockServer.getQueryParams(org.folio.rest.impl.MockServer.getQueryParams) INSTANCE_TYPE_CONTAINS_CODE_AS_INSTANCE_STATUS_TENANT_HEADER(org.folio.TestConstants.INSTANCE_TYPE_CONTAINS_CODE_AS_INSTANCE_STATUS_TENANT_HEADER) InvocationOnMock(org.mockito.invocation.InvocationOnMock) OKAPI_HEADER_PERMISSIONS(org.folio.helper.PurchaseOrderHelper.OKAPI_HEADER_PERMISSIONS) Matchers.lessThan(org.hamcrest.Matchers.lessThan) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InventoryInteractionTestHelper.verifyInventoryInteraction(org.folio.helper.InventoryInteractionTestHelper.verifyInventoryInteraction) InjectMocks(org.mockito.InjectMocks) COMP_ORDER_MOCK_DATA_PATH(org.folio.TestConstants.COMP_ORDER_MOCK_DATA_PATH) RestTestUtils.verifyGet(org.folio.RestTestUtils.verifyGet) Piece(org.folio.rest.jaxrs.model.Piece) COMPOSITE_PO_LINES(org.folio.orders.utils.HelperUtils.COMPOSITE_PO_LINES) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) JsonArray(io.vertx.core.json.JsonArray) AcqDesiredPermissions(org.folio.orders.utils.AcqDesiredPermissions) TestUtils.getMockAsJson(org.folio.TestUtils.getMockAsJson) GENERIC_ERROR_CODE(org.folio.rest.core.exceptions.ErrorCodes.GENERIC_ERROR_CODE) Cost(org.folio.rest.jaxrs.model.Cost) MockServer.getItemsSearches(org.folio.rest.impl.MockServer.getItemsSearches) MockServer.getContributorNameTypesSearches(org.folio.rest.impl.MockServer.getContributorNameTypesSearches) TimeoutException(java.util.concurrent.TimeoutException) PoLine(org.folio.rest.jaxrs.model.PoLine) Ongoing(org.folio.rest.acq.model.Ongoing) MISMATCH_BETWEEN_ID_IN_PATH_AND_BODY(org.folio.rest.core.exceptions.ErrorCodes.MISMATCH_BETWEEN_ID_IN_PATH_AND_BODY) MockServer.getItemUpdates(org.folio.rest.impl.MockServer.getItemUpdates) FUNDS(org.folio.orders.utils.ResourcePathResolver.FUNDS) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) StringUtils.containsAny(org.apache.commons.lang3.StringUtils.containsAny) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) InventoryInteractionTestHelper.verifyOpenOrderPiecesCreated(org.folio.helper.InventoryInteractionTestHelper.verifyOpenOrderPiecesCreated) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) BAD_QUERY(org.folio.TestConstants.BAD_QUERY) NON_EXIST_LOAN_TYPE_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_LOAN_TYPE_TENANT_HEADER) RestTestUtils.checkPreventProtectedFieldsModificationRule(org.folio.RestTestUtils.checkPreventProtectedFieldsModificationRule) PIECES_TO_BE_DELETED(org.folio.rest.core.exceptions.ErrorCodes.PIECES_TO_BE_DELETED) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) HasPropertyWithValue(org.hamcrest.beans.HasPropertyWithValue) INSTANCE_ID_NOT_ALLOWED_FOR_PACKAGE_POLINE(org.folio.rest.core.exceptions.ErrorCodes.INSTANCE_ID_NOT_ALLOWED_FOR_PACKAGE_POLINE) InventoryInteractionTestHelper.verifyInventoryNonInteraction(org.folio.helper.InventoryInteractionTestHelper.verifyInventoryNonInteraction) InventoryInteractionTestHelper.verifyInstanceLinksForUpdatedOrder(org.folio.helper.InventoryInteractionTestHelper.verifyInstanceLinksForUpdatedOrder) PO_ID_OPEN_STATUS(org.folio.TestConstants.PO_ID_OPEN_STATUS) List(java.util.List) DistributionType(org.folio.rest.jaxrs.model.FundDistribution.DistributionType) EncumbranceService(org.folio.service.finance.transaction.EncumbranceService) Parameter(org.folio.rest.jaxrs.model.Parameter) Pattern(java.util.regex.Pattern) AcquisitionsUnitMembershipCollection(org.folio.rest.jaxrs.model.AcquisitionsUnitMembershipCollection) PIECES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PIECES_STORAGE) RECEIPT_STATUS(org.folio.orders.utils.ResourcePathResolver.RECEIPT_STATUS) ORGANIZATION_NOT_A_VENDOR(org.folio.rest.core.exceptions.ErrorCodes.ORGANIZATION_NOT_A_VENDOR) X_ECHO_STATUS(org.folio.TestConstants.X_ECHO_STATUS) OKAPI_HEADER_TENANT(org.folio.rest.RestVerticle.OKAPI_HEADER_TENANT) HashMap(java.util.HashMap) PO_LINE_NUMBER_VALUE(org.folio.TestConstants.PO_LINE_NUMBER_VALUE) MockServer.getCreatedInstances(org.folio.rest.impl.MockServer.getCreatedInstances) MockServer.getCreatedPieces(org.folio.rest.impl.MockServer.getCreatedPieces) Title(org.folio.rest.jaxrs.model.Title) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) ObjectUtils(org.apache.commons.lang3.ObjectUtils) RequestContext(org.folio.rest.core.models.RequestContext) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) RestTestUtils.prepareHeaders(org.folio.RestTestUtils.prepareHeaders) PURCHASE_ORDER_STORAGE(org.folio.orders.utils.ResourcePathResolver.PURCHASE_ORDER_STORAGE) PO_ID_OPEN_TO_CANCEL(org.folio.TestConstants.PO_ID_OPEN_TO_CANCEL) INCORRECT_FUND_DISTRIBUTION_TOTAL(org.folio.rest.core.exceptions.ErrorCodes.INCORRECT_FUND_DISTRIBUTION_TOTAL) PHYSICAL_COST_LOC_QTY_MISMATCH(org.folio.rest.core.exceptions.ErrorCodes.PHYSICAL_COST_LOC_QTY_MISMATCH) NON_EXIST_INSTANCE_STATUS_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_INSTANCE_STATUS_TENANT_HEADER) INACTIVE_EXPENSE_CLASS(org.folio.rest.core.exceptions.ErrorCodes.INACTIVE_EXPENSE_CLASS) MockServer.getInstanceStatusesSearches(org.folio.rest.impl.MockServer.getInstanceStatusesSearches) PurchaseOrderCollection(org.folio.rest.jaxrs.model.PurchaseOrderCollection) HttpMethod(io.vertx.core.http.HttpMethod) HttpStatus(org.folio.HttpStatus) X_OKAPI_USER_ID_WITH_ACQ_UNITS(org.folio.TestConstants.X_OKAPI_USER_ID_WITH_ACQ_UNITS) NON_EXIST_INSTANCE_TYPE_TENANT_HEADER(org.folio.TestConstants.NON_EXIST_INSTANCE_TYPE_TENANT_HEADER) WorkflowStatus(org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus) ELECTRONIC(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC) Collections(java.util.Collections) ORDER_OPEN(org.folio.rest.core.exceptions.ErrorCodes.ORDER_OPEN) FinanceInteractionsTestHelper.verifyEncumbrancesOnPoCreation(org.folio.helper.FinanceInteractionsTestHelper.verifyEncumbrancesOnPoCreation) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) JsonObject(io.vertx.core.json.JsonObject) TestUtils.getMinimalContentCompositePurchaseOrder(org.folio.TestUtils.getMinimalContentCompositePurchaseOrder) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)7 ArrayList (java.util.ArrayList)7 Arrays (java.util.Arrays)7 Collections (java.util.Collections)7 List (java.util.List)7 Objects (java.util.Objects)7 ExecutionException (java.util.concurrent.ExecutionException)7 TimeoutException (java.util.concurrent.TimeoutException)7 Collectors (java.util.stream.Collectors)7 APPLICATION_JSON (javax.ws.rs.core.MediaType.APPLICATION_JSON)7 LogManager (org.apache.logging.log4j.LogManager)7 Logger (org.apache.logging.log4j.Logger)7 ApiTestSuite (org.folio.ApiTestSuite)7 HttpStatus (org.folio.HttpStatus)7 Header (io.restassured.http.Header)5 Headers (io.restassured.http.Headers)5 RestTestUtils.prepareHeaders (org.folio.RestTestUtils.prepareHeaders)4 RestTestUtils.verifyPostResponse (org.folio.RestTestUtils.verifyPostResponse)4 TestConfig.clearServiceInteractions (org.folio.TestConfig.clearServiceInteractions)4 TestConfig.initSpringContext (org.folio.TestConfig.initSpringContext)4