use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverridePatronBlockWhenUserDoesNotHaveRequiredPermissions.
@Test
void cannotOverridePatronBlockWhenUserDoesNotHaveRequiredPermissions() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_LIMIT_BLOCK_PERMISSION);
Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(itemsFixture.basedUponNod()).to(usersFixture.steve()).at(UUID.randomUUID()).withOverrideBlocks(new CheckOutBlockOverrides().withPatronBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()), okapiHeaders);
assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
assertThat(getMissingPermissions(response), hasSize(1));
assertThat(getMissingPermissions(response), hasItem(OVERRIDE_PATRON_BLOCK_PERMISSION));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canOverrideManualPatronBlockWhenBlockIsPresent.
@Test
void canOverrideManualPatronBlockWhenBlockIsPresent() {
IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource steve = usersFixture.steve();
userManualBlocksFixture.createBorrowingManualPatronBlockForUser(steve.getId());
final Response response = checkOutFixture.attemptCheckOutByBarcode(item, steve);
assertThat(response, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
assertThat(response.getJson(), hasErrorWith(hasMessage(PATRON_WAS_BLOCKED_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));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canOverrideCheckOutWhenItemIsLoanableAndOverrideIsRequested.
@Test
void canOverrideCheckOutWhenItemIsLoanableAndOverrideIsRequested() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
JsonObject loan = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).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).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