Skip to content

Commit

Permalink
Merge branch 'master' into CIRC-2136-floating-collections
Browse files Browse the repository at this point in the history
  • Loading branch information
nielserik authored Sep 23, 2024
2 parents 261420d + 7b49c91 commit 728ddea
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ramls/examples/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
{
"name": "Steve Jones"
}
]
],
"primaryContributor" : "Steve Jones"
},
"loanPolicyId" : "e9af4ba4-6801-4722-be45-d7a49d13564d",
"loanPolicy": {
Expand All @@ -37,7 +38,9 @@
"firstName" : "FirstName",
"lastName" : "LastName",
"middleName" : "MiddleName",
"barcode" : "102322966933815"
"barcode" : "102322966933815",
"preferredFirstName" : "preferredFirstName",
"patronGroup" : "3684a786-6671-4268-8ed0-9db82ebca60b"
},
"loanDate": "2017-03-01T23:11:00.000Z",
"dueDate": "2017-04-01T23:11:00.000Z",
Expand Down
15 changes: 15 additions & 0 deletions ramls/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
"description": "barcode used to identify the borrower (read only, defined by the server)",
"type": "string",
"readonly": true
},
"preferredFirstName": {
"description": "preferred first name of the borrower (read only, defined by the server)",
"type": "string",
"readonly": true
},
"patronGroup": {
"description": "current patron group of the borrower (read only, defined by the server)",
"type": "string",
"readonly": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -158,6 +168,11 @@
"additionalProperties": false
}
},
"primaryContributor": {
"description": "primary contributor of the item",
"type": "string",
"readonly": true
},
"holdingsRecordId": {
"description": "The ID of the holdings for the item",
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ private void additionalBorrowerProperties(JsonObject loanRepresentation, User bo
borrowerSummary.put("lastName", borrower.getLastName());
borrowerSummary.put("middleName", borrower.getMiddleName());
borrowerSummary.put("barcode", borrower.getBarcode());

borrowerSummary.put("preferredFirstName",borrower.getPreferredFirstName());
borrowerSummary.put("patronGroup",borrower.getPatronGroupId());
loanRepresentation.put(BORROWER, borrowerSummary);

additionalPatronGroupProperties(loanRepresentation, borrower.getPatronGroup());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public JsonObject createItemSummary(Item item) {
write(itemSummary, "title", item.isDcbItem() ? item.getDcbItemTitle() : item.getTitle());
write(itemSummary, "barcode", item.getBarcode());
write(itemSummary, "contributors", mapContributorNamesToJson(item));
write(itemSummary, "primaryContributor",item.getPrimaryContributorName());
write(itemSummary, "callNumber", item.getCallNumber());
write(itemSummary, "enumeration", item.getEnumeration());
write(itemSummary, "chronology", item.getChronology());
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/api/loans/LoanAPITests.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ void createLoanForDcbUserAndDcbItem() {
loan.getString("isDcb"), is("true"));
}

@Test
void canGetLoansWithAdditionalFieldsRequiredForDueDateSlip() {
loansFixture.createLoan(itemsFixture.basedUponSmallAngryPlanet(), usersFixture.KimJames());
JsonObject loan = loansFixture.getLoans().getFirst();

assertThat("Borrower has preferredFirstName",
loan.getJsonObject("borrower").containsKey("preferredFirstName"), is(true));

assertThat("Borrower has patronGroup",
loan.getJsonObject("borrower").containsKey("patronGroup"), is(true));

assertThat("Item has primaryContributor",
loan.getJsonObject("item").containsKey("primaryContributor"), is(true));
}

@Test
void canGetLoanWithoutOpenFeesFines() {
UUID id = UUID.randomUUID();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/api/support/fixtures/UserExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ static UserBuilder basedUponGroot() {
.withActive(true);
}

static UserBuilder basedUponJames() {
return new UserBuilder()
.withBarcode("6430530304")
.withPreferredFirstName("kim", "james", "kimJ")
.withActive(true);
}

static UserBuilder basedUponCharlotteBroadwell() {
return new UserBuilder()
.withName("Broadwell", "Charlotte")
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/api/support/fixtures/UsersFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static api.support.fixtures.UserExamples.basedUponCharlotteBroadwell;
import static api.support.fixtures.UserExamples.basedUponGroot;
import static api.support.fixtures.UserExamples.basedUponHenryHanks;
import static api.support.fixtures.UserExamples.basedUponJames;
import static api.support.fixtures.UserExamples.basedUponJamesRodwell;
import static api.support.fixtures.UserExamples.basedUponJessicaPontefract;
import static api.support.fixtures.UserExamples.basedUponRebeccaStuart;
Expand Down Expand Up @@ -40,6 +41,11 @@ public UserResource groot() {
.inGroupFor(patronGroupsFixture.regular()));
}

public UserResource KimJames() {
return createIfAbsent(basedUponJames()
.inGroupFor(patronGroupsFixture.staff()));
}

public UserResource james() {
return createIfAbsent(basedUponJamesRodwell()
.inGroupFor(patronGroupsFixture.regular()));
Expand Down

0 comments on commit 728ddea

Please sign in to comment.