use of api.support.builders.ItemNotLoanableBlockOverrideBuilder 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.ItemNotLoanableBlockOverrideBuilder 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.builders.ItemNotLoanableBlockOverrideBuilder 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)))));
}
use of api.support.builders.ItemNotLoanableBlockOverrideBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canOverrideCheckOutWhenItemNotLoanableBlockIsPresent.
@Test
void canOverrideCheckOutWhenItemNotLoanableBlockIsPresent() {
final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
setNotLoanablePolicy();
IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
Response responseBlocked = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(usersFixture.steve()).at(UUID.randomUUID()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withComment(TEST_COMMENT).create()), okapiHeaders);
assertThat(responseBlocked.getJson(), hasErrorWith(allOf(hasMessage("Item is not loanable"), hasParameter("loanPolicyName", "Not Loanable Policy"))));
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));
final var publishedEvents = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(FakePubSub::getPublishedEvents, hasSize(2));
final var checkOutLogEvent = publishedEvents.findFirst(byLogEventType(LogEventType.CHECK_OUT_THROUGH_OVERRIDE.value()));
assertThat(checkOutLogEvent, isValidCheckOutLogEvent(loan, CHECK_OUT_THROUGH_OVERRIDE));
}
use of api.support.builders.ItemNotLoanableBlockOverrideBuilder 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));
}
Aggregations