RemoteData { static Map<Integer, Tuple2<Rating, Money>> getAmountsBlocked(final Tenant tenant) { return tenant.call(Zonky::getPendingInvestments) .peek(investment -> LOGGER.debug("Found: {}.", investment)) .collect(Collectors.toMap(i -> i.getLoan() .getId(), i -> Tuple.of(i.getLoan() .getRating(), i.getPrincipal() .getUnpaid()))); } private  RemoteData(final Statistics statistics, final Map<Integer, Tuple2<Rating, Money>> blocked); static RemoteData load(final Tenant tenant); OffsetDateTime getRetrievedOn(); Statistics getStatistics(); Map<Integer, Tuple2<Rating, Money>> getBlocked(); @Override String toString();  }
@Test void amountsBlocked() { final Zonky zonky = harmlessZonky(); final Tenant tenant = mockTenant(zonky); final Loan loan = new MockLoanBuilder() .set(LoanImpl::setRating, Rating.D) .set(LoanImpl::setInterestRate, Rating.D.getInterestRate()) .build(); Investment i = new InvestmentImpl(new InvestmentLoanDataImpl(loan), Money.from(10)); when(zonky.getPendingInvestments()).thenReturn(Stream.of(i)); Map<Integer, Tuple2<Rating, Money>> result = RemoteData.getAmountsBlocked(tenant); Assertions.assertThat(result) .containsOnly(Map.entry(i.getLoan() .getId(), Tuple.of(Rating.D, Money.from(10)))); }