use of com.github.robozonky.api.remote.entities.sanitized.Loan 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.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class WrapperTest method equality.
@Test
void equality() {
final Loan loan = Loan.custom().setId(1).setAmount(2).build();
final Wrapper w = new Wrapper(loan);
assertSoftly(softly -> {
softly.assertThat(w).isEqualTo(w);
softly.assertThat(w).isNotEqualTo(null);
softly.assertThat(w).isNotEqualTo("");
});
final Wrapper w2 = new Wrapper(loan);
assertSoftly(softly -> {
softly.assertThat(w).isEqualTo(w2);
softly.assertThat(w2).isEqualTo(w);
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class LoanDescriptorTest method constructorForCaptchaLess.
@Test
void constructorForCaptchaLess() {
final Loan mockedLoan = LoanDescriptorTest.mockLoan(Rating.AAAAA);
final LoanDescriptor ld = new LoanDescriptor(mockedLoan);
assertSoftly(softly -> {
softly.assertThat(ld.item()).isSameAs(mockedLoan);
softly.assertThat(ld.getLoanCaptchaProtectionEndDateTime()).isEmpty();
});
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class LoanDescriptorTest method recommendAmount.
@Test
void recommendAmount() {
final Loan mockedLoan = LoanDescriptorTest.mockLoan();
final LoanDescriptor ld = new LoanDescriptor(mockedLoan);
final Optional<RecommendedLoan> r = ld.recommend(BigDecimal.valueOf(Defaults.MINIMUM_INVESTMENT_IN_CZK));
assertThat(r).isPresent();
final RecommendedLoan recommendation = r.get();
final SoftAssertions softly = new SoftAssertions();
softly.assertThat(recommendation.descriptor()).isSameAs(ld);
softly.assertThat(recommendation.amount()).isEqualTo(BigDecimal.valueOf(Defaults.MINIMUM_INVESTMENT_IN_CZK));
softly.assertThat(recommendation.isConfirmationRequired()).isFalse();
softly.assertAll();
}
use of com.github.robozonky.api.remote.entities.sanitized.Loan in project robozonky by RoboZonky.
the class JmxListenerServiceTest method getParametersForInvestmentMade.
private DynamicTest getParametersForInvestmentMade() {
final Loan l = mockLoan();
final Investment i = Investment.fresh((MarketplaceLoan) l, 200);
final PortfolioOverview po = PortfolioOverview.calculate(BigDecimal.valueOf(1000), Stream::empty);
final Event evt = new InvestmentMadeEvent(i, l, po);
final Consumer<SoftAssertions> before = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getSuccessfulInvestments()).isEmpty();
};
final Consumer<SoftAssertions> after = (softly) -> {
final OperationsMBean mbean = getOperationsMBean();
softly.assertThat(mbean.getSuccessfulInvestments()).containsOnlyKeys(l.getId());
softly.assertThat(mbean.getLatestUpdatedDateTime()).isEqualTo(evt.getCreatedOn());
};
return getParameters(evt, before, after);
}
Aggregations