Search in sources :

Example 16 with CheckOutBlockOverrides

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

the class CheckOutByBarcodeTests method cannotOverridePatronBlockWhenUserDoesNotHaveRequiredPermissions.

@Test
void cannotOverridePatronBlockWhenUserDoesNotHaveRequiredPermissions() {
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_LIMIT_BLOCK_PERMISSION);
    Response response = checkOutFixture.attemptCheckOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(itemsFixture.basedUponNod()).to(usersFixture.steve()).at(UUID.randomUUID()).withOverrideBlocks(new CheckOutBlockOverrides().withPatronBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()), okapiHeaders);
    assertThat(response.getJson(), hasErrorWith(hasMessage(INSUFFICIENT_OVERRIDE_PERMISSIONS)));
    assertThat(getMissingPermissions(response), hasSize(1));
    assertThat(getMissingPermissions(response), hasItem(OVERRIDE_PATRON_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) JsonObject(io.vertx.core.json.JsonObject) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 17 with CheckOutBlockOverrides

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

the class CheckOutByBarcodeTests method canOverrideManualPatronBlockWhenBlockIsPresent.

@Test
void canOverrideManualPatronBlockWhenBlockIsPresent() {
    IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource steve = usersFixture.steve();
    userManualBlocksFixture.createBorrowingManualPatronBlockForUser(steve.getId());
    final Response response = checkOutFixture.attemptCheckOutByBarcode(item, steve);
    assertThat(response, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(response.getJson(), hasErrorWith(hasMessage(PATRON_WAS_BLOCKED_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)

Example 18 with CheckOutBlockOverrides

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

the class CheckOutByBarcodeTests method canOverrideCheckOutWhenItemIsLoanableAndOverrideIsRequested.

@Test
void canOverrideCheckOutWhenItemIsLoanableAndOverrideIsRequested() {
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_NOT_LOANABLE_BLOCK_PERMISSION);
    IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    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));
}
Also used : OkapiHeaders(api.support.http.OkapiHeaders) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) 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)

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