Search in sources :

Example 1 with CheckOutByBarcodeRequestBuilder

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)));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with CheckOutByBarcodeRequestBuilder

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));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) CheckOutBlockOverrides(api.support.builders.CheckOutBlockOverrides) ItemNotLoanableBlockOverrideBuilder(api.support.builders.ItemNotLoanableBlockOverrideBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with CheckOutByBarcodeRequestBuilder

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)));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with CheckOutByBarcodeRequestBuilder

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)));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 5 with CheckOutByBarcodeRequestBuilder

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));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)127 Test (org.junit.jupiter.api.Test)121 IndividualResource (api.support.http.IndividualResource)111 UUID (java.util.UUID)74 JsonObject (io.vertx.core.json.JsonObject)57 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)51 ZonedDateTime (java.time.ZonedDateTime)41 Response (org.folio.circulation.support.http.client.Response)33 LoanHistoryConfigurationBuilder (api.support.builders.LoanHistoryConfigurationBuilder)30 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)28 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)21 CheckOutBlockOverrides (api.support.builders.CheckOutBlockOverrides)18 OkapiHeaders (api.support.http.OkapiHeaders)15 FixedDueDateSchedulesBuilder (api.support.builders.FixedDueDateSchedulesBuilder)9 ItemNotLoanableBlockOverrideBuilder (api.support.builders.ItemNotLoanableBlockOverrideBuilder)9 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)9 ItemResource (api.support.http.ItemResource)8 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)7 RequestBuilder (api.support.builders.RequestBuilder)5 ItemBuilder (api.support.builders.ItemBuilder)3