Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODDCB-152 Support for intermediate requests #124

Merged
merged 6 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading