Skip to content

Commit

Permalink
Merge pull request #254 from folio-org/CIRCSTORE-229-release-12-0-2
Browse files Browse the repository at this point in the history
Release 12.0.2 CIRCSTORE-229
  • Loading branch information
marcjohnson-kint authored Jul 30, 2020
2 parents 991f14a + 36627bd commit 1f95eb9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 12.0.2 2020-07-30

* Introduces b-tree index for `status.name` property on `loan` records (CIRCSTORE-223)

## 12.0.1 2020-07-15

* Introduces b-tree index for `requestType` property on `request` records (CIRCSTORE-219)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mod-circulation-storage</artifactId>
<groupId>org.folio</groupId>
<version>12.0.2-SNAPSHOT</version>
<version>12.0.3-SNAPSHOT</version>
<licenses>
<license>
<name>Apache License 2.0</name>
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/templates/db_scripts/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
"tOps": "ADD",
"caseSensitive": false,
"removeAccents": false
},
{
"fieldName": "status.name",
"tOps": "ADD",
"caseSensitive": false,
"removeAccents": true
}
],
"fullTextIndex": [
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/org/folio/rest/api/LoansApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.notNullValue;
Expand All @@ -23,12 +25,14 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
Expand Down Expand Up @@ -1322,6 +1326,22 @@ public void cannotProvideAdditionalPropertiesInLoanStatus()
hasMessageContaining("Unrecognized field")));
}

@Test
public void canSearchByLoanStatus() throws Exception {
final IndividualResource openLoan = loansClient.create(
new LoanRequestBuilder().open().checkedOut());

loansClient.create(new LoanRequestBuilder().closed().checkedOut());

final List<String> openLoans = loansClient.getMany("status.name==Open")
.getRecords().stream()
.map(json -> json.getString("id"))
.collect(Collectors.toList());

assertThat(openLoans, hasSize(1));
assertThat(openLoans, hasItem(openLoan.getId()));
}

private JsonObject loanRequest() {
return new LoanRequestBuilder().create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static LoanRequestBuilder from(JsonObject example) {
final DateTime claimedReturnedDate = example.containsKey("claimedReturnedDate")
? DateTime.parse(example.getString("claimedReturnedDate"))
: null;

final JsonObject agedToLostDelayedBilling = example.containsKey("agedToLostDelayedBilling")
? example.getJsonObject("agedToLostDelayedBilling")
: null;
Expand Down Expand Up @@ -278,7 +278,7 @@ public JsonObject create() {
if (claimedReturnedDate != null) {
request.put("claimedReturnedDate", claimedReturnedDate.toString());
}

if (agedToLostDelayedBilling != null) {
request.put("agedToLostDelayedBilling", agedToLostDelayedBilling);
}
Expand Down Expand Up @@ -817,7 +817,7 @@ public LoanRequestBuilder withClaimedReturnedDate(DateTime claimedReturnedDate)
claimedReturnedDate,
this.agedToLostDelayedBilling);
}

public LoanRequestBuilder withAgedToLostDelayedBilling(JsonObject agedToLostDelayedBilling) {
return new LoanRequestBuilder(
this.id,
Expand All @@ -842,4 +842,8 @@ public LoanRequestBuilder withAgedToLostDelayedBilling(JsonObject agedToLostDela
this.claimedReturnedDate,
agedToLostDelayedBilling);
}

public LoanRequestBuilder checkedOut() {
return withAction("checkedout").withItemStatus("Checked out");
}
}

0 comments on commit 1f95eb9

Please sign in to comment.