}
public void testSingleValueNoLiveData() {
final ExternalId secIdentifier = ExternalId.of("SEC", "1");
final SimplePosition pos = new SimplePosition(new BigDecimal(1), secIdentifier);
final SimplePortfolioNode pn = new SimplePortfolioNode("node");
pn.addPosition(pos);
final SimplePortfolio p = new SimplePortfolio(UniqueId.of("FOO", "BAR"), "portfolio");
p.setRootNode(pn);
final MockPositionSource positionSource = new MockPositionSource();
positionSource.addPortfolio(p);
final SimpleSecurity defSec = new SimpleSecurity("My Sec");
defSec.addExternalId(secIdentifier);
final InMemorySecuritySource securitySource = new InMemorySecuritySource();
securitySource.addSecurity(defSec);
// This function doesn't actually require anything, so it can compute at the node level without anything else.
// Hence, the only target will be the node.
final MockFunction fn1 = MockFunction.getMockFunction(new ComputationTarget(ComputationTargetType.PORTFOLIO_NODE, pn), 14.2);
final InMemoryFunctionRepository functionRepo = new InMemoryFunctionRepository();
functionRepo.addFunction(fn1);
final FunctionCompilationContext functionCompilationContext = new FunctionCompilationContext();
functionCompilationContext.setFunctionInitId(123);
functionCompilationContext.setSecuritySource(securitySource);
final CompiledFunctionService cfs = new CompiledFunctionService(functionRepo, new CachingFunctionRepositoryCompiler(), functionCompilationContext);
cfs.initialize();
final DefaultFunctionResolver functionResolver = new DefaultFunctionResolver(cfs);
final DefaultCachingComputationTargetResolver computationTargetResolver = new DefaultCachingComputationTargetResolver(new DefaultComputationTargetResolver(securitySource, positionSource),
_cacheManager);
functionCompilationContext.setRawComputationTargetResolver(computationTargetResolver);
final ViewCompilationServices vcs = new ViewCompilationServices(new FixedMarketDataAvailabilityProvider(), functionResolver, functionCompilationContext, new PoolExecutor(1, getClass()
.getSimpleName()),
new DependencyGraphBuilderFactory());
final ViewDefinition viewDefinition = new ViewDefinition("My View", UniqueId.of("FOO", "BAR"), "kirk");
// We've not provided a function that targets the position level, so we can't ask for it.
viewDefinition.getResultModelDefinition().setPositionOutputMode(ResultOutputMode.NONE);
final ViewCalculationConfiguration calcConfig = new ViewCalculationConfiguration(viewDefinition, "Fibble");
calcConfig.addPortfolioRequirementName("My Sec", "OUTPUT");
viewDefinition.addViewCalculationConfiguration(calcConfig);
final CompiledViewDefinitionWithGraphsImpl compiledViewDefinition = ViewDefinitionCompiler.compile(viewDefinition, vcs, Instant.now(), VersionCorrection.LATEST);
assertTrue(compiledViewDefinition.getMarketDataRequirements().isEmpty());
assertEquals(1, compiledViewDefinition.getDependencyGraphExplorers().size());
assertNotNull(compiledViewDefinition.getDependencyGraphExplorer("Fibble"));
assertTargets(compiledViewDefinition, pn.getUniqueId());
}