Skip to content

Commit

Permalink
MODTLR-12 Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkurash committed Feb 15, 2024
1 parent bb5c85e commit da5c96d
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/folio/client/feign/DcbClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.folio.client.feign;

import org.folio.domain.dto.DcbTransaction;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;

@FeignClient(name = "dcb", url = "${folio.okapi-url}", configuration = FeignClientConfiguration.class)
public interface DcbClient {

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

}
2 changes: 2 additions & 0 deletions src/main/resources/swagger.api/ecs-tlr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ components:
schemas:
ecs-tlr:
$ref: 'schemas/EcsTlr.yaml#/EcsTlr'
ecs-tlr-dcb-transaction:
$ref: 'schemas/DcbTransaction.yaml#/DcbTransaction'
errorResponse:
$ref: 'schemas/errors.json'
request:
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/swagger.api/schemas/DcbItem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DcbItem:
description: Item metadata required for the transaction
type: object
properties:
id:
description: The unique item identifier
$ref: "uuid.yaml"
title:
description: The title of the item that has been requested
type: string
barcode:
description: The barcode of the item as specified in the lending library
type: string
materialType:
description: The “hub-normalized” form of the item item type, used in the circulation rules for determining the correct loan policy.
type: string
lendingLibraryCode:
description: The code which identifies the lending library
type: string
13 changes: 13 additions & 0 deletions src/main/resources/swagger.api/schemas/DcbPatron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DcbPatron:
description: Patron metadata required for the transaction
type: object
properties:
id:
description: The unique identifier for the patron making the request as known in the requesting library
$ref: "uuid.yaml"
group:
description: The patron group associated with the requesting patron
type: string
barcode:
description: The barcode of the patron
type: string
13 changes: 13 additions & 0 deletions src/main/resources/swagger.api/schemas/DcbPickup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DcbPickup:
description: Pickup Location metadata required for the pickup service point
type: object
properties:
libraryCode:
description: The code which identifies the pickup library
type: string
servicePointId:
description: UUID of the pickup service point
type: string
servicePointName:
description: The name of the pickup service point
type: string
19 changes: 19 additions & 0 deletions src/main/resources/swagger.api/schemas/DcbTransaction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DcbTransaction:
type: object
properties:
item:
$ref: 'DcbItem.yaml#/DcbItem'
patron:
$ref: 'DcbPatron.yaml#/DcbPatron'
pickup:
$ref: 'DcbPickup.yaml#/DcbPickup'
role:
type: string
enum:
- LENDER
- BORROWER
- PICKUP
- BORROWING-PICKUP
requestId:
description: ID of the existing request
$ref: "uuid.yaml"
33 changes: 33 additions & 0 deletions src/test/java/org/folio/client/DcbClientTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.folio.client;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.when;

import java.util.UUID;

import org.folio.client.feign.DcbClient;
import org.folio.domain.dto.DcbTransaction;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class DcbClientTest {
@Mock
private DcbClient dcbClient;

@Test
void canCreateDcbTransaction() {
String requestId = UUID.randomUUID().toString();
DcbTransaction dcbTransaction = new DcbTransaction()
.role(DcbTransaction.RoleEnum.BORROWER)
.requestId(requestId);
when(dcbClient.createDcbTransaction(dcbTransaction)).thenReturn(dcbTransaction);
var response = dcbClient.createDcbTransaction(dcbTransaction);
assertNotNull(response);
assertEquals(response.getRole(), DcbTransaction.RoleEnum.BORROWER);
assertEquals(response.getRequestId(), requestId);
}
}

0 comments on commit da5c96d

Please sign in to comment.