use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockAndPatronBlockWhenUserDoesNotHavePermissions.
@Test
void cannotOverrideItemNotLoanableBlockAndPatronBlockWhenUserDoesNotHavePermissions() {
setNotLoanablePolicy();
Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(itemsFixture.basedUponSmallAngryPlanet()).to(usersFixture.steve()).at(UUID.randomUUID()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withItemNotLoanableBlockOverride(new ItemNotLoanableBlockOverrideBuilder().withDueDate(TEST_DUE_DATE).create()).withPatronBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()));
assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
assertThat(getMissingPermissions(response), hasSize(2));
assertThat(getMissingPermissions(response), hasItems(OVERRIDE_PATRON_BLOCK_PERMISSION, OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canCreateRecallRequestAfterOverriddenCheckout.
@Test
void canCreateRecallRequestAfterOverriddenCheckout() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
IndividualResource steve = usersFixture.steve();
IndividualResource charlotte = usersFixture.charlotte();
setNotLoanablePolicy();
checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(steve).at(servicePointsFixture.cd1()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withItemNotLoanableBlockOverride(new ItemNotLoanableBlockOverrideBuilder().withDueDate(TEST_DUE_DATE).create()).withComment(TEST_COMMENT).create()), okapiHeaders).getJson();
final Response placeRequestResponse = requestsFixture.attemptPlace(new RequestBuilder().recall().forItem(item).by(charlotte).fulfilToHoldShelf(servicePointsFixture.cd1()));
assertThat(placeRequestResponse.getStatusCode(), is(201));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenDueDateIsBeforeLoanDate.
@Test
void cannotOverrideItemNotLoanableBlockWhenDueDateIsBeforeLoanDate() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
ZonedDateTime invalidDueDate = TEST_LOAN_DATE.minusDays(2);
setNotLoanablePolicy();
Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(itemsFixture.basedUponSmallAngryPlanet()).to(usersFixture.steve()).at(UUID.randomUUID()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withItemNotLoanableBlockOverride(new ItemNotLoanableBlockOverrideBuilder().withDueDate(invalidDueDate).create()).withComment(TEST_COMMENT).create()), okapiHeaders);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Due date should be later than loan date"), hasParameter("dueDate", formatDateTime(invalidDueDate)))));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenUserDoesNotHaveRequiredPermissions.
@Test
void cannotOverrideItemNotLoanableBlockWhenUserDoesNotHaveRequiredPermissions() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_PATRON_BLOCK_PERMISSION);
setNotLoanablePolicy();
Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(itemsFixture.basedUponSmallAngryPlanet()).to(usersFixture.steve()).at(UUID.randomUUID()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withItemNotLoanableBlockOverride(new ItemNotLoanableBlockOverrideBuilder().withDueDate(TEST_DUE_DATE).create()).withComment(TEST_COMMENT).create()), okapiHeaders);
assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
assertThat(getMissingPermissions(response), hasSize(1));
assertThat(getMissingPermissions(response), hasItem(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canOverrideManualAndAutomationPatronBlocksWhenBlocksArePresent.
@Test
void canOverrideManualAndAutomationPatronBlocksWhenBlocksArePresent() {
IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource steve = usersFixture.steve();
userManualBlocksFixture.createBorrowingManualPatronBlockForUser(steve.getId());
automatedPatronBlocksFixture.blockAction(steve.getId().toString(), true, false, false);
final Response response = checkOutFixture.attemptCheckOutByBarcode(item, steve);
assertThat(response, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
assertThat(response.getJson(), hasErrorWith(hasMessage(PATRON_WAS_BLOCKED_MESSAGE)));
assertThat(response.getJson(), hasErrorWith(hasMessage(MAX_NUMBER_OF_ITEMS_CHARGED_OUT_MESSAGE)));
assertThat(response.getJson(), hasErrorWith(hasMessage(MAX_OUTSTANDING_FEE_FINE_BALANCE_MESSAGE)));
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_PATRON_BLOCK_PERMISSION);
JsonObject loan = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(steve).at(UUID.randomUUID()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withPatronBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()), okapiHeaders).getJson();
item = itemsClient.get(item);
assertThat(item, hasItemStatus(CHECKED_OUT));
assertThat(loan.getString("actionComment"), is(TEST_COMMENT));
assertThat(loan.getString("action"), is(CHECKED_OUT_THROUGH_OVERRIDE));
}
Aggregations