use of com.github.robozonky.strategy.natural.conditions.MarketplaceFilter in project robozonky by RoboZonky.
the class NaturalLanguageInvestmentStrategyTest method noLoansApplicable.
@Test
void noLoansApplicable() {
final MarketplaceFilter filter = MarketplaceFilter.of(MarketplaceFilterCondition.alwaysAccepting());
final ParsedStrategy p = new ParsedStrategy(DefaultPortfolio.PROGRESSIVE, Collections.singleton(filter));
final InvestmentStrategy s = new NaturalLanguageInvestmentStrategy(p);
final PortfolioOverview portfolio = mock(PortfolioOverview.class);
when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance());
when(portfolio.getCzkInvested()).thenReturn(p.getMaximumInvestmentSizeInCzk() - 1);
final Stream<RecommendedLoan> result = s.recommend(Collections.singletonList(new LoanDescriptor(mockLoan(2))), portfolio, new Restrictions());
assertThat(result).isEmpty();
}
use of com.github.robozonky.strategy.natural.conditions.MarketplaceFilter in project robozonky by RoboZonky.
the class NaturalLanguagePurchaseStrategyTest method noLoansApplicable.
@Test
void noLoansApplicable() {
final MarketplaceFilter filter = MarketplaceFilter.of(MarketplaceFilterCondition.alwaysAccepting());
final DefaultValues v = new DefaultValues(DefaultPortfolio.PROGRESSIVE);
final FilterSupplier w = new FilterSupplier(v, Collections.emptySet(), Collections.singleton(filter));
final ParsedStrategy p = new ParsedStrategy(v, Collections.emptySet(), Collections.emptyMap(), w);
final PurchaseStrategy s = new NaturalLanguagePurchaseStrategy(p);
final PortfolioOverview portfolio = mock(PortfolioOverview.class);
when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance());
when(portfolio.getCzkInvested()).thenReturn(p.getMaximumInvestmentSizeInCzk() - 1);
final Stream<RecommendedParticipation> result = s.recommend(Collections.singletonList(mockDescriptor()), portfolio, new Restrictions());
assertThat(result).isEmpty();
}
use of com.github.robozonky.strategy.natural.conditions.MarketplaceFilter in project robozonky by RoboZonky.
the class NaturalLanguageSellStrategyTest method noLoansApplicable.
@Test
void noLoansApplicable() {
final MarketplaceFilter filter = MarketplaceFilter.of(MarketplaceFilterCondition.alwaysAccepting());
final ParsedStrategy p = new ParsedStrategy(DefaultPortfolio.PROGRESSIVE, Collections.singleton(filter));
final SellStrategy s = new NaturalLanguageSellStrategy(p);
final PortfolioOverview portfolio = mock(PortfolioOverview.class);
when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance());
when(portfolio.getCzkInvested()).thenReturn(p.getMaximumInvestmentSizeInCzk() - 1);
final Stream<RecommendedInvestment> result = s.recommend(Collections.singletonList(mockDescriptor()), portfolio);
assertThat(result).isEmpty();
}
use of com.github.robozonky.strategy.natural.conditions.MarketplaceFilter in project robozonky by RoboZonky.
the class ParsedStrategyTest method conditions.
@Test
void conditions() {
final DefaultPortfolio portfolio = DefaultPortfolio.PROGRESSIVE;
// test for default values
final ParsedStrategy strategy = new ParsedStrategy(portfolio);
assertThat(strategy.getApplicableLoans(Collections.emptyList())).isEmpty();
// add loan; without filters, should be applicable
final Loan loan = mockLoan(2);
final LoanDescriptor ld = new LoanDescriptor(loan);
assertThat(strategy.getApplicableLoans(Collections.singletonList(ld))).contains(ld);
// now add a filter and see no loans applicable
final MarketplaceFilter f = mock(MarketplaceFilter.class);
when(f.test(eq(new Wrapper(loan)))).thenReturn(true);
final ParsedStrategy strategy2 = new ParsedStrategy(portfolio, Collections.singleton(f));
assertThat(strategy2.getApplicableLoans(Collections.singletonList(ld))).isEmpty();
}
use of com.github.robozonky.strategy.natural.conditions.MarketplaceFilter in project robozonky by RoboZonky.
the class FilterSupplier method supplyFilters.
private static Collection<MarketplaceFilter> supplyFilters(final Collection<MarketplaceFilter> filters, final long monthsBeforeExit) {
if (monthsBeforeExit > -1) {
// ignore marketplace items that go over the exit date
// fix extreme exit dates
final long filteredTerms = Math.min(monthsBeforeExit + 1, 84);
final MarketplaceFilterCondition c = new LoanTermCondition(filteredTerms);
final MarketplaceFilter f = MarketplaceFilter.of(c);
final Collection<MarketplaceFilter> result = new ArrayList<>(filters.size());
result.add(f);
result.addAll(filters);
return Collections.unmodifiableCollection(result);
} else {
return Collections.unmodifiableCollection(filters);
}
}
Aggregations