use of api.support.http.OkapiHeaders in project mod-circulation by folio-org.
the class OverrideRenewalFixture method overrideRenewalByBarcode.
public void overrideRenewalByBarcode(IndividualResource loan, UUID servicePointId) {
val itemId = loan.getJson().getString("itemId");
val userId = loan.getJson().getString("userId");
final Item item = itemsFixture.getById(itemId);
final User user = usersFixture.getById(userId);
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_RENEWAL_PERMISSION);
overrideRenewalByBarcode(OverrideRenewal.builder().itemBarcode(item.getBarcode()).userBarcode(user.getBarcode()).overrideBlocks(new RenewBlockOverrides().withRenewalBlock(new RenewalDueDateRequiredBlockOverrideBuilder().create()).withComment("Override renewal")).servicePointId(servicePointId.toString()).build(), okapiHeaders);
}
use of api.support.http.OkapiHeaders 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.http.OkapiHeaders 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.http.OkapiHeaders in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideBlockWhenCommentIsNotPresent.
@Test
void cannotOverrideBlockWhenCommentIsNotPresent() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_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()).create()), okapiHeaders);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Override should be performed with the comment specified"), hasParameter("comment", null))));
}
use of api.support.http.OkapiHeaders in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenDueDateIsTheSameAsLoanDate.
@Test
void cannotOverrideItemNotLoanableBlockWhenDueDateIsTheSameAsLoanDate() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_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_LOAN_DATE).create()).withComment(TEST_COMMENT).create()), okapiHeaders);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Due date should be later than loan date"), hasParameter("dueDate", formatDateTime(TEST_LOAN_DATE)))));
}
Aggregations