PortfolioOverviewImpl implements PortfolioOverview { @Override public Ratio getAnnualProfitability() { return profitability; } PortfolioOverviewImpl(final RemotePortfolioImpl impl);   PortfolioOverviewImpl(final Map<Rating, Money> investedPerRating, final Ratio profitability); @Override Money getInvested(); @Override Money getInvested(final Rating r); @Override Ratio getAnnualProfitability(); @Override ZonedDateTime getTimestamp(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test void profitability() { final Map<Rating, Money> investments = new EnumMap<>(Rating.class); investments.put(Rating.AAAAA, Money.from(200_000)); investments.put(Rating.D, Money.from(20_000)); final PortfolioOverview po = new PortfolioOverviewImpl(investments, Ratio.fromPercentage(4)); assertSoftly(softly -> { softly.assertThat(po.getAnnualProfitability()) .isEqualTo(Ratio.fromPercentage(4)); softly.assertThat(po.getMinimalAnnualProfitability() .asPercentage() .doubleValue()) .isCloseTo(3.72, within(0.01)); softly.assertThat(po.getOptimalAnnualProfitability() .asPercentage() .doubleValue()) .isCloseTo(4.87, within(0.01)); softly.assertThat(po.getMonthlyProfit() .getValue() .intValue()) .isCloseTo(733, within(1)); softly.assertThat(po.getMinimalMonthlyProfit() .getValue() .intValue()) .isCloseTo(682, within(1)); softly.assertThat(po.getOptimalMonthlyProfit() .getValue() .intValue()) .isCloseTo(893, within(1)); }); }