ForexNonDeliverableForwardDefinition implements InstrumentDefinition<InstrumentDerivative> { @Override public ForexNonDeliverableForward toDerivative(final ZonedDateTime date) { ArgumentChecker.isTrue(!date.isAfter(_fixingDate), "Date is after fixing date"); return new ForexNonDeliverableForward(_currency1, _currency2, _notional, _exchangeRate, TimeCalculator.getTimeBetween(date, _fixingDate), TimeCalculator.getTimeBetween(date, _paymentDate)); } ForexNonDeliverableForwardDefinition(final Currency currency1, final Currency currency2, final double notional, final double exchangeRate,
      final ZonedDateTime fixingDate, final ZonedDateTime paymentDate); Currency getCurrency1(); Currency getCurrency2(); double getNotional(); double getExchangeRate(); ZonedDateTime getFixingDate(); ZonedDateTime getPaymentDate(); @Override ForexNonDeliverableForward toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void toDerivativeDateAfter() { NDF_DEFINITION.toDerivative(PAYMENT_DATE.plusDays(1)); }
@Test public void toDerivative() { final ForexNonDeliverableForward ndfConverted = NDF_DEFINITION.toDerivative(REFERENCE_DATE); final ForexNonDeliverableForward ndfExpected = new ForexNonDeliverableForward(KRW, USD, NOMINAL_USD, FX_RATE, TimeCalculator.getTimeBetween(REFERENCE_DATE, FIXING_DATE), TimeCalculator.getTimeBetween( REFERENCE_DATE, PAYMENT_DATE)); assertEquals("Forex NDF - toDerivatives", ndfExpected, ndfConverted); }