assertTrue(getResultsCalled.get());
}
public void functionWithDynamicConversionTwoLevel() {
final DepGraphTestHelper helper = helper();
final MockFunction fn1 = helper.addFunctionProducing(helper.getValue1Foo());
// This converter will manipulate a value name but preserve a property; requiring late-stage property/constraint composition
final MockFunction fnConv1 = new MockFunction("conv1", helper.getTarget()) {
@Override
public Set<ValueSpecification> getResults(FunctionCompilationContext context, ComputationTarget target) {
final ValueRequirement req = helper.getRequirement2Any();
return Collections.singleton(new ValueSpecification(req.getValueName(), target.toSpecification(), req.getConstraints().copy().with(ValuePropertyNames.FUNCTION, getUniqueId()).get()));
}
@Override
public Set<ValueSpecification> getResults(FunctionCompilationContext context, ComputationTarget target, Map<ValueSpecification, ValueRequirement> inputs) {
s_logger.debug("fnConv1 late resolving with inputs {}", inputs);
assertEquals(1, inputs.size());
final ValueSpecification input = inputs.keySet().iterator().next();
return Collections.singleton(new ValueSpecification(helper.getRequirement2().getValueName(), target.toSpecification(),
ValueProperties.with(ValuePropertyNames.FUNCTION, getUniqueId()).with("TEST", input.getProperties().getValues("TEST")).get()));
}
};
fnConv1.addRequirement(helper.getRequirement1Any());
helper.getFunctionRepository().addFunction(fnConv1);
// This converter will preserve the value name but manipulate a property; and be selected if a converter is needed on top
// of fnConv1 after late-stage composition
final MockFunction fnConv2 = new MockFunction("conv2", helper.getTarget()) {
@Override
public Set<ValueSpecification> getResults(FunctionCompilationContext context, ComputationTarget target) {
final ValueRequirement req = helper.getRequirement2Any();
return Collections.singleton(new ValueSpecification(req.getValueName(), target.toSpecification(), req.getConstraints().copy().with(ValuePropertyNames.FUNCTION, getUniqueId()).get()));
}
@Override
public Set<ValueSpecification> getResults(FunctionCompilationContext context, ComputationTarget target, Map<ValueSpecification, ValueRequirement> inputs) {
s_logger.debug("fnConv2 late resolving with inputs {}", inputs);
assertEquals(1, inputs.size());
return super.getResults(context, target, inputs);
}
};
fnConv2.addRequirement(helper.getRequirement2Any());
helper.getFunctionRepository().addFunction(fnConv2);
DependencyGraphBuilder builder = helper.createBuilder(new FunctionPriority() {
@Override
public int getPriority(CompiledFunctionDefinition function) {
if (function == fnConv2) {