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]);
}
Aggregations