use of api.support.builders.UserManualBlockBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method canCreateRequestWhenRequesterNotHaveActiveManualBlocks.
@Test
void canCreateRequestWhenRequesterNotHaveActiveManualBlocks() {
final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requester = usersFixture.rebecca();
final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
final ZonedDateTime now = ClockUtil.getZonedDateTime();
final ZonedDateTime expirationDate = now.plusDays(4);
final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
userManualBlocksFixture.create(userManualBlockBuilder);
Response postResponse = requestsClient.attemptCreate(requestBuilder);
assertThat(postResponse, hasStatus(HTTP_CREATED));
}
use of api.support.builders.UserManualBlockBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method cannotCreateRequestWhenRequesterHasSomeActiveRequestManualBlocks.
@Test
void cannotCreateRequestWhenRequesterHasSomeActiveRequestManualBlocks() {
final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requester = usersFixture.rebecca();
final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
final ZonedDateTime now = ClockUtil.getZonedDateTime();
final ZonedDateTime expirationDate = now.plusDays(4);
final UserManualBlockBuilder requestUserManualBlockBuilder1 = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
final UserManualBlockBuilder requestUserManualBlockBuilder2 = getManualBlockBuilder().withBorrowing(true).withRenewals(true).withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId())).withDesc("Test");
final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
userManualBlocksFixture.create(requestUserManualBlockBuilder1);
userManualBlocksFixture.create(requestUserManualBlockBuilder2);
Response postResponse = requestsClient.attemptCreate(requestBuilder);
assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
assertThat(postResponse.getJson(), hasErrors(1));
assertThat(postResponse.getJson(), hasErrorWith(hasMessage("Patron blocked from requesting")));
}
use of api.support.builders.UserManualBlockBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method canCreateRequestWhenRequesterHasManualExpiredBlock.
@Test
void canCreateRequestWhenRequesterHasManualExpiredBlock() {
final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requester = usersFixture.rebecca();
final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
final ZonedDateTime now = ClockUtil.getZonedDateTime();
final ZonedDateTime expirationDate = now.minusDays(1);
final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
userManualBlocksFixture.create(userManualBlockBuilder);
Response postResponse = requestsClient.attemptCreate(requestBuilder);
assertThat(postResponse, hasStatus(HTTP_CREATED));
}
use of api.support.builders.UserManualBlockBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method cannotCreateRequestWhenRequesterHasActiveRequestManualBlocks.
@Test
void cannotCreateRequestWhenRequesterHasActiveRequestManualBlocks() {
final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requester = usersFixture.rebecca();
final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
final ZonedDateTime now = ClockUtil.getZonedDateTime();
final ZonedDateTime expirationDate = now.plusDays(4);
final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
userManualBlocksFixture.create(userManualBlockBuilder);
Response postResponse = requestsClient.attemptCreate(requestBuilder);
assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
assertThat(postResponse.getJson(), hasErrors(1));
assertThat(postResponse.getJson(), hasErrorWith(allOf(hasMessage("Patron blocked from requesting"), hasParameter("reason", "Display description"))));
}
use of api.support.builders.UserManualBlockBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method canCreateRequestWhenRequesterNoHaveRequestBlockAndHaveBorrowingRenewalsBlock.
@Test
void canCreateRequestWhenRequesterNoHaveRequestBlockAndHaveBorrowingRenewalsBlock() {
final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requester = usersFixture.rebecca();
final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
final ZonedDateTime now = ClockUtil.getZonedDateTime();
final ZonedDateTime expirationDate = now.plusDays(7);
final UserManualBlockBuilder borrowingUserManualBlockBuilder = getManualBlockBuilder().withBorrowing(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
final UserManualBlockBuilder renewalsUserManualBlockBuilder = getManualBlockBuilder().withRenewals(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
userManualBlocksFixture.create(borrowingUserManualBlockBuilder);
userManualBlocksFixture.create(renewalsUserManualBlockBuilder);
Response postResponse = requestsClient.attemptCreate(requestBuilder);
assertThat(postResponse, hasStatus(HTTP_CREATED));
}
Aggregations