use of api.support.builders.CheckOutBlockOverrides 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.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemLimitBlockWhenUserDoesNotHavePermissions.
@Test
void cannotOverrideItemLimitBlockWhenUserDoesNotHavePermissions() {
Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(itemsFixture.basedUponNod()).to(usersFixture.steve()).at(UUID.randomUUID()).withOverrideBlocks(new CheckOutBlockOverrides().withItemLimitBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()));
assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
assertThat(getMissingPermissions(response), hasSize(1));
assertThat(getMissingPermissions(response), hasItem(OVERRIDE_ITEM_LIMIT_BLOCK_PERMISSION));
}
use of api.support.builders.CheckOutBlockOverrides 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.CheckOutBlockOverrides 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.CheckOutBlockOverrides in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenDueDateIsNotPresent.
@Test
void cannotOverrideItemNotLoanableBlockWhenDueDateIsNotPresent() {
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 JsonObject()).withComment(TEST_COMMENT).create()), okapiHeaders);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Override should be performed with due date specified"), hasParameter("dueDate", null))));
}
Aggregations