From ff8641beca55868fdb5d4a5918303919f20723b8 Mon Sep 17 00:00:00 2001 From: alexanderkurash Date: Fri, 16 Feb 2024 13:56:45 +0200 Subject: [PATCH] MODTLR-19 Add GET mapping for transaction status --- .../org/folio/client/feign/DcbClient.java | 4 ++++ .../java/org/folio/client/DcbClientTest.java | 22 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/folio/client/feign/DcbClient.java b/src/main/java/org/folio/client/feign/DcbClient.java index 552dd453..4c6da8e9 100644 --- a/src/main/java/org/folio/client/feign/DcbClient.java +++ b/src/main/java/org/folio/client/feign/DcbClient.java @@ -5,6 +5,7 @@ import org.folio.domain.dto.TransactionStatusResponse; import org.folio.spring.config.FeignClientConfiguration; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -16,6 +17,9 @@ public interface DcbClient { @PostMapping("/ecs-tlr-transactions") DcbTransaction createDcbTransaction(DcbTransaction dcbTransaction); + @GetMapping("/transactions/{dcbTransactionId}/status") + TransactionStatusResponse getDcbTransactionStatus(@PathVariable String dcbTransactionId); + @PutMapping("/transactions/{dcbTransactionId}/status") TransactionStatusResponse changeDcbTransactionStatus(@PathVariable String dcbTransactionId, @RequestBody TransactionStatus newStatus); diff --git a/src/test/java/org/folio/client/DcbClientTest.java b/src/test/java/org/folio/client/DcbClientTest.java index 7c7766ab..f4f891df 100644 --- a/src/test/java/org/folio/client/DcbClientTest.java +++ b/src/test/java/org/folio/client/DcbClientTest.java @@ -33,12 +33,30 @@ void canCreateDcbTransaction() { assertEquals(response.getRequestId(), requestId); } + @Test + void canGetDcbTransactionStatus() { + String requestId = UUID.randomUUID().toString(); + String transactionId = UUID.randomUUID().toString(); + DcbTransaction dcbTransaction = new DcbTransaction() + .role(DcbTransaction.RoleEnum.BORROWER) + .requestId(requestId); + TransactionStatusResponse transactionStatusResponse = new TransactionStatusResponse() + .status(TransactionStatusResponse.StatusEnum.CANCELLED) + .message("test message") + .item(dcbTransaction.getItem()) + .patron(dcbTransaction.getPatron()) + .pickup(dcbTransaction.getPickup()) + .requestId(requestId); + when(dcbClient.getDcbTransactionStatus(transactionId)).thenReturn(transactionStatusResponse); + var response = dcbClient.getDcbTransactionStatus(transactionId); + assertNotNull(response); + assertEquals(response.getStatus(), TransactionStatusResponse.StatusEnum.CANCELLED); + } + @Test void canChangeDcbTransactionStatus() { String requestId = UUID.randomUUID().toString(); String transactionId = UUID.randomUUID().toString(); - TransactionStatus initialStatus = new TransactionStatus() - .status(TransactionStatus.StatusEnum.AWAITING_PICKUP); TransactionStatus targetStatus = new TransactionStatus() .status(TransactionStatus.StatusEnum.CANCELLED) .message("test message");