use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPIProxyTests method cannotCreateProxiedLoanWhenRelationshipHasExpired.
@Test
void cannotCreateProxiedLoanWhenRelationshipHasExpired() {
UUID id = UUID.randomUUID();
UUID itemId = itemsFixture.basedUponSmallAngryPlanet().getId();
IndividualResource sponsor = usersFixture.jessica();
IndividualResource proxy = usersFixture.james();
proxyRelationshipsFixture.expiredProxyFor(sponsor, proxy);
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
LoanBuilder loan = new LoanBuilder().withId(id).open().withUserId(sponsor.getId()).withProxyUserId(proxy.getId()).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate);
Response postResponse = loansFixture.attemptToCreateLoan(loan, 422);
assertThat(postResponse.getJson(), hasErrorWith(hasMessage("proxyUserId is not valid")));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPIProxyTests method cannotUpdateProxiedLoanWhenRelationshipHasExpired.
@Test
void cannotUpdateProxiedLoanWhenRelationshipHasExpired() {
UUID id = UUID.randomUUID();
UUID itemId = itemsFixture.basedUponSmallAngryPlanet().getId();
IndividualResource sponsor = usersFixture.jessica();
IndividualResource proxy = usersFixture.james();
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
loansFixture.createLoan(new LoanBuilder().withId(id).open().withUserId(sponsor.getId()).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate));
proxyRelationshipsFixture.expiredProxyFor(sponsor, proxy);
JsonObject updatedLoan = new LoanBuilder().withId(id).open().withUserId(sponsor.getId()).withProxyUserId(proxy.getId()).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate).create();
Response putResponse = loansFixture.attemptToReplaceLoan(id, updatedLoan);
assertThat("Invalid proxy should fail loan update", putResponse.getStatusCode(), is(422));
assertThat(putResponse.getJson(), hasErrorWith(hasMessage("proxyUserId is not valid")));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPIProxyTests method cannotCreateProxiedLoanWhenRelationshipIsInactive.
@Test
void cannotCreateProxiedLoanWhenRelationshipIsInactive() {
UUID id = UUID.randomUUID();
UUID itemId = itemsFixture.basedUponSmallAngryPlanet().getId();
IndividualResource sponsor = usersFixture.jessica();
IndividualResource proxy = usersFixture.james();
proxyRelationshipsFixture.inactiveProxyFor(sponsor, proxy);
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
LoanBuilder loan = new LoanBuilder().withId(id).open().withUserId(sponsor.getId()).withProxyUserId(proxy.getId()).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate);
Response postResponse = loansFixture.attemptToCreateLoan(loan, 422);
assertThat(postResponse.getJson(), hasErrorWith(hasMessage("proxyUserId is not valid")));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPIProxyTests method cannotCreateProxiedLoanWhenNoRelationship.
@Test
void cannotCreateProxiedLoanWhenNoRelationship() {
UUID id = UUID.randomUUID();
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
UUID itemId = itemsFixture.basedUponSmallAngryPlanet().getId();
IndividualResource requestingUser = usersFixture.jessica();
IndividualResource userAttemptingToProxy = usersFixture.james();
LoanBuilder loan = new LoanBuilder().withId(id).open().withUserId(requestingUser.getId()).withProxyUserId(userAttemptingToProxy.getId()).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate);
Response postResponse = loansFixture.attemptToCreateLoan(loan, 422);
assertThat(postResponse.getJson(), hasErrorWith(hasMessage("proxyUserId is not valid")));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPITests method cannotCreateALoanWithUnknownCheckOutServicePointId.
@Test
void cannotCreateALoanWithUnknownCheckOutServicePointId() {
UUID id = UUID.randomUUID();
UUID itemId = itemsFixture.basedUponSmallAngryPlanet().getId();
UUID userId = usersFixture.charlotte().getId();
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
final UUID unknownServicePointId = UUID.randomUUID();
final Response response = loansFixture.attemptToCreateLoan(new LoanBuilder().withId(id).withCheckoutServicePointId(unknownServicePointId).open().withUserId(userId).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate), UNPROCESSABLE_ENTITY);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Check Out Service Point does not exist"), hasUUIDParameter("checkoutServicePointId", unknownServicePointId))));
}
Aggregations