use of org.eclipse.emf.common.notify.impl.AdapterImpl in project xtext-core by eclipse.
the class DerivedStateAwareResourceTest method testInitialization.
@Test
public void testInitialization() throws Exception {
TestedResource resource = new TestedResource();
assertTrue(resource.getContents().isEmpty());
resource.setDerivedStateComputer(new IDerivedStateComputer() {
@Override
public void installDerivedState(DerivedStateAwareResource resource, boolean resolve) {
fail("shouldn't be called after initialization");
}
@Override
public void discardDerivedState(DerivedStateAwareResource resource) {
fail("shouldn't be called after initialization");
}
});
resource.getContents();
resource.setIsLoaded();
resource.eAdapters().add(new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
fail("notification received");
super.notifyChanged(msg);
}
});
resource.setDerivedStateComputer(new IDerivedStateComputer() {
@Override
public void installDerivedState(DerivedStateAwareResource resource, boolean resolve) {
resource.getContents().add(EcoreFactory.eINSTANCE.createEObject());
}
@Override
public void discardDerivedState(DerivedStateAwareResource resource) {
resource.getContents().clear();
}
});
assertEquals(1, resource.getContents().size());
}
Aggregations