}
}
public void testContextPositionFunction() {
final ComputationTarget target = new ComputationTarget(ComputationTargetType.of(SimplePosition.class), mock(SimplePosition.class));
final ParameterizedFunction pfn = function(new TestContextPositionFunction(), "1");
final FunctionCompilationContext context = new FunctionCompilationContext();
final ComputationTargetResolver.AtVersionCorrection targetResolver = Mockito.mock(ComputationTargetResolver.AtVersionCorrection.class);
Mockito.when(targetResolver.resolve(target.toSpecification())).thenReturn(target);
context.setComputationTargetResolver(targetResolver);
final DefaultCompiledFunctionResolver resolver = new DefaultCompiledFunctionResolver(context);
resolver.addRule(new ResolutionRule(pfn, ApplyToAllTargets.INSTANCE, 0));
resolver.compileRules();
assertFalse(resolver.resolveFunction("Value", target, ValueProperties.none()).hasNext());
Triple<ParameterizedFunction, ValueSpecification, Collection<ValueSpecification>> result = resolver.resolveFunction(
"Value", new ComputationTarget(new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO_NODE, UniqueId.of("Node", "0")).containing(ComputationTargetType.of(SimplePosition.class),
target.getUniqueId()), target.getValue()), ValueProperties.none()).next();
assertEquals(result.getFirst(), pfn);
}