use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPITests method canCreateALoanWithSystemReturnDate.
@Test
void canCreateALoanWithSystemReturnDate() {
UUID id = UUID.randomUUID();
UUID itemId = itemsFixture.basedUponSmallAngryPlanet().getId();
UUID userId = usersFixture.charlotte().getId();
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
ZonedDateTime systemReturnDate = ZonedDateTime.of(2017, 4, 1, 12, 0, 0, 0, UTC);
IndividualResource response = loansFixture.createLoan(new LoanBuilder().closed().withId(id).withUserId(userId).withItemId(itemId).withLoanDate(loanDate).withDueDate(dueDate).withSystemReturnDate(systemReturnDate));
JsonObject loan = response.getJson();
assertThat("systemReturnDate does not match", loan.getString("systemReturnDate"), isEquivalentTo(systemReturnDate));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanAPITests method cannotUpdateAnOpenLoanWithoutAUserId.
@Test
void cannotUpdateAnOpenLoanWithoutAUserId() {
UUID itemId = itemsFixture.basedUponNod().getId();
final IndividualResource jessica = usersFixture.jessica();
IndividualResource loan = loansFixture.createLoan(new LoanBuilder().open().withUserId(jessica.getId()).withItemId(itemId));
JsonObject updatedLoan = loan.copyJson();
updatedLoan.remove("userId");
Response putResponse = loansFixture.attemptToReplaceLoan(loan.getId(), updatedLoan);
assertThat(putResponse.getJson(), hasErrorWith(allOf(hasMessage("Open loan must have a user ID"), hasNullParameter("userId"))));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class LoanLostDateTest method lostDateIsNotNullWhenBothLostDatesAreEqual.
@Test
void lostDateIsNotNullWhenBothLostDatesAreEqual() {
final var lostDate = ClockUtil.getZonedDateTime();
final var loan = new LoanBuilder().asDomainObject().ageOverdueItemToLost(lostDate).declareItemLost("Lost", lostDate);
assertTrue(isSameMillis(lostDate, loan.getLostDate()));
}
use of api.support.builders.LoanBuilder in project mod-circulation by folio-org.
the class OverduePeriodCalculatorServiceTest method countOverdueMinutesWithClosedDays.
@Test
void countOverdueMinutesWithClosedDays() throws ExecutionException, InterruptedException {
final int expectedResult = 60 * 24 * 7 + 1;
final ZonedDateTime systemTime = getZonedDateTime();
Loan loan = new LoanBuilder().withDueDate(systemTime.minusMinutes(expectedResult)).asDomainObject();
int actualResult = calculator.getOverdueMinutes(loan, systemTime, true).get().value();
assertEquals(expectedResult, actualResult);
}
use of api.support.builders.LoanBuilder 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));
}
Aggregations