use of ch.acanda.eclipse.pmd.domain.DomainModel.AddElementPropertyChangeEvent in project eclipse-pmd by acanda.
the class WorkspaceModelTest method addFiresAnAddElementPropertyChangeEvent.
/**
* Verifies that an event is fired when adding a project model.
*/
@Test
public void addFiresAnAddElementPropertyChangeEvent() {
final WorkspaceModel model = new WorkspaceModel();
final boolean[] eventFired = new boolean[1];
final ProjectModel element = new ProjectModel("Foo");
model.addPropertyChangeListener(WorkspaceModel.PROJECTS_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
eventFired[0] = true;
assertTrue("The event should be an AddElementPropertyChangeEvent", event instanceof AddElementPropertyChangeEvent);
assertSame("Event's added element", element, ((AddElementPropertyChangeEvent) event).getAddedElement());
assertNull("Event's old value should be null", event.getOldValue());
assertSame("Event's new value should be the added element", element, event.getNewValue());
}
});
model.add(element);
assertTrue("An event should be fired when adding a project model", eventFired[0]);
}
Aggregations