final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
final SynchronousInMemoryLKVSnapshotProvider marketDataProvider = new SynchronousInMemoryLKVSnapshotProvider();
marketDataProvider.addValue(ViewProcessorTestEnvironment.getPrimitive1(), 0);
marketDataProvider.addValue(ViewProcessorTestEnvironment.getPrimitive2(), 0);
env.setMarketDataProvider(marketDataProvider);
final InMemoryFunctionRepository functionRepository = new InMemoryFunctionRepository();
final ComputationTarget target = new ComputationTarget(ComputationTargetType.CURRENCY, Currency.USD);
final MockFunction fn1 = new MockFunction(MockFunction.UNIQUE_ID + "1", target) {
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
LogBridge.getInstance().log(new SimpleLogEvent(LogLevel.WARN, "Warning during execution"));
LogBridge.getInstance().log(new SimpleLogEvent(LogLevel.ERROR, "Error during execution"));
return super.execute(executionContext, inputs, target, desiredValues);
}
};
final ValueRequirement requirement1 = new ValueRequirement("value1", target.toSpecification());
fn1.addResult(new ValueSpecification(requirement1.getValueName(), target.toSpecification(), ValueProperties.with(ValuePropertyNames.FUNCTION, "fn1").get()), "result1");
functionRepository.addFunction(fn1);
final MockFunction fn2 = new MockFunction(MockFunction.UNIQUE_ID + "2", target) {
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
LogBridge.getInstance().log(new SimpleLogEvent(LogLevel.WARN, "Warning during execution"));
return super.execute(executionContext, inputs, target, desiredValues);
}
};
fn2.addRequirement(requirement1);
final ValueRequirement requirement2 = new ValueRequirement("value2", target.toSpecification());
fn2.addResult(new ValueSpecification(requirement2.getValueName(), target.toSpecification(), ValueProperties.with(ValuePropertyNames.FUNCTION, "fn2").get()), "result2");
functionRepository.addFunction(fn2);
env.setFunctionRepository(functionRepository);
final ViewDefinition vd = new ViewDefinition(UniqueId.of("test", "vd1"), "Test view", UserPrincipal.getLocalUser());
final ViewCalculationConfiguration calcConfig = new ViewCalculationConfiguration(vd, "Default");