Search in sources :

Example 31 with Loan

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();
}
Also used : Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) MarketplaceFilter(com.github.robozonky.strategy.natural.conditions.MarketplaceFilter) LoanDescriptor(com.github.robozonky.api.strategies.LoanDescriptor) Test(org.junit.jupiter.api.Test)

Example 32 with Loan

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);
    });
}
Also used : MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) Test(org.junit.jupiter.api.Test)

Example 33 with Loan

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();
    });
}
Also used : Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) Test(org.junit.jupiter.api.Test)

Example 34 with Loan

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();
}
Also used : Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.jupiter.api.Test)

Example 35 with Loan

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);
}
Also used : RecommendedLoan(com.github.robozonky.api.strategies.RecommendedLoan) ExecutionCompletedEvent(com.github.robozonky.api.notifications.ExecutionCompletedEvent) SoftAssertions(org.assertj.core.api.SoftAssertions) TestFactory(org.junit.jupiter.api.TestFactory) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) InvestmentDelegatedEvent(com.github.robozonky.api.notifications.InvestmentDelegatedEvent) SellingCompletedEvent(com.github.robozonky.api.notifications.SellingCompletedEvent) AfterAll(org.junit.jupiter.api.AfterAll) BigDecimal(java.math.BigDecimal) SellingStartedEvent(com.github.robozonky.api.notifications.SellingStartedEvent) SessionInfo(com.github.robozonky.api.notifications.SessionInfo) BeforeAll(org.junit.jupiter.api.BeforeAll) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) PurchasingStartedEvent(com.github.robozonky.api.notifications.PurchasingStartedEvent) Lifecycle(com.github.robozonky.app.runtime.Lifecycle) Assertions(org.assertj.core.api.Assertions) ShutdownHook(com.github.robozonky.app.ShutdownHook) InvestmentRejectedEvent(com.github.robozonky.api.notifications.InvestmentRejectedEvent) EventListenerSupplier(com.github.robozonky.api.notifications.EventListenerSupplier) LoanDescriptor(com.github.robozonky.api.strategies.LoanDescriptor) PurchasingCompletedEvent(com.github.robozonky.api.notifications.PurchasingCompletedEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Event(com.github.robozonky.api.notifications.Event) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) Stream(java.util.stream.Stream) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview) EventListener(com.github.robozonky.api.notifications.EventListener) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) DynamicTest(org.junit.jupiter.api.DynamicTest) Optional(java.util.Optional) ReturnCode(com.github.robozonky.api.ReturnCode) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent) RoboZonkyEndingEvent(com.github.robozonky.api.notifications.RoboZonkyEndingEvent) AbstractRoboZonkyTest(com.github.robozonky.test.AbstractRoboZonkyTest) Collections(java.util.Collections) RecommendedLoan(com.github.robozonky.api.strategies.RecommendedLoan) Loan(com.github.robozonky.api.remote.entities.sanitized.Loan) MarketplaceLoan(com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan) SoftAssertions(org.assertj.core.api.SoftAssertions) ExecutionCompletedEvent(com.github.robozonky.api.notifications.ExecutionCompletedEvent) InvestmentDelegatedEvent(com.github.robozonky.api.notifications.InvestmentDelegatedEvent) SellingCompletedEvent(com.github.robozonky.api.notifications.SellingCompletedEvent) SellingStartedEvent(com.github.robozonky.api.notifications.SellingStartedEvent) PurchasingStartedEvent(com.github.robozonky.api.notifications.PurchasingStartedEvent) InvestmentRejectedEvent(com.github.robozonky.api.notifications.InvestmentRejectedEvent) PurchasingCompletedEvent(com.github.robozonky.api.notifications.PurchasingCompletedEvent) InvestmentPurchasedEvent(com.github.robozonky.api.notifications.InvestmentPurchasedEvent) Event(com.github.robozonky.api.notifications.Event) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent) RoboZonkyEndingEvent(com.github.robozonky.api.notifications.RoboZonkyEndingEvent) Stream(java.util.stream.Stream) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview) InvestmentMadeEvent(com.github.robozonky.api.notifications.InvestmentMadeEvent)

Aggregations

Loan (com.github.robozonky.api.remote.entities.sanitized.Loan)53 Test (org.junit.jupiter.api.Test)46 Investment (com.github.robozonky.api.remote.entities.sanitized.Investment)25 LoanDescriptor (com.github.robozonky.api.strategies.LoanDescriptor)20 AbstractZonkyLeveragingTest (com.github.robozonky.app.AbstractZonkyLeveragingTest)19 MarketplaceLoan (com.github.robozonky.api.remote.entities.sanitized.MarketplaceLoan)14 Zonky (com.github.robozonky.common.remote.Zonky)14 SoftAssertions (org.assertj.core.api.SoftAssertions)14 PortfolioOverview (com.github.robozonky.api.strategies.PortfolioOverview)13 Assertions (org.assertj.core.api.Assertions)13 Mockito (org.mockito.Mockito)13 Event (com.github.robozonky.api.notifications.Event)12 Portfolio (com.github.robozonky.app.portfolio.Portfolio)12 Authenticated (com.github.robozonky.app.authentication.Authenticated)11 Collection (java.util.Collection)11 Collections (java.util.Collections)11 Stream (java.util.stream.Stream)10 Optional (java.util.Optional)9 InvestmentPurchasedEvent (com.github.robozonky.api.notifications.InvestmentPurchasedEvent)8 Participation (com.github.robozonky.api.remote.entities.Participation)8