SaleCheck implements TenantPayload { @Override public void accept(final Tenant tenant) { final SoldParticipationCache cache = SoldParticipationCache.forTenant(tenant); cache.getOffered() .mapToObj(investmentId -> retrieveInvestmentIfSold(cache, tenant, investmentId)) .flatMap(Optional::stream) .forEach(sold -> { cache.markAsSold(sold.getId()); ((PowerTenant) tenant).fire(investmentSoldLazy(() -> { final Loan l = tenant.getLoan(sold.getLoan() .getId()); return investmentSold(sold, l, tenant.getPortfolio() .getOverview()); })); }); }  @Override void accept(final Tenant tenant);  }
@Test void nothingIsOffered() { sut.accept(tenant); }