Skip to content

Commit

Permalink
MODTLR-5 code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Jan 17, 2024
1 parent 3fedec9 commit 5bc0a06
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
8 changes: 1 addition & 7 deletions src/main/java/org/folio/controller/EcsTlrController.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.folio.controller;

import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;

import java.util.UUID;
Expand Down Expand Up @@ -35,11 +34,6 @@ public ResponseEntity<EcsTlr> getEcsTlrById(UUID requestId) {
public ResponseEntity<EcsTlr> postEcsTlr(EcsTlr ecsTlr) {
log.debug("postEcsTlr:: parameters ecsTlr: {}", ecsTlr);

try {
return ResponseEntity.status(CREATED).body(ecsTlrService.post(ecsTlr));
} catch (Exception e) {
log.error("postEcsTlr:: unexpected error: {}", e.getMessage());
return ResponseEntity.status(INTERNAL_SERVER_ERROR).body(ecsTlr);
}
return ResponseEntity.status(CREATED).body(ecsTlrService.post(ecsTlr));
}
}
11 changes: 2 additions & 9 deletions src/main/java/org/folio/domain/entity/EcsTlrEntity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package org.folio.domain.entity;

import java.util.Date;
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;
Expand All @@ -23,17 +20,13 @@
public class EcsTlrEntity {

@Id
@Convert(converter = UUIDConverter.class)
private UUID id;
@Convert(converter = UUIDConverter.class)
private UUID instanceId;
@Convert(converter = UUIDConverter.class)
private UUID requesterId;
private String requestType;
private String requestLevel;
private DateTime requestExpirationDate;
private Date requestExpirationDate;
private String patronComments;
private String fulfillmentPreference;
@Convert(converter = UUIDConverter.class)
private UUID pickupServicePointId;
}
2 changes: 1 addition & 1 deletion src/main/resources/db/changelog/changes/initial_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<column name="requester_id" type="uuid"/>
<column name="request_type" type="varchar(255)"/>
<column name="request_level" type="varchar(255)"/>
<column name="request_expiration_date" type="datetime"/>
<column name="request_expiration_date" type="timestamp with time zone"/>
<column name="patron_comments" type="varchar(255)"/>
<column name="fulfillment_preference" type="varchar(255)"/>
<column name="pickup_service_point_id" type="uuid"/>
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/folio/service/EcsTlrServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,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();
var requestExpirationDate = DateTime.now().toDate();
var patronComments = "Test comment";

var mockEcsTlrEntity = new EcsTlrEntity();
Expand All @@ -63,7 +63,7 @@ void postEcsTlr() {
mockRequest.setRequesterId(requesterId.toString());
mockRequest.setRequestType(requestType);
mockRequest.setRequestLevel(requestLevel);
mockRequest.setRequestExpirationDate(requestExpirationDate.toDate());
mockRequest.setRequestExpirationDate(requestExpirationDate);
mockRequest.setPatronComments(patronComments);
mockRequest.setFulfillmentPreference(fulfillmentPreference);
mockRequest.setPickupServicePointId(pickupServicePointId.toString());
Expand All @@ -77,7 +77,7 @@ void postEcsTlr() {
assertEquals(instanceId.toString(), postEcsTlr.getInstanceId());
assertEquals(requesterId.toString(), postEcsTlr.getRequesterId());
assertEquals(requestType, postEcsTlr.getRequestType());
assertEquals(requestExpirationDate.toDate(), postEcsTlr.getRequestExpirationDate());
assertEquals(requestExpirationDate, postEcsTlr.getRequestExpirationDate());
assertEquals(patronComments, postEcsTlr.getPatronComments());
assertEquals(fulfillmentPreference, postEcsTlr.getFulfillmentPreference());
assertEquals(pickupServicePointId.toString(), postEcsTlr.getPickupServicePointId());
Expand Down

0 comments on commit 5bc0a06

Please sign in to comment.