Skip to content

Commit

Permalink
MODDCB-152 Support for intermediate requests (#124)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alexanderkurash authored Dec 9, 2024
1 parent 3271144 commit fd30651
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CirculationRequest:
enum:
- Primary
- Secondary
- Intermediate
requestLevel:
description: Level of the request - Item or Title
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/folio/dcb/utils/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fd30651

Please sign in to comment.