Package com.opengamma.engine.value

Examples of com.opengamma.engine.value.ValueSpecification


    final MockFunction function = new MockFunction(target);
    return new ParameterizedFunction(function, function.getDefaultParameters());
  }

  private ValueSpecification valueSpecification(final ValueRequirement requirement) {
    return new ValueSpecification(requirement.getValueName(), requirement.getTargetReference().getSpecification(), ValueProperties.with(ValuePropertyNames.FUNCTION, "Mock").get());
  }
View Full Code Here


  public void testFunctionApplication() {
    final ValueRequirement req1 = valueRequirement();
    final ValueRequirement req2 = valueRequirement();
    final ValueRequirement req3 = valueRequirement();
    final ParameterizedFunction function = parameterizedFunction();
    final ValueSpecification spec1 = valueSpecification(req1);
    final ValueSpecification spec2 = valueSpecification(req2);
    assertEncodeDecodeCycle(ResolutionFailure.class, ResolutionFailureImpl.functionApplication(req1, function, spec1).getRequirementsFailed());
    assertEncodeDecodeCycle(ResolutionFailure.class, ResolutionFailureImpl.functionApplication(req1, function, spec1).requirement(req2, ResolutionFailureImpl.recursiveRequirement(req2)));
    assertEncodeDecodeCycle(ResolutionFailure.class, ResolutionFailureImpl.functionApplication(req1, function, spec1).requirements(Collections.singletonMap(spec2, req2)));
    assertEncodeDecodeCycle(ResolutionFailure.class,
        ResolutionFailureImpl.functionApplication(req1, function, spec1).requirements(Collections.singletonMap(spec2, req2)).requirement(req3, ResolutionFailureImpl.unsatisfied(req3)));
View Full Code Here

*/
@Test(groups = TestGroup.UNIT)
public class DependencyNodeJobExecutionResultCacheTest {

  private ValueSpecification createValueSpec(final int id) {
    return new ValueSpecification("V", ComputationTargetSpecification.NULL, ValueProperties.with(ValuePropertyNames.FUNCTION, "Test").with("Id", Integer.toString(id)).get());
  }
View Full Code Here

  }

  public void testBasic() {
    final ComputationTargetRequirement targetReq = ComputationTargetRequirement.of(ExternalId.of("Foo", "Bar"));
    final ComputationTargetSpecification targetSpec = ComputationTargetSpecification.of(UniqueId.of("Sec", "123"));
    final ValueSpecification valueSpecification = new ValueSpecification("Value", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get());
    final ValueRequirement valueRequirement = new ValueRequirement("Value", targetReq);
    final ValueSpecification dataSpecification1 = new ValueSpecification("Data1", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get());
    final ValueSpecification dataSpecification2a = new ValueSpecification("Data2a", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get());
    final ValueSpecification dataSpecification2b = new ValueSpecification("Data2b", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get());
    final ValueSpecification dataSpecification3a = new ValueSpecification("Data3a", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get());
    final ValueSpecification dataSpecification3b = new ValueSpecification("Data3b", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get());
    final ValueSpecification dataSpecification3c = new ValueSpecification("Data3c", targetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get());
    final CompiledViewCalculationConfiguration in = new CompiledViewCalculationConfigurationImpl("2", ImmutableSet.of(ComputationTargetSpecification.NULL, targetSpec),
        ImmutableMap.<ValueSpecification, Set<ValueRequirement>>of(valueSpecification, ImmutableSet.of(valueRequirement)), ImmutableMap.<ValueSpecification, Collection<ValueSpecification>>of(
            dataSpecification1, Collections.singleton(dataSpecification1),
            dataSpecification2a, Collections.singleton(dataSpecification2b),
            dataSpecification3a, ImmutableSet.of(dataSpecification3a, dataSpecification3b, dataSpecification3c)));
View Full Code Here

    final MockFunction function = new MockFunction(target);
    return new ParameterizedFunction(function, function.getDefaultParameters());
  }

  private ValueSpecification valueSpecification(final ValueRequirement requirement) {
    return new ValueSpecification(requirement.getValueName(), requirement.getTargetReference().getSpecification(), ValueProperties.with(ValuePropertyNames.FUNCTION, "Mock").get());
  }
View Full Code Here

  public void testFunctionApplication() {
    final ValueRequirement req1 = valueRequirement();
    final ValueRequirement req2 = valueRequirement();
    final ValueRequirement req3 = valueRequirement();
    final ParameterizedFunction function = parameterizedFunction();
    final ValueSpecification spec1 = valueSpecification(req1);
    final ValueSpecification spec2 = valueSpecification(req2);
    assertEquals(ResolutionFailureImpl.functionApplication(req1, function, spec1).getRequirementsFailed(), "getRequirementsFailed=" + req1 + ",mock," + spec1);
    assertEquals(ResolutionFailureImpl.functionApplication(req1, function, spec1).requirement(req2, null), "failedFunction=" + req1 + ",mock," + spec1 + ",{},[unsatisfied=" + req2 + "]");
    assertEquals(ResolutionFailureImpl.functionApplication(req1, function, spec1).requirement(req2, ResolutionFailureImpl.recursiveRequirement(req2)), "failedFunction=" + req1 + ",mock," + spec1 +
        ",{},[recursiveRequirement=" + req2 + "]");
    assertEquals(ResolutionFailureImpl.functionApplication(req1, function, spec1).requirements(Collections.singletonMap(spec2, req2)), "successfulFunction=" + req1 + ",mock," + spec1 + ",{" + spec2 +
View Full Code Here

    assertEquals(2, nodes.size());
    for (DependencyNode node : nodes) {
      if (ObjectUtils.equals(node.getFunction().getFunction(), fn1)) {
        assertTrue(node.getOutputValues().contains(helper.getSpec1()));
        assertEquals(1, node.getInputNodes().size());
        ValueSpecification inputSpec = node.getInputValues().iterator().next();
        assertEquals(helper.getSpec2().getValueName(), inputSpec.getValueName());
        assertEquals(helper.getSpec2().getTargetSpecification(), inputSpec.getTargetSpecification());
        assertEquals(helper.getTarget().toSpecification(), node.getComputationTarget());
      } else if (node.getFunction().getFunction() instanceof MarketDataSourcingFunction) {
        assertFalse(node.getOutputValues().contains(helper.getSpec1()));
        assertEquals(1, node.getOutputValues().size());
        ValueSpecification outputSpec = node.getOutputValues().iterator().next();
        assertEquals(helper.getSpec2().getValueName(), outputSpec.getValueName());
        assertEquals(helper.getSpec2().getTargetSpecification(), outputSpec.getTargetSpecification());
        assertTrue(node.getInputValues().isEmpty());
        assertTrue(node.getInputNodes().isEmpty());
      } else {
        Assert.fail("Unexpected function definition");
      }
View Full Code Here

  public void testPopulated() {
    final FunctionBlacklistRule rule = new FunctionBlacklistRule();
    rule.setFunctionIdentifier("Foo");
    rule.setFunctionParameters(new EmptyFunctionParameters());
    rule.setTarget(ComputationTargetSpecification.of(UniqueId.of("Test", "Bar")));
    rule.setInputs(Arrays.asList(new ValueSpecification("Foo", rule.getTarget(), ValueProperties.with(ValuePropertyNames.FUNCTION, "Fn").get())));
    rule.setOutputs(Arrays.asList(new ValueSpecification("Bar", rule.getTarget(), ValueProperties.with(ValuePropertyNames.FUNCTION, "Fn").get())));
    assertEncodeDecodeCycle(FunctionBlacklistRule.class, rule);
  }
View Full Code Here

        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) {
View Full Code Here

  }

  @Test
  public void testMarketDataSubscriptionFailing() {

    ValueSpecification valueSpec = createValueSpecForMarketValue("AAPL.");
    _manager.requestMarketDataSubscriptions(ImmutableSet.of(valueSpec));
    _manager.subscriptionFailed(valueSpec, "Que?");

    checkSingleSubscriptionState("AAPL.", SubscriptionStateQuery.SubscriptionState.FAILED);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.value.ValueSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.