Package com.opengamma.engine.target

Examples of com.opengamma.engine.target.Primitive


    final ComputationTargetResolver.AtVersionCorrection underlying = Mockito.mock(ComputationTargetResolver.AtVersionCorrection.class);
    final ConcurrentMap<ComputationTargetReference, UniqueId> resolutions = new ConcurrentHashMap<ComputationTargetReference, UniqueId>();
    final Set<UniqueId> expiredResolutions = new HashSet<UniqueId>();
    final ComputationTargetResolver.AtVersionCorrection resolver = TargetResolutionLogger.of(underlying, resolutions, expiredResolutions);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.PRIMITIVE, UniqueId.of("Foo", "Bar"));
    final ComputationTarget target = new ComputationTarget(spec.replaceIdentifier(UniqueId.of("Foo", "Bar", "Cow")), new Primitive(UniqueId.of("Foo", "Bar", "Cow")));
    Mockito.when(underlying.resolve(spec)).thenReturn(target);
    final ObjectResolver shallowResolver = Mockito.mock(ObjectResolver.class);
    Mockito.when(underlying.getResolver(spec)).thenReturn(shallowResolver);
    assertSame(resolver.resolve(spec), target);
  }
View Full Code Here


    final ComputationTargetResolver.AtVersionCorrection underlying = Mockito.mock(ComputationTargetResolver.AtVersionCorrection.class);
    final ConcurrentMap<ComputationTargetReference, UniqueId> resolutions = new ConcurrentHashMap<ComputationTargetReference, UniqueId>();
    final Set<UniqueId> expiredResolutions = new HashSet<UniqueId>();
    final ComputationTargetResolver.AtVersionCorrection resolver = TargetResolutionLogger.of(underlying, resolutions, expiredResolutions);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.PRIMITIVE, UniqueId.of("Foo", "Bar"));
    final ComputationTarget target = new ComputationTarget(spec.replaceIdentifier(UniqueId.of("Foo", "Bar", "Cow")), new Primitive(UniqueId.of("Foo", "Bar", "Cow")));
    Mockito.when(underlying.resolve(spec)).thenReturn(target);
    final ObjectResolver deepResolver = Mockito.mock(ObjectResolver.class);
    Mockito.when(deepResolver.deepResolver()).thenReturn(new DeepResolver() {
      @SuppressWarnings("serial")
      @Override
      public UniqueIdentifiable withLogger(final UniqueIdentifiable underlying, final ResolutionLogger logger) {
        assertSame(underlying, target.getValue());
        return new Primitive(UniqueId.of("Foo", "Bar", "Cow")) {
          @Override
          public int hashCode() {
            // Pretend that this is a deep-resolving operation
            logger.log(spec, underlying.getUniqueId());
            return super.hashCode();
View Full Code Here

    assertEquals(resolver.resolveObject(UniqueId.of("Foo", "Bar"), VersionCorrection.LATEST), null);
  }

  public void testPrimitiveResolver() {
    final Resolver<?> resolver = new PrimitiveResolver();
    assertEquals(resolver.resolveObject(UniqueId.of("Foo", "Bar"), VersionCorrection.LATEST), new Primitive(UniqueId.of("Foo", "Bar")));
    final ExternalId[] eids = new ExternalId[] {ExternalId.of("Foo", "A"), ExternalId.of("Foo-", "A"), ExternalId.of("Foo\\", "A"), ExternalId.of("Foo", "A-B"), ExternalId.of("Foo-Bar", "A"),
        ExternalId.of("Foo-Bar", "A-B"), ExternalId.of("Foo\\-Bar", "A\\B"), ExternalId.of("Foo\\\\Bar", "A\\\\B") };
    for (ExternalId eid : eids) {
      final UniqueId uid = resolver.resolveExternalId(eid.toBundle(), VersionCorrection.LATEST);
      final Object o = resolver.resolveObject(uid, VersionCorrection.LATEST);
View Full Code Here

  }

  public void testMissing() {
    final MarketDataAvailabilityFilter availability = create();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final Object target = new Primitive(UniqueId.of("Security", "Foo"));
    final ValueRequirement desiredValue = new ValueRequirement("Value", targetSpec);
    assertFalse(availability.isAvailable(targetSpec, target, desiredValue));
  }
View Full Code Here

  public void testPresent() {
    final MarketDataAvailabilityFilter availability = create();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final ValueRequirement desiredValue = new ValueRequirement("Market_Value", targetSpec);
    assertTrue(availability.isAvailable(targetSpec, new Primitive(UniqueId.of("Security", "Foo")), desiredValue));
    assertTrue(availability.isAvailable(targetSpec, new ExternalIdentifiablePrimitive(UniqueId.of("Security", "Foo"), ExternalId.of("Foo", "Bar")), desiredValue));
  }
View Full Code Here

  }

  public void testGetAvailability_uniqueId() {
    final MarketDataAvailabilityFilter availability = create();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final Object target = new Primitive(UniqueId.of("Security", "Foo"));
    ValueRequirement desiredValue = new ValueRequirement("Cow", targetSpec);
    assertFalse(availability.isAvailable(targetSpec, target, desiredValue));
    desiredValue = new ValueRequirement("Foo", targetSpec);
    assertFalse(availability.isAvailable(targetSpec, target, desiredValue));
  }
View Full Code Here

  }

  public void testGetAvailability() {
    final MarketDataAvailabilityProvider availability = create();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final Object target = new Primitive(UniqueId.of("Security", "Foo"));
    assertNull(availability.getAvailability(targetSpec, target, new ValueRequirement("Value", targetSpec)));
    assertNotNull(availability.getAvailability(targetSpec, new Primitive(UniqueId.of("Security", "Foo")), new ValueRequirement("Market_Value", targetSpec)));
  }
View Full Code Here

  }

  public void testIsAvailable() {
    final MarketDataAvailabilityFilter availability = create().getAvailabilityFilter();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final Object target = new Primitive(UniqueId.of("Security", "Foo"));
    assertFalse(availability.isAvailable(targetSpec, target, new ValueRequirement("Value", targetSpec)));
    assertTrue(availability.isAvailable(targetSpec, new Primitive(UniqueId.of("Security", "Foo")), new ValueRequirement("Market_Value", targetSpec)));
  }
View Full Code Here

  }

  public void testMissing() {
    final MarketDataAvailabilityFilter availability = create();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final Object target = new Primitive(UniqueId.of("Security", "Foo"));
    final ValueRequirement desiredValue = new ValueRequirement("Cow", targetSpec);
    assertFalse(availability.isAvailable(targetSpec, target, desiredValue));
  }
View Full Code Here

  }

  public void testPresent_uniqueId() {
    final MarketDataAvailabilityFilter availability = create();
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(ComputationTargetType.SECURITY, UniqueId.of("Security", "Foo"));
    final Object target = new Primitive(UniqueId.of("Security", "Foo"));
    final ValueRequirement desiredValue = new ValueRequirement("Bar", targetSpec);
    assertTrue(availability.isAvailable(targetSpec, target, desiredValue));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.target.Primitive

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.