use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canSearchByLoanItemStatus.
@Test
public void canSearchByLoanItemStatus() throws Exception {
final IndividualResource agedToLostLoan = loansClient.create(new LoanRequestBuilder().agedToLost());
loansClient.create(new LoanRequestBuilder().lostAndPaid());
final List<String> agedToLostLoans = loansClient.getMany("itemStatus==Aged to lost").getRecords().stream().map(json -> json.getString("id")).collect(Collectors.toList());
assertThat(agedToLostLoans, hasSize(1));
assertThat(agedToLostLoans, hasItem(agedToLostLoan.getId()));
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method cannotCreateALoanWithInvalidDates.
@Test
public void cannotCreateALoanWithInvalidDates() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
JsonObject loanRequest = new LoanRequestBuilder().create();
loanRequest.put("loanDate", "foo").put("returnDate", "bar");
JsonResponse response = loansClient.attemptCreate(loanRequest);
assertThat(String.format("Creating the loan should fail: %s", response.getBody()), response.getStatusCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
assertThat(response.getBody(), containsString("loan date must be a date time (in RFC3339 format)"));
assertThat(response.getBody(), containsString("return date must be a date time (in RFC3339 format)"));
assertNoLoanEvent(loanRequest.getString("id"));
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansAnonymizationApiTest method shouldAnonymizeSingleClosedLoanForUser.
@Test
public void shouldAnonymizeSingleClosedLoanForUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
final UUID userId = UUID.randomUUID();
final IndividualResource loan = loansClient.create(new LoanRequestBuilder().closed().withUserId(userId));
anonymizeLoansFor(userId);
final IndividualResource fetchedLoan = loansClient.getById(loan.getId());
assertThat("Should no longer have a user ID", fetchedLoan.getJson().containsKey("userId"), is(false));
assertThat("Anonymized loans should still be present", loansClient.getAll().getTotalRecords(), is(1));
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansAnonymizationApiTest method shouldAnonymizeSingleClosedLoanHistoryForUser.
@Test
public void shouldAnonymizeSingleClosedLoanHistoryForUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
final UUID userId = UUID.randomUUID();
final IndividualResource loan = loansClient.create(new LoanRequestBuilder().open().withUserId(userId));
loansClient.replace(loan.getId(), LoanRequestBuilder.from(loan.getJson()).withReturnDate(DateTime.now()).closed());
anonymizeLoansFor(userId);
final MultipleRecords<JsonObject> historyRecords = getLoanActionHistoryForUser(userId);
assertThat("Should be no history records for user", historyRecords.getRecords().size(), is(0));
assertThat("Should be no history records for user", historyRecords.getTotalRecords(), is(0));
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansAnonymizationApiTest method shouldNotAnonymizeOpenLoans.
@Test
public void shouldNotAnonymizeOpenLoans() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
final UUID userId = UUID.randomUUID();
final LoanRequestBuilder loanForUser = new LoanRequestBuilder().withUserId(userId);
final String firstOpenLoanId = loansClient.create(loanForUser.open().withItemId(UUID.randomUUID()).withId(UUID.randomUUID())).getId();
final String secondOpenLoanId = loansClient.create(loanForUser.open().withItemId(UUID.randomUUID()).withId(UUID.randomUUID())).getId();
anonymizeLoansFor(userId);
hasOpenLoansForUser(userId, firstOpenLoanId, secondOpenLoanId);
assertThat("Anonymized loans should still be present", loansClient.getAll().getTotalRecords(), is(2));
}
Aggregations