use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoansApiTest method omittedStatusFromReplacedLoanDefaultsToOpen.
@Test
public void omittedStatusFromReplacedLoanDefaultsToOpen() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
IndividualResource loan = loansClient.create(new LoanRequestBuilder().open().create());
JsonObject createdLoan = loan.copyJson();
LoanRequestBuilder returnedLoan = LoanRequestBuilder.from(createdLoan).withNoStatus();
loansClient.replace(loan.getId(), returnedLoan);
JsonObject updatedLoan = loansClient.getById(UUID.fromString(loan.getId())).getJson();
assertThat(updatedLoan, isOpen());
assertCreateEventForLoan(createdLoan);
assertUpdateEventForLoan(createdLoan, updatedLoan);
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoansApiTest method canSearchByLoanAgedToLostBillingDate.
@Test
public void canSearchByLoanAgedToLostBillingDate() throws Exception {
final DateTime today = DateTime.now();
final DateTime yesterday = today.minusDays(1);
final DateTime tomorrow = today.plusDays(1);
loansClient.create(new LoanRequestBuilder().withAgedToLostDelayedBilling(true, yesterday, DateTime.now()));
final IndividualResource loanToBillTomorrow = loansClient.create(new LoanRequestBuilder().withAgedToLostDelayedBilling(false, tomorrow, DateTime.now()));
final List<String> filteredLoans = loansClient.getMany(String.format("agedToLostDelayedBilling.dateLostItemShouldBeBilled > \"%s\"", today)).getRecords().stream().map(json -> json.getString("id")).collect(Collectors.toList());
assertThat(filteredLoans, hasSize(1));
assertThat(filteredLoans, hasItem(loanToBillTomorrow.getId()));
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoansApiTest method canRenewALoan.
@Test
public void canRenewALoan() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
DateTime loanDate = new DateTime(2017, DateTimeConstants.MARCH, 1, 13, 25, 46, DateTimeZone.UTC);
IndividualResource loan = loansClient.create(new LoanRequestBuilder().withLoanDate(loanDate).withDueDate(loanDate.plus(Period.days(14))).create());
JsonObject createdLoan = loan.getJson();
LoanRequestBuilder returnedLoan = LoanRequestBuilder.from(createdLoan).withDueDate(new DateTime(2017, DateTimeConstants.MARCH, 30, 13, 25, 46, DateTimeZone.UTC)).withAction("renewed").withActionComment("test action comment").withItemStatus("Checked out").withRenewalCount(1);
loansClient.replace(loan.getId(), returnedLoan);
JsonObject updatedLoan = loansClient.getById(UUID.fromString(loan.getId())).getJson();
assertThat(updatedLoan.getString("dueDate"), is("2017-03-30T13:25:46.000+00:00"));
assertThat(updatedLoan, isOpen());
assertThat("action is not renewed", updatedLoan.getString("action"), is("renewed"));
assertThat("action comment is incorrect", updatedLoan.getString("actionComment"), is("test action comment"));
assertThat("renewal count is not 1", updatedLoan.getInteger("renewalCount"), is(1));
assertThat("item status is not checked out", updatedLoan.getString("itemStatus"), is("Checked out"));
assertCreateEventForLoan(createdLoan);
assertUpdateEventForLoan(createdLoan, updatedLoan);
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateAnAlreadyClosedLoanWithoutUserId.
@Test
public void canCreateAnAlreadyClosedLoanWithoutUserId() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
UUID id = UUID.randomUUID();
JsonObject loanRequest = new LoanRequestBuilder().withId(id).withNoUserId().closed().create();
final IndividualResource createLoanResponse = loansClient.create(loanRequest);
JsonObject loan = createLoanResponse.getJson();
assertThat(loan, isClosed());
assertThat("should not have a user ID", loan.containsKey("userId"), is(false));
assertCreateEventForLoan(loan);
}
use of org.folio.rest.support.IndividualResource in project mod-circulation-storage by folio-org.
the class LoansApiTest method canDeleteALoan.
@Test
public void canDeleteALoan() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID id = UUID.randomUUID();
IndividualResource loanResouce = loansClient.create(new LoanRequestBuilder().withId(id).create());
loansClient.deleteById(id);
JsonResponse getResponse = loansClient.attemptGetById(id);
assertThat(getResponse, isNotFound());
JsonObject loan = loanResouce.getJson();
assertCreateEventForLoan(loan);
assertRemoveEventForLoan(loan);
}
Aggregations