VAT implements ValueObject { @NonNull public Money addTax(@NonNull Money amount) { Objects.requireNonNull(amount, "amount must not be null"); return amount.add(calculateTax(amount)); } @JsonCreator  VAT(int percentage); static VAT valueOf(Integer percentage); @JsonValue int toInteger(); double toDouble(); @NonNull Money addTax(@NonNull Money amount); @NonNull Money subtractTax(@NonNull Money amount); @NonNull Money calculateTax(@NonNull Money amount); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void addTax_noDecimals() { var withTax = new VAT(24).addTax(new Money(Currency.EUR, 100.00)); assertThat(withTax).isEqualTo(new Money(Currency.EUR, 124.00)); }
@Test public void addTax_withDecimals() { var withTax = new VAT(24).addTax(new Money(Currency.EUR, 1.00)); assertThat(withTax).isEqualTo(new Money(Currency.EUR, 1.24)); }