Search in sources :

Example 1 with ClockUtil.getZonedDateTime

use of org.folio.circulation.support.utils.ClockUtil.getZonedDateTime in project mod-circulation by folio-org.

the class ClaimItemReturnedAPITests method itemClaimedReturnedEventIsPublished.

@Test
void itemClaimedReturnedEventIsPublished() {
    final ZonedDateTime dateTime = ClockUtil.getZonedDateTime();
    final Response response = claimItemReturnedFixture.claimItemReturned(new ClaimItemReturnedRequestBuilder().forLoan(loanId).withItemClaimedReturnedDate(dateTime));
    assertLoanAndItem(response, null, dateTime);
    // Five events are expected: one for check-out one for log event, one for the claim
    // and one for log records
    final var publishedEvents = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(FakePubSub::getPublishedEvents, hasSize(4));
    final var event = publishedEvents.findFirst(byEventType(ITEM_CLAIMED_RETURNED));
    assertThat(event, isValidItemClaimedReturnedEvent(loan.getJson()));
    assertThatPublishedLoanLogRecordEventsAreValid(loansClient.getById(loan.getId()).getJson());
}
Also used : Response(org.folio.circulation.support.http.client.Response) FakePubSub(api.support.fakes.FakePubSub) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) ZonedDateTime(java.time.ZonedDateTime) ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with ClockUtil.getZonedDateTime

use of org.folio.circulation.support.utils.ClockUtil.getZonedDateTime in project mod-circulation by folio-org.

the class RequestsAPICreationTests method canCreateRequestWhenRequesterNotHaveActiveManualBlocks.

@Test
void canCreateRequestWhenRequesterNotHaveActiveManualBlocks() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.plusDays(4);
    final UserManualBlockBuilder userManualBlockBuilder = getManualBlockBuilder().withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(userManualBlockBuilder);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_CREATED));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with ClockUtil.getZonedDateTime

use of org.folio.circulation.support.utils.ClockUtil.getZonedDateTime in project mod-circulation by folio-org.

the class RequestsAPICreationTests method cannotCreateRequestWhenRequesterHasSomeActiveRequestManualBlocks.

@Test
void cannotCreateRequestWhenRequesterHasSomeActiveRequestManualBlocks() {
    final IndividualResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requester = usersFixture.rebecca();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    final ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    final ZonedDateTime now = ClockUtil.getZonedDateTime();
    final ZonedDateTime expirationDate = now.plusDays(4);
    final UserManualBlockBuilder requestUserManualBlockBuilder1 = getManualBlockBuilder().withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId()));
    final UserManualBlockBuilder requestUserManualBlockBuilder2 = getManualBlockBuilder().withBorrowing(true).withRenewals(true).withRequests(true).withExpirationDate(expirationDate).withUserId(String.valueOf(requester.getId())).withDesc("Test");
    final RequestBuilder requestBuilder = createRequestBuilder(item, requester, pickupServicePointId, requestDate);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    userManualBlocksFixture.create(requestUserManualBlockBuilder1);
    userManualBlocksFixture.create(requestUserManualBlockBuilder2);
    Response postResponse = requestsClient.attemptCreate(requestBuilder);
    assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(postResponse.getJson(), hasErrors(1));
    assertThat(postResponse.getJson(), hasErrorWith(hasMessage("Patron blocked from requesting")));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UserManualBlockBuilder(api.support.builders.UserManualBlockBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with ClockUtil.getZonedDateTime

use of org.folio.circulation.support.utils.ClockUtil.getZonedDateTime in project mod-circulation by folio-org.

the class OverduePeriodCalculatorServiceTest method preconditionsCheckLoanHasNoDueDate.

@Test
void preconditionsCheckLoanHasNoDueDate() {
    ZonedDateTime systemTime = ClockUtil.getZonedDateTime();
    Loan loan = new LoanBuilder().asDomainObject();
    assertFalse(calculator.preconditionsAreMet(loan, systemTime, true));
}
Also used : LoanBuilder(api.support.builders.LoanBuilder) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ClockUtil.getZonedDateTime

use of org.folio.circulation.support.utils.ClockUtil.getZonedDateTime in project mod-circulation by folio-org.

the class OverduePeriodCalculatorServiceTest method preconditionsCheckCountClosedIsNull.

@Test
void preconditionsCheckCountClosedIsNull() {
    ZonedDateTime systemTime = ClockUtil.getZonedDateTime();
    Loan loan = new LoanBuilder().withDueDate(systemTime.minusDays(1)).asDomainObject();
    assertFalse(calculator.preconditionsAreMet(loan, systemTime, null));
}
Also used : LoanBuilder(api.support.builders.LoanBuilder) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)27 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)27 Test (org.junit.jupiter.api.Test)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 IndividualResource (api.support.http.IndividualResource)17 Response (org.folio.circulation.support.http.client.Response)13 JsonObject (io.vertx.core.json.JsonObject)11 UUID (java.util.UUID)11 RequestBuilder (api.support.builders.RequestBuilder)8 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)7 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)5 UserManualBlockBuilder (api.support.builders.UserManualBlockBuilder)5 LoanBuilder (api.support.builders.LoanBuilder)4 LinkedHashMap (java.util.LinkedHashMap)4 APITests (api.support.APITests)3 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)3 MultipleJsonRecords (api.support.MultipleJsonRecords)3 TlrFeatureStatus (api.support.TlrFeatureStatus)3 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)3 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)3