Search in sources :

Example 1 with RemoveElementPropertyChangeEvent

use of ch.acanda.eclipse.pmd.domain.DomainModel.RemoveElementPropertyChangeEvent in project eclipse-pmd by acanda.

the class WorkspaceModelTest method removeFiresARemoveElementPropertyChangeEvent.

/**
 * Verifies that an event is fired when removing a project model.
 */
@Test
public void removeFiresARemoveElementPropertyChangeEvent() {
    final WorkspaceModel model = new WorkspaceModel();
    final boolean[] eventFired = new boolean[1];
    final ProjectModel element = new ProjectModel("Foo");
    model.add(element);
    model.addPropertyChangeListener(WorkspaceModel.PROJECTS_PROPERTY, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            eventFired[0] = true;
            assertTrue("The event should be an RemoveElementPropertyChangeEvent", event instanceof RemoveElementPropertyChangeEvent);
            assertSame("Event's added element", element, ((RemoveElementPropertyChangeEvent) event).getRemovedElement());
            assertSame("Event's old value should be the removed element", element, event.getOldValue());
            assertNull("Event's new value should be null", event.getNewValue());
        }
    });
    model.remove(element.getProjectName());
    assertTrue("An event should be fired when removing a project model", eventFired[0]);
}
Also used : RemoveElementPropertyChangeEvent(ch.acanda.eclipse.pmd.domain.DomainModel.RemoveElementPropertyChangeEvent) AddElementPropertyChangeEvent(ch.acanda.eclipse.pmd.domain.DomainModel.AddElementPropertyChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) RemoveElementPropertyChangeEvent(ch.acanda.eclipse.pmd.domain.DomainModel.RemoveElementPropertyChangeEvent) Test(org.junit.Test)

Aggregations

AddElementPropertyChangeEvent (ch.acanda.eclipse.pmd.domain.DomainModel.AddElementPropertyChangeEvent)1 RemoveElementPropertyChangeEvent (ch.acanda.eclipse.pmd.domain.DomainModel.RemoveElementPropertyChangeEvent)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Test (org.junit.Test)1