Skip to content

Commit

Permalink
MODTLR-12 Change schema, response type
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkurash committed Feb 21, 2024
1 parent 5c2d694 commit 44a79cd
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/folio/client/feign/DcbClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.folio.client.feign;

import org.folio.domain.dto.DcbTransaction;
import org.folio.domain.dto.TransactionStatusResponse;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -9,6 +10,6 @@
public interface DcbClient {

@PostMapping("/ecs-tlr-transactions")
DcbTransaction createDcbTransaction(DcbTransaction dcbTransaction);
TransactionStatusResponse createDcbTransaction(DcbTransaction dcbTransaction);

}
4 changes: 4 additions & 0 deletions src/main/resources/swagger.api/ecs-tlr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ components:
$ref: 'schemas/EcsTlr.yaml#/EcsTlr'
dcbTransaction:
$ref: 'schemas/dcbTransaction.yaml#/DcbTransaction'
transactionStatus:
$ref: 'schemas/transactionStatus.yaml#/TransactionStatus'
transactionStatusResponse:
$ref: 'schemas/transactionStatusResponse.yaml#/TransactionStatusResponse'
errorResponse:
$ref: 'schemas/errors.json'
request:
Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/swagger.api/schemas/dcbTransaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ DcbTransaction:
properties:
item:
$ref: 'dcbItem.yaml#/DcbItem'
patron:
$ref: 'dcbPatron.yaml#/DcbPatron'
pickup:
$ref: 'dcbPickup.yaml#/DcbPickup'
role:
type: string
enum:
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/swagger.api/schemas/transactionStatus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TransactionStatus:
type: object
properties:
status:
type: string
enum:
- CREATED #Created by DCB
- OPEN #Item checked in at lending library
- AWAITING_PICKUP #Item checked in at borrowing/Pickup library
- ITEM_CHECKED_OUT #Item checkout by patron. Request is fulfilled and loan is created
- ITEM_CHECKED_IN #Item returned to borrowing/Pickup library
- CLOSED #Item returned to lending library
- CANCELLED #Request was cancelled
- ERROR #Error occurred
message:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TransactionStatusResponse:
allOf:
- $ref: 'transactionStatus.yaml#/TransactionStatus'
- $ref: 'dcbTransaction.yaml#/DcbTransaction'
8 changes: 7 additions & 1 deletion src/test/java/org/folio/client/DcbClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.folio.client.feign.DcbClient;
import org.folio.domain.dto.DcbTransaction;
import org.folio.domain.dto.TransactionStatusResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand All @@ -24,7 +25,12 @@ void canCreateDcbTransaction() {
DcbTransaction dcbTransaction = new DcbTransaction()
.role(DcbTransaction.RoleEnum.BORROWER)
.requestId(requestId);
when(dcbClient.createDcbTransaction(dcbTransaction)).thenReturn(dcbTransaction);
TransactionStatusResponse transactionStatusResponse = new TransactionStatusResponse()
.status(TransactionStatusResponse.StatusEnum.CANCELLED)
.message("test message")
.item(dcbTransaction.getItem())
.requestId(requestId);
when(dcbClient.createDcbTransaction(dcbTransaction)).thenReturn(transactionStatusResponse);
var response = dcbClient.createDcbTransaction(dcbTransaction);
assertNotNull(response);
assertEquals(DcbTransaction.RoleEnum.BORROWER, response.getRole());
Expand Down

0 comments on commit 44a79cd

Please sign in to comment.