return Collections.emptySet();
}
@Override
protected Set<ValueSpecification> getResults(final ComputationTargetSpecification targetSpec, final Security security) {
return Collections.singleton(new ValueSpecification(VALUE_1, targetSpec, properties().with(ValuePropertyNames.CURRENCY, security.getName()).get()));
}
});
repository.addFunction(new MockPositionFunction(FUNCTION_1_TYPE_1_POSITION) {
@Override
public boolean canApplyTo(final Position position) {
// TODO: try with just "return true" and rely on the downstream function
return SECURITY_TYPE_1.equals(position.getSecurity().getSecurityType());
}
@Override
public Set<ValueSpecification> getResults(final ComputationTargetSpecification targetSpec, final Position position) {
return Collections.singleton(new ValueSpecification(VALUE_1, targetSpec, properties().with(ValuePropertyNames.CURRENCY, position.getSecurity().getName()).get()));
}
@Override
public Set<ValueRequirement> getRequirements(final Position position, final ValueRequirement desiredValue) {
return Collections.singleton(new ValueRequirement(VALUE_1, ComputationTargetSpecification.of(position.getSecurity())));
}
});
repository.addFunction(new MockPositionFunction(FUNCTION_2_TYPE_1_POSITION) {
@Override
protected boolean canApplyTo(final Position position) {
return SECURITY_TYPE_1.equals(position.getSecurity().getSecurityType());
}
@Override
protected Set<ValueSpecification> getResults(final ComputationTargetSpecification targetSpec, final Position position) {
return Collections.singleton(new ValueSpecification(VALUE_2, targetSpec, properties().with(ValuePropertyNames.CURRENCY, position.getSecurity().getName()).get()));
}
@Override
public Set<ValueRequirement> getRequirements(final Position position, final ValueRequirement desiredValue) {
return Collections.emptySet();
}
});
repository.addFunction(new MockPositionFunction(FUNCTION_TYPE_2_POSITION) {
@Override
protected boolean canApplyTo(final Position position) {
return SECURITY_TYPE_2.equals(position.getSecurity().getSecurityType());
}
@Override
protected Set<ValueSpecification> getResults(final ComputationTargetSpecification targetSpec, final Position position) {
final Set<ValueSpecification> result = new HashSet<ValueSpecification>();
result.add(new ValueSpecification(VALUE_1, targetSpec, properties().with(ValuePropertyNames.CURRENCY, position.getSecurity().getName()).get()));
result.add(new ValueSpecification(VALUE_2, targetSpec, properties().with(ValuePropertyNames.CURRENCY, position.getSecurity().getName()).get()));
return result;
}
@Override
public Set<ValueRequirement> getRequirements(final Position position, final ValueRequirement desiredValue) {
return Collections.emptySet();
}
});
repository.addFunction(new MockPortfolioNodeFunction(FUNCTION_SUM_NODE) {
@Override
protected boolean canApplyTo(final PortfolioNode node) {
return true;
}
@Override
protected Set<ValueSpecification> getResults(final ComputationTargetSpecification targetSpec, final PortfolioNode node) {
final Set<ValueSpecification> result = new HashSet<ValueSpecification>();
result.add(new ValueSpecification(VALUE_1, targetSpec, properties().withAny(ValuePropertyNames.CURRENCY).get()));
result.add(new ValueSpecification(VALUE_2, targetSpec, properties().withAny(ValuePropertyNames.CURRENCY).get()));
return result;
}
@Override
public Set<ValueRequirement> getRequirements(final PortfolioNode node, final ValueRequirement desiredValue) {