Search in sources :

Example 1 with AdapterImpl

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());
}
Also used : AdapterImpl(org.eclipse.emf.common.notify.impl.AdapterImpl) Notification(org.eclipse.emf.common.notify.Notification) Test(org.junit.Test)

Aggregations

Notification (org.eclipse.emf.common.notify.Notification)1 AdapterImpl (org.eclipse.emf.common.notify.impl.AdapterImpl)1 Test (org.junit.Test)1