From 8d9435826308b6c2654a3c5f85e6c89c20c16a68 Mon Sep 17 00:00:00 2001 From: Roman_Barannyk Date: Tue, 16 Jan 2024 18:40:47 +0200 Subject: [PATCH] MODTLR-5 incorporating review comments --- descriptors/ModuleDescriptor-template.json | 8 ++------ .../java/org/folio/domain/entity/EcsTlrEntity.java | 11 ++++------- .../org/folio/service/impl/EcsTlrServiceImpl.java | 2 ++ src/main/resources/swagger.api/schemas/EcsTlr.yaml | 2 +- .../java/org/folio/service/EcsTlrServiceTest.java | 14 ++++++++------ 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 99e729d8..242fcd32 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -7,17 +7,13 @@ "version": "1.0", "handlers": [ { - "methods": [ - "GET" - ], + "methods": ["GET"], "pathPattern": "/tlr/ecs-tlr/{requestId}", "permissionsRequired": ["tlr.ecs-tlr.item.get"], "modulePermissions": [] }, { - "methods": [ - "POST" - ], + "methods": ["POST"], "pathPattern": "/tlr/ecs-tlr", "permissionsRequired": ["tlr.ecs-tlr.post"], "modulePermissions": [] diff --git a/src/main/java/org/folio/domain/entity/EcsTlrEntity.java b/src/main/java/org/folio/domain/entity/EcsTlrEntity.java index 6251efa1..6e467432 100644 --- a/src/main/java/org/folio/domain/entity/EcsTlrEntity.java +++ b/src/main/java/org/folio/domain/entity/EcsTlrEntity.java @@ -3,6 +3,7 @@ import java.util.UUID; import org.folio.domain.converter.UUIDConverter; +import org.joda.time.DateTime; import jakarta.persistence.Convert; import jakarta.persistence.Entity; @@ -10,16 +11,12 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.Getter; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; @Entity @Table(name = "ecs_tlr") -@Getter -@Setter -@ToString +@Data @AllArgsConstructor @NoArgsConstructor @Builder @@ -34,7 +31,7 @@ public class EcsTlrEntity { private UUID requesterId; private String requestType; private String requestLevel; - private String requestExpirationDate; + private DateTime requestExpirationDate; private String patronComments; private String fulfillmentPreference; @Convert(converter = UUIDConverter.class) diff --git a/src/main/java/org/folio/service/impl/EcsTlrServiceImpl.java b/src/main/java/org/folio/service/impl/EcsTlrServiceImpl.java index 8b5ea96d..43d20595 100644 --- a/src/main/java/org/folio/service/impl/EcsTlrServiceImpl.java +++ b/src/main/java/org/folio/service/impl/EcsTlrServiceImpl.java @@ -22,6 +22,8 @@ public class EcsTlrServiceImpl implements EcsTlrService { @Override public Optional get(UUID id) { + log.debug("get:: parameters id: {}", id); + return ecsTlrRepository.findById(id) .map(requestsMapper::mapEntityToDto); } diff --git a/src/main/resources/swagger.api/schemas/EcsTlr.yaml b/src/main/resources/swagger.api/schemas/EcsTlr.yaml index f6ea2f32..18815049 100644 --- a/src/main/resources/swagger.api/schemas/EcsTlr.yaml +++ b/src/main/resources/swagger.api/schemas/EcsTlr.yaml @@ -3,7 +3,7 @@ EcsTlr: type: "object" properties: id: - description: "Id of the ecs-tlr" + description: "ID of the ecs-tlr" $ref: "uuid.yaml" instanceId: description: "ID of the instance being requested" diff --git a/src/test/java/org/folio/service/EcsTlrServiceTest.java b/src/test/java/org/folio/service/EcsTlrServiceTest.java index d1bea0a7..0e651320 100644 --- a/src/test/java/org/folio/service/EcsTlrServiceTest.java +++ b/src/test/java/org/folio/service/EcsTlrServiceTest.java @@ -10,6 +10,7 @@ import org.folio.domain.dto.EcsTlr; import org.folio.domain.entity.EcsTlrEntity; import org.folio.domain.mapper.EcsTlrMapper; +import org.folio.domain.mapper.EcsTlrMapperImpl; import org.folio.repository.EcsTlrRepository; import org.folio.service.impl.EcsTlrServiceImpl; import org.joda.time.DateTime; @@ -17,6 +18,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) @@ -26,8 +28,8 @@ class EcsTlrServiceTest { private EcsTlrServiceImpl ecsTlrService; @Mock private EcsTlrRepository ecsTlrRepository; - @Mock - private EcsTlrMapper ecsTlrMapper; + @Spy + private final EcsTlrMapper ecsTlrMapper = new EcsTlrMapperImpl(); @Test void getById() { @@ -43,7 +45,7 @@ void postEcsTlr() { var requestType = EcsTlr.RequestTypeEnum.PAGE; var requestLevel = EcsTlr.RequestLevelEnum.TITLE; var fulfillmentPreference = EcsTlr.FulfillmentPreferenceEnum.HOLD_SHELF; - var requestExpirationDate = DateTime.now().toDate(); + var requestExpirationDate = DateTime.now(); var patronComments = "Test comment"; var mockEcsTlrEntity = new EcsTlrEntity(); @@ -51,7 +53,7 @@ void postEcsTlr() { mockEcsTlrEntity.setRequesterId(requesterId); mockEcsTlrEntity.setRequestType(requestType.getValue()); mockEcsTlrEntity.setRequestLevel(requestLevel.getValue()); - mockEcsTlrEntity.setRequestExpirationDate(requestExpirationDate.toString()); + mockEcsTlrEntity.setRequestExpirationDate(requestExpirationDate); mockEcsTlrEntity.setPatronComments(patronComments); mockEcsTlrEntity.setFulfillmentPreference(fulfillmentPreference.getValue()); mockEcsTlrEntity.setPickupServicePointId(pickupServicePointId); @@ -61,7 +63,7 @@ void postEcsTlr() { mockRequest.setRequesterId(requesterId.toString()); mockRequest.setRequestType(requestType); mockRequest.setRequestLevel(requestLevel); - mockRequest.setRequestExpirationDate(requestExpirationDate); + mockRequest.setRequestExpirationDate(requestExpirationDate.toDate()); mockRequest.setPatronComments(patronComments); mockRequest.setFulfillmentPreference(fulfillmentPreference); mockRequest.setPickupServicePointId(pickupServicePointId.toString()); @@ -75,7 +77,7 @@ void postEcsTlr() { assertEquals(instanceId.toString(), postEcsTlr.getInstanceId()); assertEquals(requesterId.toString(), postEcsTlr.getRequesterId()); assertEquals(requestType, postEcsTlr.getRequestType()); - assertEquals(requestExpirationDate, postEcsTlr.getRequestExpirationDate()); + assertEquals(requestExpirationDate.toDate(), postEcsTlr.getRequestExpirationDate()); assertEquals(patronComments, postEcsTlr.getPatronComments()); assertEquals(fulfillmentPreference, postEcsTlr.getFulfillmentPreference()); assertEquals(pickupServicePointId.toString(), postEcsTlr.getPickupServicePointId());