Search in sources :

Example 1 with OkapiHeaders

use of api.support.http.OkapiHeaders in project mod-circulation by folio-org.

the class OverrideRenewalFixture method overrideRenewalByBarcode.

public void overrideRenewalByBarcode(IndividualResource loan, UUID servicePointId) {
    val itemId = loan.getJson().getString("itemId");
    val userId = loan.getJson().getString("userId");
    final Item item = itemsFixture.getById(itemId);
    final User user = usersFixture.getById(userId);
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_RENEWAL_PERMISSION);
    overrideRenewalByBarcode(OverrideRenewal.builder().itemBarcode(item.getBarcode()).userBarcode(user.getBarcode()).overrideBlocks(new RenewBlockOverrides().withRenewalBlock(new RenewalDueDateRequiredBlockOverrideBuilder().create()).withComment("Override renewal")).servicePointId(servicePointId.toString()).build(), okapiHeaders);
}
Also used : lombok.val(lombok.val) OkapiHeaders(api.support.http.OkapiHeaders) RenewBlockOverrides(api.support.builders.RenewBlockOverrides) Item(api.support.dto.Item) User(api.support.dto.User) RenewalDueDateRequiredBlockOverrideBuilder(api.support.builders.RenewalDueDateRequiredBlockOverrideBuilder)

Example 2 with OkapiHeaders

use of api.support.http.OkapiHeaders in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method canOverrideCheckOutWhenAutomatedBlockIsPresent.

@Test
void canOverrideCheckOutWhenAutomatedBlockIsPresent() {
    IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource steve = usersFixture.steve();
    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(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)

Example 3 with OkapiHeaders

use of api.support.http.OkapiHeaders in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method canOverrideCheckoutWhenItemLimitWasReachedForBookMaterialType.

@Test
void canOverrideCheckoutWhenItemLimitWasReachedForBookMaterialType() {
    circulationRulesFixture.updateCirculationRules(createRules("m " + materialTypesFixture.book().getId()));
    IndividualResource firstBookTypeItem = itemsFixture.basedUponNod();
    IndividualResource secondBookTypeItem = itemsFixture.basedUponSmallAngryPlanet();
    IndividualResource steve = usersFixture.steve();
    checkOutFixture.checkOutByBarcode(firstBookTypeItem, steve);
    firstBookTypeItem = itemsClient.get(firstBookTypeItem);
    assertThat(firstBookTypeItem, hasItemStatus(CHECKED_OUT));
    Response response = checkOutFixture.attemptCheckOutByBarcode(secondBookTypeItem, steve);
    assertThat(response.getJson(), hasErrorWith(hasMessage("Patron has reached maximum limit of 1 items for material type")));
    final OkapiHeaders okapiHeaders = buildOkapiHeadersWithPermissions(OVERRIDE_ITEM_LIMIT_BLOCK_PERMISSION);
    JsonObject loan = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(secondBookTypeItem).to(steve).at(UUID.randomUUID()).withOverrideBlocks(new CheckOutBlockOverrides().withItemLimitBlockOverride(new JsonObject()).withComment(TEST_COMMENT).create()), okapiHeaders).getJson();
    secondBookTypeItem = itemsClient.get(secondBookTypeItem);
    assertThat(secondBookTypeItem, 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 4 with OkapiHeaders

use of api.support.http.OkapiHeaders 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))));
}
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 5 with OkapiHeaders

use of api.support.http.OkapiHeaders 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)))));
}
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)

Aggregations

OkapiHeaders (api.support.http.OkapiHeaders)44 Test (org.junit.jupiter.api.Test)43 IndividualResource (api.support.http.IndividualResource)31 JsonObject (io.vertx.core.json.JsonObject)30 ZonedDateTime (java.time.ZonedDateTime)20 Response (org.folio.circulation.support.http.client.Response)19 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 CheckOutBlockOverrides (api.support.builders.CheckOutBlockOverrides)13 UUID (java.util.UUID)12 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)11 ItemNotLoanableBlockOverrideBuilder (api.support.builders.ItemNotLoanableBlockOverrideBuilder)7 lombok.val (lombok.val)6 RenewBlockOverrides (api.support.builders.RenewBlockOverrides)4 RenewalDueDateRequiredBlockOverrideBuilder (api.support.builders.RenewalDueDateRequiredBlockOverrideBuilder)4 RenewByBarcodeRequestBuilder (api.support.builders.RenewByBarcodeRequestBuilder)3 ItemResource (api.support.http.ItemResource)3 FixedDueDateSchedulesBuilder (api.support.builders.FixedDueDateSchedulesBuilder)2 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)2 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)2