Mockito.when(positionSource.getPosition(POSITION.getUniqueId())).thenReturn(POSITION);
Mockito.when(positionSource.getPosition(Mockito.eq(POSITION.getUniqueId().getObjectId()), Mockito.any(VersionCorrection.class))).thenReturn(POSITION);
final FunctionCompilationContext context = new FunctionCompilationContext();
context.setRawComputationTargetResolver(new DefaultComputationTargetResolver(securitySource, positionSource));
context.setComputationTargetResolver(context.getRawComputationTargetResolver().atVersionCorrection(VersionCorrection.of(Instant.now(), Instant.now())));
final CompiledFunctionService cfs = new CompiledFunctionService(functionRepo, new CachingFunctionRepositoryCompiler(), context);
cfs.initialize();
final FunctionResolver functionResolver = new DefaultFunctionResolver(cfs);
final CompiledFunctionResolver compiledFunctionResolver = functionResolver.compile(Instant.now());
final ComputationTargetResults results = new ComputationTargetResults(compiledFunctionResolver.getAllResolutionRules());
results.setFunctionCompilationContext(context);
return results;