CurrencyMatrixLookupFunction extends AbstractFunction.NonCompiledInvoker { @Override public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target) { final ComputationTargetSpecification targetSpec = target.toSpecification(); final ValueProperties properties = createValueProperties().withAny(CURRENCY_MATRIX_NAME_PROPERTY).get(); return ImmutableSet.of(createSpotRateResult(targetSpec, properties), createHistoricalTimeSeriesResult(targetSpec, properties), createTimeSeriesLatestResult(targetSpec, properties)); } CurrencyMatrixLookupFunction(final String defaultCurrencyMatrixName);  CurrencyMatrixLookupFunction(final String[] params); @Override ComputationTargetType getTargetType(); @Override Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target); @Override Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue); @Override Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target, final Map<ValueSpecification, ValueRequirement> inputs); @Override Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues); int getPriority();  }
@Test public void testGetResults1() { final ComputationTarget ct = new ComputationTarget(CurrencyPair.TYPE, CurrencyPair.parse("USD/EUD")); final Set<ValueSpecification> results = _function.getResults(_functionCompilationContext, ct); assertEquals(3, results.size()); }
@Test public void testGetResults2() { ComputationTarget target = new ComputationTarget(CurrencyPair.TYPE, CurrencyPair.parse("GBP/USD")); Set<ValueSpecification> results = _function.getResults( _functionCompilationContext, target, ImmutableMap.of( new ValueSpecification(ValueRequirementNames.SPOT_RATE, new ComputationTargetSpecification(CurrencyMatrixResolver.TYPE, UniqueId.of("Matrix", "0")), ValueProperties.with( ValuePropertyNames.FUNCTION, "Test").get()), new ValueRequirement(ValueRequirementNames.SPOT_RATE, new ComputationTargetRequirement(CurrencyMatrixResolver.TYPE, ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Foo"))))); assertEquals( Iterables.getOnlyElement(results), new ValueSpecification(ValueRequirementNames.SPOT_RATE, target.toSpecification(), ValueProperties.with(ValuePropertyNames.FUNCTION, "currencyMatrixLookup") .with(CurrencyMatrixLookupFunction.CURRENCY_MATRIX_NAME_PROPERTY, "Foo").get())); }