Search in sources :

Example 11 with CheckOutBlockOverrides

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

Example 12 with CheckOutBlockOverrides

use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method canCreateRecallRequestAfterOverriddenCheckout.

@Test
void canCreateRecallRequestAfterOverriddenCheckout() {
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
    IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    IndividualResource steve = usersFixture.steve();
    IndividualResource charlotte = usersFixture.charlotte();
    setNotLoanablePolicy();
    checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item).to(steve).at(servicePointsFixture.cd1()).on(TEST_LOAN_DATE).withOverrideBlocks(new CheckOutBlockOverrides().withItemNotLoanableBlockOverride(new ItemNotLoanableBlockOverrideBuilder().withDueDate(TEST_DUE_DATE).create()).withComment(TEST_COMMENT).create()), okapiHeaders).getJson();
    final Response placeRequestResponse = requestsFixture.attemptPlace(new RequestBuilder().recall().forItem(item).by(charlotte).fulfilToHoldShelf(servicePointsFixture.cd1()));
    assertThat(placeRequestResponse.getStatusCode(), is(201));
}
Also used : OkapiHeaders(api.support.http.OkapiHeaders) Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) CheckOutBlockOverrides(api.support.builders.CheckOutBlockOverrides) ItemNotLoanableBlockOverrideBuilder(api.support.builders.ItemNotLoanableBlockOverrideBuilder) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 13 with CheckOutBlockOverrides

use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenDueDateIsBeforeLoanDate.

@Test
void cannotOverrideItemNotLoanableBlockWhenDueDateIsBeforeLoanDate() {
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
    ZonedDateTime invalidDueDate = TEST_LOAN_DATE.minusDays(2);
    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(invalidDueDate).create()).withComment(TEST_COMMENT).create()), okapiHeaders);
    assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Due date should be later than loan date"), hasParameter("dueDate", formatDateTime(invalidDueDate)))));
}
Also used : OkapiHeaders(api.support.http.OkapiHeaders) Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) CheckOutBlockOverrides(api.support.builders.CheckOutBlockOverrides) ItemNotLoanableBlockOverrideBuilder(api.support.builders.ItemNotLoanableBlockOverrideBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 14 with CheckOutBlockOverrides

use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method cannotOverrideItemNotLoanableBlockWhenUserDoesNotHaveRequiredPermissions.

@Test
void cannotOverrideItemNotLoanableBlockWhenUserDoesNotHaveRequiredPermissions() {
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_PATRON_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()).withComment(TEST_COMMENT).create()), okapiHeaders);
    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 : OkapiHeaders(api.support.http.OkapiHeaders) 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 15 with CheckOutBlockOverrides

use of api.support.builders.CheckOutBlockOverrides in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method canOverrideManualAndAutomationPatronBlocksWhenBlocksArePresent.

@Test
void canOverrideManualAndAutomationPatronBlocksWhenBlocksArePresent() {
    IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource steve = usersFixture.steve();
    userManualBlocksFixture.createBorrowingManualPatronBlockForUser(steve.getId());
    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(PATRON_WAS_BLOCKED_MESSAGE)));
    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));
}
Also used : Response(org.folio.circulation.support.http.client.Response) OkapiHeaders(api.support.http.OkapiHeaders) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) CheckOutBlockOverrides(api.support.builders.CheckOutBlockOverrides) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

CheckOutBlockOverrides (api.support.builders.CheckOutBlockOverrides)18 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)18 Test (org.junit.jupiter.api.Test)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 Response (org.folio.circulation.support.http.client.Response)17 OkapiHeaders (api.support.http.OkapiHeaders)13 JsonObject (io.vertx.core.json.JsonObject)12 ItemNotLoanableBlockOverrideBuilder (api.support.builders.ItemNotLoanableBlockOverrideBuilder)9 IndividualResource (api.support.http.IndividualResource)8 RequestBuilder (api.support.builders.RequestBuilder)1 FakePubSub (api.support.fakes.FakePubSub)1 ZonedDateTime (java.time.ZonedDateTime)1 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)1