PowerTenantImpl implements PowerTenant { @Override public CompletableFuture<?> fire(final SessionEvent event) { return Events.forSession(this) .fire(event); } PowerTenantImpl(final String username, final String sessionName, final boolean isDryRun, final ApiProvider apis,
            final StrategyProvider strategyProvider, final ZonkyApiTokenSupplier tokenSupplier); @Override T call(final Function<Zonky, T> operation); @Override Availability getAvailability(); @Override RemotePortfolio getPortfolio(); @Override SessionInfo getSessionInfo(); @Override Optional<InvestmentStrategy> getInvestmentStrategy(); @Override Optional<SellStrategy> getSellStrategy(); @Override Optional<PurchaseStrategy> getPurchaseStrategy(); @Override Optional<ReservationStrategy> getReservationStrategy(); @Override Loan getLoan(final int loanId); @Override Investment getInvestment(long investmentId, boolean fresh); @Override InstanceState<T> getState(final Class<T> clz); @Override void close(); @Override Money getKnownBalanceUpperBound(); @Override void setKnownBalanceUpperBound(final Money knownBalanceUpperBound); @Override CompletableFuture<?> fire(final SessionEvent event); @Override CompletableFuture<?> fire(final LazyEvent<? extends SessionEvent> event); @Override String toString();  }
@Test void fires() throws Exception { final OAuth a = mock(OAuth.class); final Zonky z = harmlessZonky(); final ApiProvider api = mockApiProvider(a, z); try (final PowerTenant tenant = new TenantBuilder().withApi(api) .withSecrets(SECRETS) .build(false)) { tenant.fire(roboZonkyDaemonSuspended(new IllegalStateException())) .join(); } assertThat(this.getEventsRequested()) .hasSize(1) .first() .isInstanceOf(RoboZonkyDaemonSuspendedEvent.class); }
@Test void firesLazy() throws Exception { final OAuth a = mock(OAuth.class); final Zonky z = harmlessZonky(); final ApiProvider api = mockApiProvider(a, z); try (final PowerTenant tenant = new TenantBuilder().withApi(api) .withSecrets(SECRETS) .build(false)) { tenant.fire(sellingCompletedLazy(() -> sellingCompleted(Collections.emptyList(), mockPortfolioOverview()))) .join(); } assertThat(this.getEventsRequested()) .hasSize(1) .first() .isInstanceOf(SellingCompletedEvent.class); }