Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODAUD-177 Added the virtual item lookup if item is missed in Inventory #157

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"version": "1.2"
}
],
"optional": [
{
"id": "circulation-item",
"version": "1.0"
}
],
"provides": [
{
"id": "audit",
Expand Down Expand Up @@ -176,7 +182,8 @@
"templates.item.get",
"inventory.items.item.get",
"inventory-storage.holdings.item.get",
"circulation-storage.cancellation-reasons.collection.get"
"circulation-storage.cancellation-reasons.collection.get",
"circulation-item.item.get"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.folio.rest.RestVerticle.OKAPI_HEADER_TENANT;
import static org.folio.util.Constants.CIRCULATION_ITEM_URL;
import static org.folio.util.Constants.HOLDINGS_URL;
import static org.folio.util.Constants.ITEMS_URL;
import static org.folio.util.Constants.TEMPLATES_URL;
Expand Down Expand Up @@ -224,6 +225,8 @@ private void fetchUserPersonal(JsonObject payload, User user) {
public CompletableFuture<JsonObject> fetchItemDetails(JsonObject payload) {
LOGGER.debug("fetchItemDetails:: Fetching Item Details");
return handleGetRequest(String.format(URL_WITH_ID_PATTERN, ITEMS_URL, getProperty(payload, ITEM_ID)))
.thenCompose(itemJson -> nonNull(itemJson) ? CompletableFuture.completedFuture(itemJson) :
handleGetRequest(String.format(URL_WITH_ID_PATTERN, CIRCULATION_ITEM_URL, getProperty(payload, ITEM_ID))))
.thenCompose(itemJson -> addItemData(payload, itemJson))
.thenCompose(json ->
handleGetRequest(String.format(URL_WITH_ID_PATTERN, HOLDINGS_URL, getProperty(json, HOLDINGS_RECORD_ID))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class Constants {
private Constants(){}

public static final String ITEMS_URL = "/inventory/items";
public static final String CIRCULATION_ITEM_URL = "/circulation-item";
public static final String HOLDINGS_URL = "/holdings-storage/holdings";
public static final String TEMPLATES_URL = "/templates";
public static final String USERS_URL = "/users";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void getCirculationAuditLogRecordsNoFilter() {
logger.info("Get circulation audit log records: no filter");
given().headers(HEADERS).get(CIRCULATION_LOGS_ENDPOINT)
.then().log().all().statusCode(200)
.assertThat().body("totalRecords", equalTo(25));
.assertThat().body("totalRecords", equalTo(26));
}

@Test
Expand Down Expand Up @@ -115,6 +115,20 @@ void anonymizeLoanShouldRemoveUserDataFromRelatedRecords() {
.and().body("logRecords[5].linkToIds.userId", is(emptyOrNullString()));
}

@Test
void getFeeFineRelatedRecordOfVirtualItem() {
// For virtual item, holdingsId and instanceId needs to be present, then only FE validation will work.
// This record is already posted in beforeAll method so directly assert it using get endpoint with virtual item ID.
given().headers(HEADERS).get(CIRCULATION_LOGS_ENDPOINT + "?query=(items=100d10bf-2f06-4aa0-be15-0b95b2d9f9e4)")
.then().log().all().statusCode(200)
.assertThat()
.body("totalRecords", equalTo(1))
.body("logRecords[0].items[0].itemBarcode", is("virtualItem"))
.and().body("logRecords[0].items[0].itemId", is("100d10bf-2f06-4aa0-be15-0b95b2d9f9e4"))
.and().body("logRecords[0].items[0].instanceId", is("5bf370e0-8cca-4d9c-82e4-5170ab2a0a39"))
.and().body("logRecords[0].items[0].holdingId", is("e3ff6133-b9a2-4d4c-a1c9-dc1867d4df19"));
}

@Test
void getCirculationAuditLogRecordsMalformedQuery() {
logger.info("get circulation audit log records: malformed query");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class TenantApiTestUtil {
public static final String MANUAL_BLOCK_UPDATED_PAYLOAD_JSON = "payloads/manual_block_updated.json";
public static final String MANUAL_BLOCK_DELETED_PAYLOAD_JSON = "payloads/manual_block_deleted.json";
public static final String FEE_FINE_PAYLOAD_JSON = "payloads/fee_fine_billed.json";
public static final String FEE_FINE_VIRTUAL_ITEM_PAYLOAD_JSON = "payloads/fee_fine_billed_automated_virtual_item.json";
public static final String LOAN_PAYLOAD_JSON = "payloads/loan.json";
public static final String LOAN_ANONYMIZE_PAYLOAD_JSON = "payloads/anonymize_loan.json";
public static final String LOAN_AGE_TO_LOST_PAYLOAD_JSON = "payloads/loan_age_to_lost.json";
Expand Down Expand Up @@ -71,7 +72,7 @@ public class TenantApiTestUtil {
public static final String ANONYMIZE_LOAN_CLOSED = "payloads/anonymize_loan_closed.json";

public static final List<String> SAMPLES = Arrays.asList(CHECK_IN_PAYLOAD_JSON, CHECK_OUT_PAYLOAD_JSON, MANUAL_BLOCK_CREATED_PAYLOAD_JSON, MANUAL_BLOCK_UPDATED_PAYLOAD_JSON, MANUAL_BLOCK_DELETED_PAYLOAD_JSON,
FEE_FINE_PAYLOAD_JSON, LOAN_PAYLOAD_JSON, LOAN_AGE_TO_LOST_PAYLOAD_JSON, LOAN_WRONG_ACTION_JSON, LOAN_EMPTY_ACTION_JSON, NOTICE_PAYLOAD_JSON,
FEE_FINE_PAYLOAD_JSON, FEE_FINE_VIRTUAL_ITEM_PAYLOAD_JSON, LOAN_PAYLOAD_JSON, LOAN_AGE_TO_LOST_PAYLOAD_JSON, LOAN_WRONG_ACTION_JSON, LOAN_EMPTY_ACTION_JSON, NOTICE_PAYLOAD_JSON,
REQUEST_CREATED_THROUGH_OVERRIDE_PAYLOAD_JSON, REQUEST_CREATED_PAYLOAD_JSON, REQUEST_EDITED_PAYLOAD_JSON, REQUEST_MOVED_PAYLOAD_JSON,
REQUEST_REORDERED_PAYLOAD_JSON, REQUEST_CANCELLED_PAYLOAD_JSON, REQUEST_EXPIRED_PAYLOAD_JSON, ANONYMIZE_CHECK_OUT, ANONYMIZE_CHECK_IN, ANONYMIZE_LOAN_CLOSED);

Expand Down
11 changes: 11 additions & 0 deletions mod-audit-server/src/test/resources/mock_content.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@
"receivedPath": "mocks/item.json",
"status": 200
},
{
"url": "/inventory/items/100d10bf-2f06-4aa0-be15-0b95b2d9f9e4",
"method": "GET",
"status": 404
},
{
"url": "/circulation-item/100d10bf-2f06-4aa0-be15-0b95b2d9f9e4",
"method": "GET",
"receivedPath": "mocks/circulation-item.json",
"status": 200
},
{
"url": "/inventory/items/e038e283-4104-455d-80b7-e6d05ca4e5a7",
"method": "GET",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"barcode": "virtualItem",
"holdingsRecordId" : "e3ff6133-b9a2-4d4c-a1c9-dc1867d4df19"
}
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":"virtualItem",
"itemId":"100d10bf-2f06-4aa0-be15-0b95b2d9f9e4",
"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
}
}