Search in sources :

Example 1 with EcoreAdapterFactory

use of org.eclipse.emf.ecore.util.EcoreAdapterFactory in project xtext-core by eclipse.

the class CompositeNodeTest method testIsAdapterForType.

@Test
public void testIsAdapterForType() {
    EObject object = EcoreFactory.eINSTANCE.createEObject();
    CompositeNodeWithSemanticElement node = createCompositeNode();
    object.eAdapters().add(node);
    AdapterFactory adapterFactory = new EcoreAdapterFactory();
    Adapter adapter = adapterFactory.adapt(object, INode.class);
    assertSame(node, adapter);
    // the following line may not throw a ClassCastException
    Adapter secondAdapter = adapterFactory.adapt(object, new Object());
    assertNull(secondAdapter);
}
Also used : AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) EcoreAdapterFactory(org.eclipse.emf.ecore.util.EcoreAdapterFactory) EObject(org.eclipse.emf.ecore.EObject) Adapter(org.eclipse.emf.common.notify.Adapter) EObject(org.eclipse.emf.ecore.EObject) EcoreAdapterFactory(org.eclipse.emf.ecore.util.EcoreAdapterFactory) Test(org.junit.Test)

Aggregations

Adapter (org.eclipse.emf.common.notify.Adapter)1 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreAdapterFactory (org.eclipse.emf.ecore.util.EcoreAdapterFactory)1 Test (org.junit.Test)1