Search in sources :

Example 1 with PortfolioDependant

use of com.github.robozonky.app.portfolio.PortfolioDependant in project robozonky by RoboZonky.

the class BlockedAmountsUpdaterTest method customDependant.

@Test
void customDependant() {
    final Portfolio p = mock(Portfolio.class);
    final PortfolioDependant d = mock(PortfolioDependant.class);
    final Authenticated auth = mock(Authenticated.class);
    final BlockedAmountsUpdater bau = new BlockedAmountsUpdater(auth, () -> Optional.of(p), d);
    bau.run();
    verify(d).accept(eq(p), eq(auth));
}
Also used : Authenticated(com.github.robozonky.app.authentication.Authenticated) Portfolio(com.github.robozonky.app.portfolio.Portfolio) PortfolioDependant(com.github.robozonky.app.portfolio.PortfolioDependant) Test(org.junit.jupiter.api.Test)

Example 2 with PortfolioDependant

use of com.github.robozonky.app.portfolio.PortfolioDependant in project robozonky by RoboZonky.

the class PortfolioUpdaterTest method updatingDependants.

@Test
void updatingDependants() {
    final Zonky z = harmlessZonky(10_000);
    final Authenticated a = mockAuthentication(z);
    final PortfolioDependant dependant = mock(PortfolioDependant.class);
    final PortfolioUpdater instance = new PortfolioUpdater((t) -> {
    }, a, mockBalance(z));
    instance.registerDependant(dependant);
    instance.run();
    // this is the call to update Portfolio
    verify(a, times(2)).call(any());
    final Optional<Portfolio> result = instance.get();
    // make sure that the dependants were called with the proper value of Portfolio
    verify(dependant).accept(eq(result.get()), eq(a));
    // it's false when update finished
    assertThat(instance.isUpdating()).isFalse();
}
Also used : Authenticated(com.github.robozonky.app.authentication.Authenticated) Portfolio(com.github.robozonky.app.portfolio.Portfolio) PortfolioDependant(com.github.robozonky.app.portfolio.PortfolioDependant) Zonky(com.github.robozonky.common.remote.Zonky) Test(org.junit.jupiter.api.Test) AbstractZonkyLeveragingTest(com.github.robozonky.app.AbstractZonkyLeveragingTest)

Aggregations

Authenticated (com.github.robozonky.app.authentication.Authenticated)2 Portfolio (com.github.robozonky.app.portfolio.Portfolio)2 PortfolioDependant (com.github.robozonky.app.portfolio.PortfolioDependant)2 Test (org.junit.jupiter.api.Test)2 AbstractZonkyLeveragingTest (com.github.robozonky.app.AbstractZonkyLeveragingTest)1 Zonky (com.github.robozonky.common.remote.Zonky)1