use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansAnonymizationApiTest method shouldNotAnonymizeLoansForOtherUser.
@Test
public void shouldNotAnonymizeLoansForOtherUser() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException {
final UUID firstUserId = UUID.randomUUID();
final UUID secondUserId = UUID.randomUUID();
final IndividualResource otherUsersLoan = loansClient.create(new LoanRequestBuilder().closed().withUserId(firstUserId));
anonymizeLoansFor(secondUserId);
final IndividualResource fetchedLoan = loansClient.getById(otherUsersLoan.getId());
assertThat(fetchedLoan.getJson().getString("userId"), isUUID(firstUserId));
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 PatronActionSessionAPITest method beforeTest.
@Before
public void beforeTest() throws InterruptedException, ExecutionException, TimeoutException, MalformedURLException {
CompletableFuture<RowSet<Row>> future = new CompletableFuture<>();
PostgresClient.getInstance(StorageTestSuite.getVertx(), TENANT_ID).delete(PATRON_ACTION_SESSION, new Criterion(), del -> future.complete(del.result()));
future.join();
JsonObject loan = loansClient.create(new LoanRequestBuilder().withId(UUID.randomUUID()).withItemId(UUID.randomUUID()).withUserId(UUID.randomUUID()).closed().create()).getJson();
existingLoanId = loan.getString("id");
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateOpenLoanWhenClosedLoansForSameItem.
@Test
public void canCreateOpenLoanWhenClosedLoansForSameItem() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID itemId = UUID.randomUUID();
JsonObject closedLoanRequest = new LoanRequestBuilder().withItemId(itemId).closed().create();
loansClient.create(closedLoanRequest);
JsonObject closedLoan = loansClient.getById(closedLoanRequest.getString("id")).getJson();
JsonObject openLoanRequest = new LoanRequestBuilder().withItemId(itemId).open().create();
loansClient.create(openLoanRequest);
JsonObject openLoan = loansClient.getById(openLoanRequest.getString("id")).getJson();
assertCreateEventForLoan(closedLoan);
assertCreateEventForLoan(openLoan);
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateALoanWithoutAnId.
@Test
public void canCreateALoanWithoutAnId() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID itemId = UUID.randomUUID();
UUID userId = UUID.randomUUID();
UUID proxyUserId = UUID.randomUUID();
JsonObject loanRequest = new LoanRequestBuilder().withNoId().withItemId(itemId).withUserId(userId).withProxyUserId(proxyUserId).withLoanDate(new DateTime(2017, 3, 20, 7, 21, 45, DateTimeZone.UTC)).open().withAction("checkedout").withItemStatus("Checked out").withDueDate(new DateTime(2017, 4, 20, 7, 21, 45, DateTimeZone.UTC)).create();
JsonObject loan = loansClient.create(loanRequest).getJson();
String newId = loan.getString("id");
assertThat(newId, is(notNullValue()));
assertThat("user id does not match", loan.getString("userId"), is(userId.toString()));
assertThat("proxy user id does not match", loan.getString("proxyUserId"), is(proxyUserId.toString()));
assertThat("item id does not match", loan.getString("itemId"), is(itemId.toString()));
assertThat("loan date does not match", loan.getString("loanDate"), is("2017-03-20T07:21:45.000Z"));
assertThat(loan, isOpen());
assertThat("action is not checked out", loan.getString("action"), is("checkedout"));
assertThat("item status is not checked out", loan.getString("itemStatus"), is("Checked out"));
assertThat("due date does not match", loan.getString("dueDate"), is("2017-04-20T07:21:45.000+00:00"));
assertCreateEventForLoan(loan);
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canSearchByLoanAgedToLostItemHasBeenBilled.
@Test
public void canSearchByLoanAgedToLostItemHasBeenBilled() throws Exception {
final IndividualResource billedLoan = loansClient.create(new LoanRequestBuilder().withAgedToLostDelayedBilling(true, DateTime.now(), DateTime.now()));
loansClient.create(new LoanRequestBuilder().withAgedToLostDelayedBilling(false, DateTime.now(), DateTime.now()));
final List<String> billedLoans = loansClient.getMany("agedToLostDelayedBilling.lostItemHasBeenBilled==true").getRecords().stream().map(json -> json.getString("id")).collect(Collectors.toList());
assertThat(billedLoans, hasSize(1));
assertThat(billedLoans, hasItem(billedLoan.getId()));
}
Aggregations