AmericanVanillaOptionDefinition extends OptionDefinition { @Override public OptionExerciseFunction<StandardOptionDataBundle> getExerciseFunction() { return _exerciseFunction; } AmericanVanillaOptionDefinition(final double strike, final Expiry expiry, final boolean isCall); @Override OptionExerciseFunction<StandardOptionDataBundle> getExerciseFunction(); @Override OptionPayoffFunction<StandardOptionDataBundle> getPayoffFunction(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDataInExercise() { CALL.getExerciseFunction().shouldExercise(null, LOW_PRICE); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullOptionPriceInExercise() { CALL.getExerciseFunction().shouldExercise(DATA, -LOW_PRICE); }
@Test public void testExerciseFunction() { OptionExerciseFunction<StandardOptionDataBundle> exercise = CALL.getExerciseFunction(); assertTrue(exercise.shouldExercise(DATA.withSpot(STRIKE + DIFF), LOW_PRICE)); assertFalse(exercise.shouldExercise(DATA.withSpot(STRIKE - DIFF), LOW_PRICE)); assertFalse(exercise.shouldExercise(DATA.withSpot(STRIKE + DIFF), HIGH_PRICE)); assertFalse(exercise.shouldExercise(DATA.withSpot(STRIKE - DIFF), HIGH_PRICE)); exercise = PUT.getExerciseFunction(); assertFalse(exercise.shouldExercise(DATA.withSpot(STRIKE + DIFF), LOW_PRICE)); assertTrue(exercise.shouldExercise(DATA.withSpot(STRIKE - DIFF), LOW_PRICE)); assertFalse(exercise.shouldExercise(DATA.withSpot(STRIKE + DIFF), HIGH_PRICE)); assertFalse(exercise.shouldExercise(DATA.withSpot(STRIKE - DIFF), HIGH_PRICE)); }