Skip to content

Commit

Permalink
UICIRCLOG-149 Adding test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Vignesh-kalyanasundaram committed Dec 14, 2023
1 parent 20eaea0 commit bca2c8d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void fetchUserPersonal(JsonObject payload, User user) {

public CompletableFuture<JsonObject> fetchItemDetails(JsonObject payload) {
return handleGetRequest(String.format(URL_WITH_ID_PATTERN, ITEMS_URL, getProperty(payload, ITEM_ID)))
.thenCompose(itemJson -> itemJson != null ? CompletableFuture.completedFuture(itemJson) :
.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 ->
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 @@ -41,6 +41,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 @@ -69,7 +70,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
}
}

0 comments on commit bca2c8d

Please sign in to comment.