use of api.support.builders.CheckOutByBarcodeRequestBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method shouldBeTruncatedToTheEndOfPrevOpenDayForMoveToTheEndOfPrevOpenDayStrategyWithTwoOpeningPeriods.
@Test
public void shouldBeTruncatedToTheEndOfPrevOpenDayForMoveToTheEndOfPrevOpenDayStrategyWithTwoOpeningPeriods() {
ZonedDateTime loanDate = atStartOfDay(MONDAY_DATE, UTC).plusHours(16);
use(buildLoanPolicyWithRollingLoan(MOVE_TO_THE_END_OF_THE_PREVIOUS_OPEN_DAY, 3));
IndividualResource item = itemsFixture.basedUponNod();
ZonedDateTime patronExpirationDate = loanDate.plusDays(1);
IndividualResource steve = usersFixture.steve(user -> user.expires(patronExpirationDate));
mockClockManagerToReturnFixedDateTime(loanDate);
JsonObject response = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(steve).on(loanDate).at(CASE_MON_WED_FRI_OPEN_TUE_THU_CLOSED)).getJson();
mockClockManagerToReturnDefaultDateTime();
assertThat(parseDateTime(response.getString("dueDate")), is(ZonedDateTime.of(MONDAY_DATE, LocalTime.MIDNIGHT.minusSeconds(1), UTC)));
}
use of api.support.builders.CheckOutByBarcodeRequestBuilder 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.CheckOutByBarcodeRequestBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method dueDateShouldBeTruncatedToTheEndOfPreviousOpenDayIfTheNextOpenDayStrategy.
@Test
void dueDateShouldBeTruncatedToTheEndOfPreviousOpenDayIfTheNextOpenDayStrategy() {
ZonedDateTime loanDate = atStartOfDay(SECOND_DAY_CLOSED, UTC).plusHours(10);
use(buildLoanPolicyWithFixedLoan(MOVE_TO_THE_END_OF_THE_NEXT_OPEN_DAY, loanDate.plusDays(1)));
IndividualResource item = itemsFixture.basedUponNod();
ZonedDateTime patronExpirationDate = loanDate.plusHours(1);
IndividualResource steve = usersFixture.steve(user -> user.expires(patronExpirationDate));
mockClockManagerToReturnFixedDateTime(loanDate);
JsonObject response = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(steve).on(loanDate).at(CASE_FIRST_DAY_OPEN_SECOND_CLOSED_THIRD_OPEN)).getJson();
mockClockManagerToReturnDefaultDateTime();
assertThat(parseDateTime(response.getString("dueDate")), is(ZonedDateTime.of(FIRST_DAY_OPEN, LocalTime.MIDNIGHT.minusSeconds(1), UTC)));
}
use of api.support.builders.CheckOutByBarcodeRequestBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method dueDateShouldBeTruncatedToTheEndOfPreviousServicePointHoursIfMoveToTheBeginningOfNextStrategy.
@Test
public void dueDateShouldBeTruncatedToTheEndOfPreviousServicePointHoursIfMoveToTheBeginningOfNextStrategy() {
ZonedDateTime loanDate = atStartOfDay(FIRST_DAY_OPEN, UTC).plusHours(16);
use(buildLoanPolicyWithRollingLoan(MOVE_TO_BEGINNING_OF_NEXT_OPEN_SERVICE_POINT_HOURS, 1));
IndividualResource item = itemsFixture.basedUponNod();
ZonedDateTime patronExpirationDate = loanDate.plusHours(12);
IndividualResource steve = usersFixture.steve(user -> user.expires(patronExpirationDate));
mockClockManagerToReturnFixedDateTime(loanDate);
JsonObject response = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(steve).on(loanDate).at(CASE_FIRST_DAY_OPEN_SECOND_CLOSED_THIRD_OPEN)).getJson();
mockClockManagerToReturnDefaultDateTime();
assertThat(parseDateTime(response.getString("dueDate")), is(ZonedDateTime.of(FIRST_DAY_OPEN, END_TIME_SECOND_PERIOD, UTC)));
}
use of api.support.builders.CheckOutByBarcodeRequestBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canCheckOutWithoutLoanDate.
@Test
void canCheckOutWithoutLoanDate() {
IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource steve = usersFixture.steve();
final ZonedDateTime requestDate = getZonedDateTime();
final IndividualResource response = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(smallAngryPlanet).to(steve).at(UUID.randomUUID()));
final JsonObject loan = response.getJson();
assertThat("loan date should be as supplied", loan.getString("loanDate"), withinSecondsAfter(10, requestDate));
}
Aggregations