EuropeanOptionOnEuropeanVanillaOptionDefinition extends OptionDefinition { @Override public OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction() { return _payoffFunction; } EuropeanOptionOnEuropeanVanillaOptionDefinition(final double strike, final Expiry expiry, final boolean isCall, final double underlyingStrike, final Expiry underlyingExpiry,
      final boolean isUnderlyingCall);  EuropeanOptionOnEuropeanVanillaOptionDefinition(final double strike, final Expiry expiry, final boolean isCall, final EuropeanVanillaOptionDefinition underlyingOption); @Override OptionExerciseFunction<StandardOptionDataBundle> getExerciseFunction(); @Override OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction(); OptionDefinition getUnderlyingOption(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { OPTION.getPayoffFunction().getPayoff(null, null); }
@Test public void testPayoffFunction() { final double delta = 10; EuropeanVanillaOptionDefinition underlying = new EuropeanVanillaOptionDefinition(SPOT + delta, UNDERLYING_EXPIRY, true); EuropeanOptionOnEuropeanVanillaOptionDefinition option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), 0, 0); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, false, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), STRIKE, 0); underlying = new EuropeanVanillaOptionDefinition(SPOT - delta, UNDERLYING_EXPIRY, true); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), delta - STRIKE, 0); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, false, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), 0, 0); underlying = new EuropeanVanillaOptionDefinition(SPOT + delta, UNDERLYING_EXPIRY, false); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), delta - STRIKE, 0); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, false, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), 0, 0); underlying = new EuropeanVanillaOptionDefinition(SPOT + delta, UNDERLYING_EXPIRY, false); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, true, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), delta - STRIKE, 0); option = new EuropeanOptionOnEuropeanVanillaOptionDefinition(STRIKE, EXPIRY, false, underlying); assertEquals(option.getPayoffFunction().getPayoff(DATA, null), 0, 0); }