Search in sources :

Example 1 with ItemBuilder

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

the class ItemsFixture method setupDeclaredLostItem.

public IndividualResource setupDeclaredLostItem() {
    IndividualResource declaredLostItem = basedUponSmallAngryPlanet(ItemBuilder::declaredLost);
    assertThat(declaredLostItem.getResponse().getJson().getJsonObject("status").getString("name"), is(ItemStatus.DECLARED_LOST.getValue()));
    return declaredLostItem;
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) IndividualResource(api.support.http.IndividualResource)

Example 2 with ItemBuilder

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

the class CheckOutByBarcodeTests method canCheckOutLostAndPaidItem.

@Test
void canCheckOutLostAndPaidItem() {
    final IndividualResource withdrawnItem = itemsFixture.basedUponSmallAngryPlanet(ItemBuilder::lostAndPaid);
    assertThat(withdrawnItem.getJson(), isLostAndPaid());
    final IndividualResource response = checkOutFixture.checkOutByBarcode(withdrawnItem, usersFixture.steve());
    assertThat(response.getJson(), allOf(isOpen(), hasJsonPath("action", "checkedout"), hasJsonPath("itemId", withdrawnItem.getId().toString())));
    assertThat(itemsClient.getById(withdrawnItem.getId()).getJson(), isCheckedOut());
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with ItemBuilder

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

the class RequestScheduledNoticesTests method beforeEach.

@BeforeEach
public void beforeEach() {
    ItemBuilder itemBuilder = ItemExamples.basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId());
    HoldingBuilder holdingBuilder = itemsFixture.applyCallNumberHoldings("CN", "Prefix", "Suffix", Collections.singletonList("CopyNumbers"));
    item = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, holdingBuilder);
    requester = usersFixture.steve();
    pickupServicePoint = servicePointsFixture.cd1();
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) HoldingBuilder(api.support.builders.HoldingBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ItemBuilder

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

the class RenewalAPITests method renewalNoticeIsNotSentWhenPatronNoticeRequestFails.

@Test
void renewalNoticeIsNotSentWhenPatronNoticeRequestFails() {
    UUID renewalTemplateId = UUID.randomUUID();
    JsonObject renewalNoticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(renewalTemplateId).withRenewalEvent().create();
    JsonObject checkInNoticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withCheckInEvent().create();
    NoticePolicyBuilder policyWithRenewalNotice = new NoticePolicyBuilder().withName("Policy with renewal notice").withLoanNotices(Arrays.asList(renewalNoticeConfiguration, checkInNoticeConfiguration));
    LoanPolicyBuilder limitedRenewalsLoanPolicy = new LoanPolicyBuilder().withName("Limited renewals loan policy").rolling(Period.months(1)).limitedRenewals(3);
    use(limitedRenewalsLoanPolicy, policyWithRenewalNotice);
    ItemBuilder itemBuilder = ItemExamples.basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId(), StringUtils.EMPTY, "ItemPrefix", "ItemSuffix", "");
    ItemResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, itemsFixture.thirdFloorHoldings());
    final IndividualResource steve = usersFixture.steve();
    final ZonedDateTime loanDate = ZonedDateTime.of(2018, 3, 18, 11, 43, 54, 0, UTC);
    checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(smallAngryPlanet).to(steve).on(loanDate).at(UUID.randomUUID()));
    FakeModNotify.setFailPatronNoticesWithBadRequest(true);
    loansFixture.renewLoan(smallAngryPlanet, steve);
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 1);
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Example 5 with ItemBuilder

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

the class RequestsAPICreationTests method cannotCreateHoldRequestWhenItemIsNotCheckedOut.

@Test
void cannotCreateHoldRequestWhenItemIsNotCheckedOut() {
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet(ItemBuilder::available);
    Response postResponse = requestsClient.attemptCreate(new RequestBuilder().hold().withInstanceId(item.getInstanceId()).withItemId(item.getId()).withPickupServicePointId(servicePointsFixture.cd1().getId()).withRequesterId(usersFixture.charlotte().getId()));
    assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(postResponse.getJson(), hasErrors(1));
    assertThat(postResponse.getJson(), hasErrorWith(hasMessage("Hold requests are not allowed for this patron and item combination")));
}
Also used : Response(org.folio.circulation.support.http.client.Response) ItemBuilder(api.support.builders.ItemBuilder) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

ItemBuilder (api.support.builders.ItemBuilder)56 Test (org.junit.jupiter.api.Test)47 JsonObject (io.vertx.core.json.JsonObject)28 IndividualResource (api.support.http.IndividualResource)27 UUID (java.util.UUID)27 ItemResource (api.support.http.ItemResource)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 RequestBuilder (api.support.builders.RequestBuilder)18 ZonedDateTime (java.time.ZonedDateTime)16 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)13 lombok.val (lombok.val)12 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)10 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)10 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)9 Response (org.folio.circulation.support.http.client.Response)9 HashMap (java.util.HashMap)8 HoldingBuilder (api.support.builders.HoldingBuilder)6 LocationBuilder (api.support.builders.LocationBuilder)6 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)6 Matcher (org.hamcrest.Matcher)6