use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class ParsedStrategyTest method sellOffStarted.
@Test
void sellOffStarted() {
final DefaultPortfolio portfolio = DefaultPortfolio.EMPTY;
final DefaultValues values = new DefaultValues(portfolio);
// activate default sell-off 3 months before the given date, which is already in the past
values.setExitProperties(new ExitProperties(LocalDate.now().plusMonths(2)));
final ParsedStrategy strategy = new ParsedStrategy(values, Collections.emptyList());
// no loan or participation should be bought; every investment should be sold
final Loan l = mockLoan(1000);
final LoanDescriptor ld = new LoanDescriptor(l);
final ParticipationDescriptor pd = mockParticipationDescriptor(l);
final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
final InvestmentDescriptor id = new InvestmentDescriptor(i, l);
assertSoftly(softly -> {
softly.assertThat(strategy.getApplicableLoans(Collections.singleton(ld))).isEmpty();
softly.assertThat(strategy.getApplicableParticipations(Collections.singleton(pd))).isEmpty();
softly.assertThat(strategy.getApplicableInvestments(Collections.singleton(id))).containsOnly(id);
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class WrapperTest method fromInvestment.
@Test
void fromInvestment() {
final Loan loan = Loan.custom().setId(1).setAmount(100_000).build();
final int invested = 200;
final Investment investment = Investment.fresh((MarketplaceLoan) loan, invested).build();
final Wrapper w = new Wrapper(investment, loan);
assertSoftly(softly -> {
softly.assertThat(w.getLoanId()).isEqualTo(loan.getId());
softly.assertThat(w.getStory()).isEqualTo(loan.getStory());
softly.assertThat(w.getRegion()).isEqualTo(loan.getRegion());
softly.assertThat(w.getRating()).isEqualTo(loan.getRating());
softly.assertThat(w.getOriginalAmount()).isEqualTo(loan.getAmount());
softly.assertThat(w.getInterestRate()).isEqualTo(loan.getInterestRate());
softly.assertThat(w.getRemainingTermInMonths()).isEqualTo(investment.getRemainingMonths());
softly.assertThat(w.getRemainingAmount()).isEqualTo(BigDecimal.valueOf(invested));
softly.assertThat(w.getIdentifier()).isNotNull();
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class ZonkyTest method cancel.
@Test
void cancel() {
final ControlApi control = mock(ControlApi.class);
final Api<ControlApi> ca = mockApi(control);
final PaginatedApi<RawLoan, LoanApi> la = mockApi();
final PaginatedApi<BlockedAmount, WalletApi> wa = mockApi();
final PaginatedApi<RawInvestment, PortfolioApi> pa = mockApi();
final PaginatedApi<Participation, ParticipationApi> sa = mockApi();
final PaginatedApi<RawDevelopment, CollectionsApi> caa = mockApi();
final Zonky z = new Zonky(ca, la, sa, pa, wa, caa);
final Investment i = mock(Investment.class);
when(i.getId()).thenReturn(1);
z.cancel(i);
verify(control).cancel(eq(i.getId()));
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class FinancialCalculatorTest method expectedInterest.
private static void expectedInterest(final Rating rating, final int threshold) {
final Investment i = Investment.fresh(mockLoan(rating), 1000).setInterestRate(BigDecimal.TEN).setRemainingMonths(50).build();
final BigDecimal before = FinancialCalculator.expectedInterestAfterFees(i, getPortfolioOverview(threshold - 1));
final BigDecimal after = FinancialCalculator.expectedInterestAfterFees(i, getPortfolioOverview(threshold));
assertThat(after).isGreaterThan(before);
}
use of com.github.robozonky.api.remote.entities.sanitized.Investment in project robozonky by RoboZonky.
the class InvestmentMadeEventListener method getData.
@Override
protected Map<String, Object> getData(final InvestmentMadeEvent event) {
final Investment i = event.getInvestment();
final Map<String, Object> result = super.getData(event);
result.put("yield", FinancialCalculator.expectedInterestAfterFees(i, event.getPortfolioOverview()));
final BigDecimal interestRate = FinancialCalculator.expectedInterestRateAfterFees(i, event.getPortfolioOverview());
result.put("relativeYield", interestRate);
return result;
}
Aggregations