use of com.github.robozonky.api.strategies.LoanDescriptor 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.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class ParsedStrategyTest method matchesAlsoSellFilter.
@Test
void matchesAlsoSellFilter() {
final MarketplaceFilter accepting = MarketplaceFilter.of(MarketplaceFilterCondition.alwaysAccepting());
final Collection<MarketplaceFilter> filters = Collections.singleton(accepting);
final DefaultValues v = new DefaultValues(DefaultPortfolio.PROGRESSIVE);
final FilterSupplier s = new FilterSupplier(v, Collections.emptySet(), Collections.emptySet(), filters);
final ParsedStrategy ps = new ParsedStrategy(v, Collections.emptyList(), Collections.emptyMap(), s);
final Loan l = mockLoan(200_000);
final LoanDescriptor ld = new LoanDescriptor(l);
assertThat(ps.getApplicableLoans(Collections.singleton(ld))).isEmpty();
final Participation p = mock(Participation.class);
final ParticipationDescriptor pd = new ParticipationDescriptor(p, l);
assertThat(ps.getApplicableParticipations(Collections.singleton(pd))).isEmpty();
}
use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class PrimaryMarketplaceComparatorTest method sortByRecency.
@Test
void sortByRecency() {
final OffsetDateTime first = OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID);
final OffsetDateTime second = first.plus(Duration.ofMillis(1));
final Loan l1 = mockLoan(1, 100000, first);
final Loan l2 = mockLoan(l1.getId() + 1, l1.getAmount(), second);
final LoanDescriptor ld1 = new LoanDescriptor(l1), ld2 = new LoanDescriptor(l2);
assertSoftly(softly -> {
softly.assertThat(c.compare(ld1, ld2)).isEqualTo(1);
softly.assertThat(c.compare(ld2, ld1)).isEqualTo(-1);
softly.assertThat(c.compare(ld1, ld1)).isEqualTo(0);
});
}
use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class PrimaryMarketplaceComparatorTest method sortByRemainingIfAsRecent.
@Test
void sortByRemainingIfAsRecent() {
final OffsetDateTime first = OffsetDateTime.ofInstant(Instant.EPOCH, Defaults.ZONE_ID);
final Loan l1 = mockLoan(1, 100000, first);
final Loan l2 = mockLoan(l1.getId() + 1, l1.getAmount() + 1, l1.getDatePublished());
final LoanDescriptor ld1 = new LoanDescriptor(l1), ld2 = new LoanDescriptor(l2);
assertSoftly(softly -> {
softly.assertThat(c.compare(ld1, ld2)).isEqualTo(1);
softly.assertThat(c.compare(ld2, ld1)).isEqualTo(-1);
});
}
Aggregations