use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenUserDoesNotHavePermissions.
@Test
void cannotOverrideItemNotLoanableBlockWhenUserDoesNotHavePermissions() {
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_LOAN_DATE).create()).withComment(TEST_COMMENT).create()));
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 canOverrideCheckOutWhenAutomatedBlockIsPresent.
@Test
void canOverrideCheckOutWhenAutomatedBlockIsPresent() {
IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource steve = usersFixture.steve();
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(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));
}
use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canOverrideCheckoutWhenItemLimitWasReachedForBookMaterialType.
@Test
void canOverrideCheckoutWhenItemLimitWasReachedForBookMaterialType() {
circulationRulesFixture.updateCirculationRules(createRules("m " + materialTypesFixture.book().getId()));
IndividualResource firstBookTypeItem = itemsFixture.basedUponNod();
IndividualResource secondBookTypeItem = itemsFixture.basedUponSmallAngryPlanet();
IndividualResource steve = usersFixture.steve();
checkOutFixture.checkOutByBarcode(firstBookTypeItem, steve);
firstBookTypeItem = itemsClient.get(firstBookTypeItem);
assertThat(firstBookTypeItem, hasItemStatus(CHECKED_OUT));
Response response = checkOutFixture.attemptCheckOutByBarcode(secondBookTypeItem, steve);
assertThat(response.getJson(), hasErrorWith(hasMessage("Patron has reached maximum limit of 1 items for material type")));
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_LIMIT_BLOCK_PERMISSION);
JsonObject loan = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(secondBookTypeItem).to(steve).at(UUID.randomUUID()).withOverrideBlocks(new CheckOutBlockOverrides().withItemLimitBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()), okapiHeaders).getJson();
secondBookTypeItem = itemsClient.get(secondBookTypeItem);
assertThat(secondBookTypeItem, 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 cannotCheckOutWhenItemIsAlreadyCheckedOutAndNoPatronBlockOverridePermissions.
@Test
void cannotCheckOutWhenItemIsAlreadyCheckedOutAndNoPatronBlockOverridePermissions() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource jessica = usersFixture.jessica();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, jessica);
final IndividualResource steve = usersFixture.steve();
automatedPatronBlocksFixture.blockAction(steve.getId().toString(), true, false, false);
Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(smallAngryPlanet).to(steve).at(UUID.randomUUID()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withPatronBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()));
assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
assertThat(response.getJson(), hasErrorWith(hasMessage("Item is already checked out")));
assertThat(response.getJson(), hasErrorWith(hasMessage("Cannot check out item that already has an open loan")));
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 cannotOverridePatronBlockWhenUserDoesNotHavePermissions.
@Test
void cannotOverridePatronBlockWhenUserDoesNotHavePermissions() {
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()));
assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
assertThat(getMissingPermissions(response), hasSize(1));
assertThat(getMissingPermissions(response), hasItem(OVERRIDE_PATRON_BLOCK_PERMISSION));
}
Aggregations