Skip to content

Commit

Permalink
MODTLR-5 incorporating review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Jan 16, 2024
1 parent 9c02c1e commit 8d94358
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
8 changes: 2 additions & 6 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/folio/domain/entity/EcsTlrEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
import java.util.UUID;

import org.folio.domain.converter.UUIDConverter;
import org.joda.time.DateTime;

import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/folio/service/impl/EcsTlrServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class EcsTlrServiceImpl implements EcsTlrService {

@Override
public Optional<EcsTlr> get(UUID id) {
log.debug("get:: parameters id: {}", id);

return ecsTlrRepository.findById(id)
.map(requestsMapper::mapEntityToDto);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/swagger.api/schemas/EcsTlr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 8 additions & 6 deletions src/test/java/org/folio/service/EcsTlrServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
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;
import org.junit.jupiter.api.Test;
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)
Expand All @@ -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() {
Expand All @@ -43,15 +45,15 @@ 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();
mockEcsTlrEntity.setInstanceId(instanceId);
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);
Expand All @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit 8d94358

Please sign in to comment.