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());
}
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));
}
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")));
}
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));
}
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));
}
Aggregations