use of com.github.robozonky.api.remote.entities.sanitized.Loan 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.Loan in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForInvestmentDelegated.
private DynamicTest getParametersForInvestmentDelegated() {
final Loan l = mockLoan();
final LoanDescriptor ld = new LoanDescriptor(l);
final RecommendedLoan r = ld.recommend(200).get();
final Event evt = new InvestmentDelegatedEvent(r, "");
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getDelegatedInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getDelegatedInvestments()).containsOnlyKeys(l.getId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan 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.Loan 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);
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class DelinquentsTest method defaulted.
@Test
void defaulted() {
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_OFF).setNextPaymentDate(OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID)).build();
final Function<Investment, Loan> f = (id) -> l;
// register delinquency
Delinquents.update(Collections.singleton(i), Collections.emptyList(), po, INVESTMENT_SUPPLIER, f, COLLECTIONS_SUPPLIER);
// ignore events just emitted
this.readPreexistingEvents();
// the investment is defaulted
Delinquents.update(Collections.emptyList(), Collections.singletonList(i), po, INVESTMENT_SUPPLIER, f, COLLECTIONS_SUPPLIER);
assertThat(this.getNewEvents()).hasSize(1).first().isInstanceOf(LoanDefaultedEvent.class);
}
Aggregations