use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class FinancialCalculatorTest method actualInterest.
private static void actualInterest(final Rating rating, final int threshold) {
final Investment i = Investment.fresh(mockLoan(rating), 1000).setInterestRate(BigDecimal.TEN).setPaidInterest(BigDecimal.valueOf(500)).setPaidPenalty(BigDecimal.ONE).setCurrentTerm(50).setSmpFee(BigDecimal.ONE);
final BigDecimal before = FinancialCalculator.actualInterestAfterFees(i, getPortfolioOverview(threshold - 1));
final BigDecimal after = FinancialCalculator.actualInterestAfterFees(i, getPortfolioOverview(threshold));
assertThat(after).isGreaterThan(before);
final BigDecimal afterSmpFee = FinancialCalculator.actualInterestAfterFees(i, getPortfolioOverview(threshold), true);
assertThat(after).isGreaterThan(afterSmpFee);
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class FinancialCalculatorTest method fees.
private static void fees(final Rating rating, final int threshold) {
final Investment i = Investment.fresh(mockLoan(rating), 1000);
final BigDecimal before = FinancialCalculator.estimateFeeRate(i, getPortfolioOverview(threshold - 1));
final BigDecimal after = FinancialCalculator.estimateFeeRate(i, getPortfolioOverview(threshold));
assertThat(after).isLessThan(before);
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForSaleOffered.
private DynamicTest getParametersForSaleOffered() {
final Loan l = mockLoan();
final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
final Event evt = new SaleOfferedEvent(i, l);
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getOfferedInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getOfferedInvestments()).containsOnlyKeys(i.getLoanId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class DelinquentsTest method noLongerDelinquent.
@Test
void noLongerDelinquent() {
final PortfolioOverview po = mock(PortfolioOverview.class);
final Loan l = Loan.custom().setId(RANDOM.nextInt(10000)).setMyInvestment(mockMyInvestment()).build();
final Investment i = Investment.fresh(l, 200).setNextPaymentDate(OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID)).build();
final Function<Investment, Loan> f = (id) -> l;
// register delinquence
Delinquents.update(Collections.singleton(i), Collections.emptyList(), po, INVESTMENT_SUPPLIER, f, COLLECTIONS_SUPPLIER);
// ignore events just emitted
this.readPreexistingEvents();
// the investment is no longer delinquent
Delinquents.update(Collections.emptyList(), Collections.emptyList(), po, INVESTMENT_SUPPLIER, f, COLLECTIONS_SUPPLIER);
assertThat(this.getNewEvents()).hasSize(1).first().isInstanceOf(LoanNoLongerDelinquentEvent.class);
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class DelinquentsTest method paid.
@Test
void paid() {
final PortfolioOverview po = mock(PortfolioOverview.class);
final Loan l = Loan.custom().setId(RANDOM.nextInt(10000)).setMyInvestment(mockMyInvestment()).build();
final Investment i = Investment.fresh(l, 200).setPaymentStatus(PaymentStatus.PAID).setNextPaymentDate(OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID)).build();
final Function<Investment, Loan> f = (id) -> l;
// register delinquence
Delinquents.update(Collections.singleton(i), Collections.emptyList(), po, INVESTMENT_SUPPLIER, f, COLLECTIONS_SUPPLIER);
// ignore events just emitted
this.readPreexistingEvents();
// the investment is paid
Delinquents.update(Collections.emptyList(), Collections.singletonList(i), po, INVESTMENT_SUPPLIER, f, COLLECTIONS_SUPPLIER);
assertThat(this.getNewEvents()).hasSize(1).first().isInstanceOf(LoanRepaidEvent.class);
}
Aggregations