DefaultEquityPresentValueFn implements EquityPresentValueFn { @Override public Result<Double> presentValue(Environment env, EquitySecurity security) { return _marketDataFn.getMarketValue(env, security); } DefaultEquityPresentValueFn(MarketDataFn marketDataFn); @Override Result<Double> presentValue(Environment env, EquitySecurity security);  }
@Test public void testMarketDataUnavailable() { EquitySecurity security = new EquitySecurity("LSE", "LSE", "BloggsCo", Currency.GBP); security.setExternalIdBundle(ExternalSchemes.bloombergTickerSecurityId("BLGG").toBundle()); ZonedDateTime valuationTime = ZonedDateTime.now(); MarketDataEnvironment emptyEnvironment = new MarketDataEnvironmentBuilder().valuationTime(valuationTime).build(); Environment env = new SimpleEnvironment(valuationTime, emptyEnvironment.toBundle()); Result<Double> result = _equityPresentValueFn.presentValue(env, security); assertThat(result.getStatus(), is((ResultStatus) MISSING_DATA)); }
@Test public void testMarketDataAvailable() { EquitySecurity security = new EquitySecurity("LSE", "LSE", "BloggsCo", Currency.GBP); security.setExternalIdBundle(ExternalSchemes.bloombergTickerSecurityId("BLGG").toBundle()); ZonedDateTime valuationTime = ZonedDateTime.now(); MarketDataEnvironmentBuilder builder = new MarketDataEnvironmentBuilder(); MarketDataEnvironment marketDataEnvironment = builder.add(SecurityId.of(security), 123.45) .valuationTime(ZonedDateTime.now()) .build(); Environment env = new SimpleEnvironment(valuationTime, marketDataEnvironment.toBundle()); Result<Double> result = _equityPresentValueFn.presentValue(env, security); assertThat(result.getStatus(), is((ResultStatus) SUCCESS)); assertThat(result.getValue(), is(123.45)); }