use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method cannotCreateMultipleOpenLoansForSameItemViaPutToSpecificLocation.
@Test
public void cannotCreateMultipleOpenLoansForSameItemViaPutToSpecificLocation() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID itemId = UUID.randomUUID();
JsonObject firstLoanRequest = new LoanRequestBuilder().withItemId(itemId).open().create();
loansClient.create(firstLoanRequest);
JsonObject firstLoan = loansClient.getById(firstLoanRequest.getString("id")).getJson();
UUID secondLoanId = UUID.randomUUID();
JsonObject secondLoanRequest = new LoanRequestBuilder().withId(secondLoanId).withItemId(itemId).open().create();
JsonResponse createResponse = loansClient.attemptCreateOrReplace(secondLoanId.toString(), secondLoanRequest);
assertThat(createResponse, isValidationResponseWhich(hasMessage("Cannot have more than one open loan for the same item")));
assertCreateEventForLoan(firstLoan);
assertNoLoanEvent(secondLoanId.toString());
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method cannotCreateOpenLoanWithoutUserId.
@Test
public void cannotCreateOpenLoanWithoutUserId() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
final UUID loanId = UUID.randomUUID();
final LoanRequestBuilder loanRequest = new LoanRequestBuilder().withId(loanId).open().withNoUserId();
final JsonResponse putResponse = loansClient.attemptCreate(loanRequest);
assertThat(putResponse, isValidationResponseWhich(hasMessage("Open loan must have a user ID")));
assertNoLoanEvent(loanId.toString());
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateALoanWithOnlyRequiredProperties.
@Test
public void canCreateALoanWithOnlyRequiredProperties() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID id = UUID.randomUUID();
JsonObject loanRequest = new LoanRequestBuilder().withId(id).withNoStatus().withNoItemStatus().withLoanDate(new DateTime(2017, 3, 5, 14, 23, 41, DateTimeZone.UTC)).withAction("checkedout").create();
loansClient.create(loanRequest);
JsonObject loan = loansClient.getById(id).getJson();
assertThat("id does not match", loan.getString("id"), is(id.toString()));
assertThat(loan, isOpen());
assertCreateEventForLoan(loan);
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateMultipleClosedLoansForSameItem.
@Test
public void canCreateMultipleClosedLoansForSameItem() throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID itemId = UUID.randomUUID();
JsonObject firstLoanRequest = new LoanRequestBuilder().withItemId(itemId).closed().create();
loansClient.create(firstLoanRequest);
JsonObject firstLoan = loansClient.getById(firstLoanRequest.getString("id")).getJson();
JsonObject secondLoanRequest = new LoanRequestBuilder().withItemId(itemId).closed().create();
loansClient.create(secondLoanRequest);
JsonObject secondLoan = loansClient.getById(secondLoanRequest.getString("id")).getJson();
assertCreateEventForLoan(firstLoan);
assertCreateEventForLoan(secondLoan);
}
use of org.folio.rest.support.builders.LoanRequestBuilder in project mod-circulation-storage by folio-org.
the class LoansApiTest method canCreateALoanAtViaPutToSpecificLocation.
@Test
public void canCreateALoanAtViaPutToSpecificLocation() throws MalformedURLException, InterruptedException, ExecutionException, TimeoutException {
UUID id = UUID.randomUUID();
UUID itemId = UUID.randomUUID();
UUID userId = UUID.randomUUID();
UUID proxyUserId = UUID.randomUUID();
JsonObject loanRequest = new LoanRequestBuilder().withId(id).withItemId(itemId).withUserId(userId).withProxyUserId(proxyUserId).withLoanDate(new DateTime(2017, 2, 27, 21, 14, 43, DateTimeZone.UTC)).open().withAction("checkedout").withItemStatus("Checked out").withDueDate(new DateTime(2017, 3, 29, 21, 14, 43, DateTimeZone.UTC)).create();
loansClient.createAtSpecificLocation(id, loanRequest);
JsonObject loan = loansClient.getById(id).getJson();
assertThat("id does not match", loan.getString("id"), is(id.toString()));
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-02-27T21:14:43.000Z"));
assertThat(loan, isOpen());
assertThat("action is not checked out", loan.getString("action"), is("checkedout"));
assertThat("due date does not match", loan.getString("dueDate"), is("2017-03-29T21:14:43.000+00:00"));
assertCreateEventForLoan(loan);
}
Aggregations