Package com.opengamma.core.change

Examples of com.opengamma.core.change.ChangeEvent


    throw new UnsupportedOperationException("removeChangeListener not implemented");
  }

  @Override
  public void entityChanged(ChangeType type, ObjectId objectId, Instant versonFrom, Instant versionTo, Instant versionInstant) {
    ChangeEvent event = new ChangeEvent(type, objectId, versonFrom, versionTo, versionInstant);
    for (ChangeListener listener : _listeners) {
      listener.entityChanged(event);
    }
  }
View Full Code Here


  /**
   * Checks that a listener to changes to an entity gets fired once and once only.
   */
  @Test
  public void subscribeToEntityEvent() {
    ChangeEvent event = new ChangeEvent(ChangeType.CHANGED, _uid1.getObjectId(), null, null, Instant.now());

    // send an event and make sure the _listener doesn't receive it before subscription
    _connection.entityChanged(event);
    verify(_listener, never()).itemsUpdated(anyCollection());

View Full Code Here

  /**
   * Multiple URLs subscribing to the same entity should produce multiple updates when the entity changes.
   */
  @Test
  public void multipleSubscriptionsToEntity() {
    ChangeEvent event = new ChangeEvent(ChangeType.CHANGED, _uid1.getObjectId(), null, null, Instant.now());

    // subscribe and verify the listener receives the event
    _connection.subscribe(_uid1, TEST_URL1);
    _connection.subscribe(_uid1, TEST_URL2);
    _connection.entityChanged(event);
View Full Code Here

   * A particular URL should only have one event delivered no matter how many subscriptions it has.  After the
   * first event no more should be triggered until a new subscription is set up.
   */
  @Test
  public void multipeEntitySubscriptionsForSameUrl() {
    ChangeEvent event1 = new ChangeEvent(ChangeType.CHANGED, _uid1.getObjectId(), null, null, Instant.now());
    ChangeEvent event2 = new ChangeEvent(ChangeType.CHANGED, _uid2.getObjectId(), null, null, Instant.now());

    // subscribe and verify the listener receives the event
    _connection.subscribe(_uid1, TEST_URL1);
    _connection.subscribe(_uid2, TEST_URL1);
    _connection.entityChanged(event1);
View Full Code Here

  public void masterAndEntitySubscriptionForSameUrlMasterChangesFirst() {
    _connection.subscribe(_uid1, TEST_URL1);
    _connection.subscribe(MasterType.PORTFOLIO, TEST_URL1);
    _connection.masterChanged(MasterType.PORTFOLIO);
    verify(_listener).itemsUpdated(CollectionMatcher.collectionOf(TEST_URL1));
    _connection.entityChanged(new ChangeEvent(ChangeType.CHANGED, _uid1.getObjectId(), null, null, Instant.now()));
    verifyNoMoreInteractions(_listener);
  }
View Full Code Here

   */
  @Test
  public void masterAndEntitySubscriptionForSameUrlEntityChangesFirst() {
    _connection.subscribe(_uid1, TEST_URL1);
    _connection.subscribe(MasterType.PORTFOLIO, TEST_URL1);
    _connection.entityChanged(new ChangeEvent(ChangeType.CHANGED, _uid1.getObjectId(), null, null, Instant.now()));
    verify(_listener).itemsUpdated(CollectionMatcher.collectionOf(TEST_URL1));
    _connection.masterChanged(MasterType.PORTFOLIO);
    verifyNoMoreInteractions(_listener);
  }
View Full Code Here

   * Checks that nothing happens when a subscription is set up for an entity and a different entity changes.
   */
  @Test
  public void subscriptionForDifferentEntity() {
    _connection.subscribe(_uid1, TEST_URL1);
    _connection.entityChanged(new ChangeEvent(ChangeType.CHANGED, _uid2.getObjectId(), null, null, Instant.now()));
    verifyZeroInteractions(_listener);
  }
View Full Code Here

    @Override
    public void entityChanged(ChangeType type, ObjectId oid, Instant versionFrom, Instant versionTo, Instant versionInstant) {     
    }

    public void notifyListenerUnwatchedIdentifier() {
      _listener.entityChanged(new ChangeEvent(ChangeType.CHANGED, ObjectId.of("Test", "Unwatched"), null, null, Instant.now()));
    }
View Full Code Here

    public void notifyListenerUnwatchedIdentifier() {
      _listener.entityChanged(new ChangeEvent(ChangeType.CHANGED, ObjectId.of("Test", "Unwatched"), null, null, Instant.now()));
    }

    public void notifyListenerWatchedIdentifier() {
      _listener.entityChanged(new ChangeEvent(ChangeType.CHANGED, ObjectId.of("Test", "Watched"), null, null, Instant.now()));
    }
View Full Code Here

    return Collections.emptyList();
  }

  @Override
  public List<String> entityChanged(MasterChangeNotification<?> notification) {
    ChangeEvent event = notification.getEvent();
    if (isChangeRelevant(event)) {
      if (event.getType() == ChangeType.REMOVED) {
        // TODO clean up trades from cache if this is a position that has been removed
        _cache.remove(event.getObjectId());
        _portfolioGrid = _portfolioGrid.withUpdatedRows(_portfolioSupplier.get());
        // return the IDs of all grids because the portfolio structure has changed
        // TODO if we had separate IDs for rows and columns it would save the client rebuilding the column metadata
        return getGridIds();
      } else {
View Full Code Here

TOP

Related Classes of com.opengamma.core.change.ChangeEvent

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.