//------------------------------------------------------------------------- public virtual void test_convertedTo() { CashFlow @base = CashFlow.ofForecastValue(PAYMENT_DATE, GBP, FORECAST_VALUE, DISCOUNT_FACTOR); CashFlow test = @base.convertedTo(USD, FxRate.of(GBP, USD, 1.5)); assertThat(test.PaymentDate).isEqualTo(PAYMENT_DATE); assertThat(test.PresentValue).hasCurrency(USD); assertThat(test.PresentValue).hasAmount(PRESENT_VALUE * 1.5, TOLERANCE); assertThat(test.ForecastValue).hasCurrency(USD); assertThat(test.ForecastValue).hasAmount(FORECAST_VALUE * 1.5, TOLERANCE); assertThat(test.DiscountFactor).isCloseTo(DISCOUNT_FACTOR, TOLERANCE); }
public virtual void test_convertedTo_noConversion() { CashFlow @base = CashFlow.ofForecastValue(PAYMENT_DATE, GBP, FORECAST_VALUE, DISCOUNT_FACTOR); CashFlow test = @base.convertedTo(GBP, FxMatrix.empty()); assertThat(test.PaymentDate).isEqualTo(PAYMENT_DATE); assertThat(test.PresentValue).hasCurrency(GBP); assertThat(test.PresentValue).hasAmount(PRESENT_VALUE, TOLERANCE); assertThat(test.ForecastValue).hasCurrency(GBP); assertThat(test.ForecastValue).hasAmount(FORECAST_VALUE, TOLERANCE); assertThat(test.DiscountFactor).isCloseTo(DISCOUNT_FACTOR, TOLERANCE); }