Package org.apache.tuscany.sdo.api

Examples of org.apache.tuscany.sdo.api.Event


import org.eclipse.emf.common.notify.impl.AdapterImpl;

public abstract class ListenerBase extends AdapterImpl implements EventListener  {

  public void notifyChanged(Notification msg) {
    Event e = new EventImpl(msg);
    eventNotification(e);
  }
View Full Code Here


    Type quoteType = th.getType(TEST_NAMESPACE, "Quote");
    DataObject quote = hc.getDataFactory().create(quoteType);
    Observer o = new Observer();
    SDOUtil.addChangeListener(quote, o);

    Event e;

    String firstName = "FlyByNightTechnology";

    int changeCount = 0;
   
    quote.setString("companyName", firstName);
    assertEquals(++changeCount, o.getNotificationCount());
    e = o.getLastEvent();
    assertEquals(Event.SET, e.getEventType());
    assertEquals(null, e.getOldValue());
    assertFalse(e.wasSet());

    quote.setString("companyName", "FBNT");
    e = o.getLastEvent();
    assertTrue(e.wasSet());

    assertEquals(firstName, e.getOldValue());
    assertEquals(++changeCount, o.getNotificationCount());
    assertEquals("companyName", e.getProperty().getName());

    SDOUtil.removeChangeListener(quote, o);

    quote.setString("companyName", "3rdValue");
    e = o.getLastEvent();

    assertEquals(firstName, e.getOldValue());
    assertEquals(changeCount /* no ++ */, o.getNotificationCount());

    SDOUtil.addChangeListener(quote, o);

    quote.setString("companyName", "3rdValue");
    assertEquals(++changeCount, o.getNotificationCount());
    e = o.getLastEvent();
    assertTrue(e.isTouch());
    assertTrue(e.wasSet());

    quote.unset("companyName");
    assertEquals(++changeCount, o.getNotificationCount());
    e = o.getLastEvent();
    assertTrue(e.wasSet());
  

    quote.set("companyName", "4thValue");
    assertEquals(++changeCount, o.getNotificationCount());
    e = o.getLastEvent();
    assertFalse(e.wasSet());
   
    assertEquals(Event.NO_INDEX, e.getPosition());
   
    DataObject child = quote.createDataObject("quotes");
    assertEquals(++changeCount, o.getNotificationCount());
    e = o.getLastEvent();
    assertFalse(e.wasSet());
    assertEquals(0, e.getPosition());
    assertEquals(Event.ADD, e.getEventType());
   
    DataObject child2 = quote.createDataObject("quotes");
    assertEquals(++changeCount, o.getNotificationCount());
    e = o.getLastEvent();
    assertTrue(e.wasSet())// the quotes property was previously set to a non empty list
    assertEquals(1, e.getPosition());
   
    child2.setString("companyName", "subsidiary");
   
    assertEquals(changeCount /* no ++ */, o.getNotificationCount()); // not monitoring the child
   
    quote.getList("quotes").clear();
    e = o.getLastEvent();
    assertEquals(++changeCount, o.getNotificationCount());
    assertEquals(Event.REMOVE_MANY, e.getEventType());
   
    List newList = new ArrayList();
   
    newList.add(hc.getDataFactory().create(quoteType));
    newList.add(hc.getDataFactory().create(quoteType));
   
    quote.getList("quotes").addAll(newList);
    e = o.getLastEvent();
    assertEquals(++changeCount, o.getNotificationCount());
    assertEquals(Event.ADD_MANY, e.getEventType());
   

   

  }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sdo.api.Event

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.