Skip to content

Commit

Permalink
Merge pull request #146 from folio-org/MODAUD-154
Browse files Browse the repository at this point in the history
Modaud 154
  • Loading branch information
Arghya22 authored Feb 10, 2023
2 parents 49b97ad + 65f6817 commit 4696a5f
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Descriptions {
public static final String CLAIMED_RETURNED_ITEM_MSG = " . Claimed returned item: ";
public static final String BACKDATED_TO_MSG = ". Backdated to: ";
public static final String OVERDUE_DUE_DATE_MSG = ". Overdue due date: ";
public static final String BILLED_MSG = "Fee/Fine type: %s. Fee/Fine owner: %s. Amount: %.2f. %s";
public static final String BILLED_MSG = "Fee/Fine type: %s. Fee/Fine owner: %s. Amount: %.2f. %s. Additional information to staff: %s";
public static final String CANCELLED_MSG = "Amount: %.2f. Cancellation reason: %s. Additional information to patron: %s.";
public static final String FEE_FINE_PAID_MSG = "Fee/Fine type: %s. Amount: %.2f. Balance: %.2f. Payment method: %s. Additional information to staff: %s. Additional information to patron: %s.";
public static final String FEE_FINE_WAIVED_MSG = "Fee/Fine type: %s. Amount: %.2f. Balance: %.2f. Waive reason: %s. Additional information to staff: %s. Additional information to patron: %s.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public String buildDescription(JsonObject logEventPayload) {
getProperty(logEventPayload, TYPE),
getProperty(logEventPayload, FEE_FINE_OWNER),
getDoubleProperty(logEventPayload, AMOUNT),
getBooleanProperty(logEventPayload, AUTOMATED) ? "automated" : "manual");
getBooleanProperty(logEventPayload, AUTOMATED) ? "automated" : "manual",
getProperty(logEventPayload, COMMENTS));
case PAID_FULLY:
case PAID_PARTIALLY:
return createDescriptionFor(FEE_FINE_PAID_MSG, logEventPayload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public enum FeeFineDescriptions {
BILLED("{\"userId\":\"6f36265e-722a-490a-b436-806e63af2ea7\",\"userBarcode\":\"693787594998493\",\"itemBarcode\":\"90000\",\"action\":\"Billed\",\"date\":\"2020-10-15T12:17:38.627Z\",\"servicePointId\":\"7c5abc9f-f3d7-4856-b8d7-6712462ca007\",\"source\":\"ADMINISTRATOR, DIKU\",\"feeFineId\":\"7ad9dfa0-6ee9-43ba-8db5-7a034ce05838\",\"feeFineOwner\":\"sample owner\",\"loanId\":\"0\",\"automated\":false,\"type\":\"manual charge\",\"paymentMethod\":\"cash\",\"amount\":10.0,\"balance\":0.0,\"comments\":\"STAFF : staff info \\n PATRON : patron info\"}",
"Fee/Fine type: manual charge. Fee/Fine owner: sample owner. Amount: 10.00. manual"),
"Fee/Fine type: manual charge. Fee/Fine owner: sample owner. Amount: 10.00. manual. Additional information to staff: STAFF : staff info \n PATRON : patron info"),
CANCELLED("{\"userId\":\"6f36265e-722a-490a-b436-806e63af2ea7\",\"userBarcode\":\"693787594998493\",\"itemBarcode\":\"90000\",\"action\":\"Cancelled as error\",\"date\":\"2020-10-15T12:17:38.627Z\",\"servicePointId\":\"7c5abc9f-f3d7-4856-b8d7-6712462ca007\",\"source\":\"ADMINISTRATOR, DIKU\",\"feeFineId\":\"7ad9dfa0-6ee9-43ba-8db5-7a034ce05838\",\"feeFineOwner\":\"sample owner\",\"loanId\":\"0\",\"automated\":false,\"type\":\"Paid fully\",\"paymentMethod\":\"cash\",\"amount\":10.0,\"balance\":0.0,\"comments\":\"STAFF : sample reason \\n PATRON : patron info\"}",
"Amount: 10.00. Cancellation reason: sample reason. Additional information to patron: patron info."),
PAID("{\"userId\":\"6f36265e-722a-490a-b436-806e63af2ea7\",\"userBarcode\":\"693787594998493\",\"itemBarcode\":\"90000\",\"action\":\"Paid fully\",\"date\":\"2020-10-15T12:17:38.627Z\",\"servicePointId\":\"7c5abc9f-f3d7-4856-b8d7-6712462ca007\",\"source\":\"ADMINISTRATOR, DIKU\",\"feeFineId\":\"7ad9dfa0-6ee9-43ba-8db5-7a034ce05838\",\"feeFineOwner\":\"sample owner\",\"loanId\":\"0\",\"automated\":false,\"type\":\"cash\",\"paymentMethod\":\"cash\",\"amount\":10.0,\"balance\":0.0,\"comments\":\"STAFF : staff info \\n PATRON : patron info\"}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.folio.builder.service;

import static org.folio.rest.jaxrs.model.LogRecord.Action.BILLED;
import static org.folio.utils.TenantApiTestUtil.FEE_FINE_PAYLOAD_JSON;
import static org.folio.utils.TenantApiTestUtil.getFile;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -15,7 +14,6 @@
import org.apache.logging.log4j.Logger;
import org.folio.builder.description.FeeFineDescriptionBuilder;
import org.folio.rest.jaxrs.model.LogRecord;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

Expand All @@ -24,11 +22,12 @@
public class FeeFineRecordBuilderTest extends BuilderTestBase {
private static final Logger logger = LogManager.getLogger();

@Test
void testFeeFine() throws Exception {
@ParameterizedTest
@EnumSource(FeeFineUtil.class)
void testFeeFine(FeeFineUtil feeFineUtil) throws Exception {
logger.info("===== Test fees/fines log records builder =====");

JsonObject payload = new JsonObject(getFile(FEE_FINE_PAYLOAD_JSON));
JsonObject payload = new JsonObject(getFile(feeFineUtil.getFileName()));
List<LogRecord> records = feeFineRecordBuilder.buildLogRecord(payload).get();

assertThat(records.size(), equalTo(1));
Expand All @@ -46,7 +45,7 @@ void testFeeFine() throws Exception {
assertThat(feeFineLogRecord.getServicePointId(), equalTo("7c5abc9f-f3d7-4856-b8d7-6712462ca007"));
assertThat(feeFineLogRecord.getSource(), equalTo("ADMINISTRATOR, DIKU"));
assertThat(feeFineLogRecord.getDescription(),
equalTo("Fee/Fine type: manual charge. Fee/Fine owner: sample owner. Amount: 10.00. manual"));
equalTo("Fee/Fine type: manual charge. Fee/Fine owner: sample owner. Amount: 10.00. "+ feeFineUtil.getType() +". Additional information to staff: Comments from Staff"));
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.folio.builder.service;

public enum FeeFineUtil {

MANUAL("payloads/fee_fine_billed.json","manual"),
AUTOMATED("payloads/fee_fine_billed_automated.json","automated");
private String fileName;
private String type;

FeeFineUtil(String fileName, String type) {
this.fileName = fileName;
this.type = type;
}

public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"itemBarcode":"90000",
"itemId":"100d10bf-2f06-4aa0-be15-0b95b2d9f9e3",
"action":"Billed",
"comments": "Comments from Staff",
"date":"2020-10-15T12:17:38.627Z",
"servicePointId":"7c5abc9f-f3d7-4856-b8d7-6712462ca007",
"source":"ADMINISTRATOR, DIKU",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"logEventType":"FEE_FINE",
"payload": {
"userId":"6f36265e-722a-490a-b436-806e63af2ea7",
"userBarcode":"693787594998493",
"itemBarcode":"90000",
"itemId":"100d10bf-2f06-4aa0-be15-0b95b2d9f9e3",
"action":"Billed",
"comments": "Comments from Staff",
"date":"2020-10-15T12:17:38.627Z",
"servicePointId":"7c5abc9f-f3d7-4856-b8d7-6712462ca007",
"source":"ADMINISTRATOR, DIKU",
"feeFineId":"7ad9dfa0-6ee9-43ba-8db5-7a034ce05838",
"feeFineOwner":"sample owner",
"loanId":"0",
"automated":true,
"type":"manual charge",
"amount":10.0
}
}

0 comments on commit 4696a5f

Please sign in to comment.