final EquityOptionSecurity fooOption = new EquityOptionSecurity (OptionType.PUT, 10d, Currency.USD, ExternalId.of("Test", "FooEquity"),
new AmericanExerciseType(), new Expiry(zdt(2020, 11, 25, 12, 0, 0, 0, ZoneOffset.UTC)), 42d, "EXCH");
fooOption.addExternalId(ExternalId.of("Test", "FooOption"));
securities.addSecurity(fooOption);
final MarketDataELCompiler compiler = new MarketDataELCompiler();
Object result = compiler.compile("security.underlyingId", new DefaultComputationTargetResolver(securities).atVersionCorrection(VersionCorrection.LATEST)).apply(
new ValueRequirement("Foo", ComputationTargetSpecification.of(fooOption)), null);
assertEquals(result, ExternalId.of("Test", "FooEquity"));
result = compiler.compile("Security:get(security.underlyingId)", new DefaultComputationTargetResolver(securities).atVersionCorrection(VersionCorrection.LATEST)).apply(
new ValueRequirement("Foo", ComputationTargetSpecification.of(fooOption)), null);
assertEquals(result, _fooEquity);
}