From fd3065187367d8cc299f377c9ec4ef00541423ac Mon Sep 17 00:00:00 2001 From: Alexander Kurash Date: Mon, 9 Dec 2024 22:13:46 +0200 Subject: [PATCH] MODDCB-152 Support for intermediate requests (#124) * MODDCB-147 Add support for Intermediate phase * MODDCB-147 Add PICKUP transaction support * MODDCB-152 Add tests * MODDCB-152 Refactor * MODDCB-152 Revert string format * MODDCB-152 Revert throw --- .../impl/EcsRequestTransactionsServiceImpl.java | 4 +++- .../swagger.api/schemas/CirculationRequest.yaml | 1 + .../EcsRequestTransactionsApiControllerTest.java | 14 ++++++++++++++ src/test/java/org/folio/dcb/utils/EntityUtils.java | 9 +++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/folio/dcb/service/impl/EcsRequestTransactionsServiceImpl.java b/src/main/java/org/folio/dcb/service/impl/EcsRequestTransactionsServiceImpl.java index 722660b2..9487bc87 100644 --- a/src/main/java/org/folio/dcb/service/impl/EcsRequestTransactionsServiceImpl.java +++ b/src/main/java/org/folio/dcb/service/impl/EcsRequestTransactionsServiceImpl.java @@ -1,7 +1,9 @@ package org.folio.dcb.service.impl; +import static java.lang.String.format; import static org.folio.dcb.domain.dto.DcbTransaction.RoleEnum.BORROWER; import static org.folio.dcb.domain.dto.DcbTransaction.RoleEnum.LENDER; +import static org.folio.dcb.domain.dto.DcbTransaction.RoleEnum.PICKUP; import java.util.UUID; @@ -49,7 +51,7 @@ public TransactionStatusResponse createEcsRequestTransactions(String ecsRequestT RequestStatus.from(circulationRequest.getStatus()))) { if (dcbTransaction.getRole() == LENDER) { createLenderEcsRequestTransactions(ecsRequestTransactionsId, dcbTransaction, circulationRequest); - } else if(dcbTransaction.getRole() == BORROWER) { + } else if(dcbTransaction.getRole() == BORROWER || dcbTransaction.getRole() == PICKUP) { createBorrowerEcsRequestTransactions(ecsRequestTransactionsId, dcbTransaction, circulationRequest); } else { diff --git a/src/main/resources/swagger.api/schemas/CirculationRequest.yaml b/src/main/resources/swagger.api/schemas/CirculationRequest.yaml index a8fb0c56..c45a1fd3 100644 --- a/src/main/resources/swagger.api/schemas/CirculationRequest.yaml +++ b/src/main/resources/swagger.api/schemas/CirculationRequest.yaml @@ -18,6 +18,7 @@ CirculationRequest: enum: - Primary - Secondary + - Intermediate requestLevel: description: Level of the request - Item or Title type: string diff --git a/src/test/java/org/folio/dcb/controller/EcsRequestTransactionsApiControllerTest.java b/src/test/java/org/folio/dcb/controller/EcsRequestTransactionsApiControllerTest.java index 3b30281f..c984645f 100644 --- a/src/test/java/org/folio/dcb/controller/EcsRequestTransactionsApiControllerTest.java +++ b/src/test/java/org/folio/dcb/controller/EcsRequestTransactionsApiControllerTest.java @@ -3,6 +3,7 @@ import static org.folio.dcb.utils.EntityUtils.CIRCULATION_REQUEST_ID; import static org.folio.dcb.utils.EntityUtils.createBorrowingEcsRequestTransactionByRole; import static org.folio.dcb.utils.EntityUtils.createLendingEcsRequestTransactionByRole; +import static org.folio.dcb.utils.EntityUtils.createPickupEcsRequestTransactionByRole; import static org.hamcrest.Matchers.is; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; @@ -83,6 +84,19 @@ void createBorrowingEcsRequestTest() throws Exception { .andExpect(status().isCreated()); } + @Test + void createPickupEcsRequestTest() throws Exception { + removeExistedTransactionFromDbIfSoExists(); + + this.mockMvc.perform( + post("/ecs-request-transactions/" + CIRCULATION_REQUEST_ID) + .content(asJsonString(createPickupEcsRequestTransactionByRole())) + .headers(defaultHeaders()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isCreated()); + } + @Test void checkErrorStatusForInvalidRequest() throws Exception { DcbTransaction dcbTransaction = createLendingEcsRequestTransactionByRole(); diff --git a/src/test/java/org/folio/dcb/utils/EntityUtils.java b/src/test/java/org/folio/dcb/utils/EntityUtils.java index 48d1b1e1..0970e914 100644 --- a/src/test/java/org/folio/dcb/utils/EntityUtils.java +++ b/src/test/java/org/folio/dcb/utils/EntityUtils.java @@ -92,6 +92,15 @@ public static DcbTransaction createBorrowingEcsRequestTransactionByRole() { .build(); } + public static DcbTransaction createPickupEcsRequestTransactionByRole() { + return DcbTransaction.builder() + .requestId(REQUEST_ID) + .item(createDcbItem()) + .role(DcbTransaction.RoleEnum.PICKUP) + .pickup(createDcbPickup()) + .build(); + } + public static org.folio.dcb.domain.dto.ServicePointRequest createServicePointRequest() { return org.folio.dcb.domain.dto.ServicePointRequest.builder() .id(PICKUP_SERVICE_POINT_ID)