@Test public void riskableMoneyIsAConfigurableFractionOfTheCompleteBalance() { assertThat(new RiskMoneyProvider(new Ratio(50, PERCENT)).calculateMoneyToRisk(new Money(400, 00, EUR))) .isEqualTo(new Money(200, 00, EUR)); assertThat(new RiskMoneyProvider(new Ratio(20, PERCENT)).calculateMoneyToRisk(new Money(1000, 50, EUR))) .isEqualTo(new Money(200, 10, EUR)); }
public Money calculateMoneyToRisk(final Money balance) { return new Money((long) (balance.asRawValue() * balanceToRiskRatio.asBasic()), balance.getCurrency()); }
RiskMoneyProvider { public Money calculateMoneyToRisk(final Money balance) { return new Money((long) (balance.asRawValue() * balanceToRiskRatio.asBasic()), balance.getCurrency()); } }
RiskMoneyProvider { public Money calculateMoneyToRisk(final Money balance) { return new Money((long) (balance.asRawValue() * balanceToRiskRatio.asBasic()), balance.getCurrency()); } RiskMoneyProvider(final Ratio balanceToRiskRatio); }
RiskMoneyProvider { public Money calculateMoneyToRisk(final Money balance) { return new Money((long) (balance.asRawValue() * balanceToRiskRatio.asBasic()), balance.getCurrency()); } RiskMoneyProvider(final Ratio balanceToRiskRatio); Money calculateMoneyToRisk(final Money balance); }
RiskMoneyProvider { public Money calculateMoneyToRisk(final Money balance) { return new Money((long) (balance.asRawValue() * balanceToRiskRatio.asBasic()), balance.getCurrency()); } RiskMoneyProvider(final Ratio balanceToRiskRatio); Money calculateMoneyToRisk(final Money balance);  }