Search in sources :

Example 1 with TransientObjectImpl

use of org.eclipse.xtext.validation.csvalidationtest.impl.TransientObjectImpl in project xtext-core by eclipse.

the class ConcreteSyntaxValidationTest method testTransientObject.

@Test
public void testTransientObject() {
    TransientObject to = new TransientObjectImpl() {

        @Override
        public boolean eIsSet(int featureID) {
            switch(featureID) {
                case CsvalidationtestPackage.TRANSIENT_OBJECT__NESTED:
                    return nested != null && !"default".equals(nested.getVal2());
            }
            return super.eIsSet(featureID);
        }

        @Override
        public EList<EObject> eContents() {
            EList<EObject> r = new BasicEList<EObject>();
            if (nested != null)
                r.add(nested);
            return r;
        }
    };
    to.setNested(f.createTransientObjectSub());
    to.getNested().setVal2("default");
    validate(to).assertOK();
    to.setVal1("xxx");
    to.getNested().setVal2("something");
    to.getNested().setVal3("something");
    validate(to).assertOK();
}
Also used : TransientObjectImpl(org.eclipse.xtext.validation.csvalidationtest.impl.TransientObjectImpl) EObject(org.eclipse.emf.ecore.EObject) BasicEList(org.eclipse.emf.common.util.BasicEList) TransientObject(org.eclipse.xtext.validation.csvalidationtest.TransientObject) Test(org.junit.Test)

Aggregations

BasicEList (org.eclipse.emf.common.util.BasicEList)1 EObject (org.eclipse.emf.ecore.EObject)1 TransientObject (org.eclipse.xtext.validation.csvalidationtest.TransientObject)1 TransientObjectImpl (org.eclipse.xtext.validation.csvalidationtest.impl.TransientObjectImpl)1 Test (org.junit.Test)1