Skip to content

Commit

Permalink
MODTLR-19 Add GET mapping for transaction status
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkurash committed Feb 16, 2024
1 parent 7b24ac7 commit ff8641b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/folio/client/feign/DcbClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
22 changes: 20 additions & 2 deletions src/test/java/org/folio/client/DcbClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit ff8641b

Please sign in to comment.