Search in sources :

Example 1 with SCTUnitTestModels

use of org.yakindu.sct.test.models.SCTUnitTestModels in project statecharts by Yakindu.

the class SCTResourceTest method testFragments.

@Test
public void testFragments() throws Exception {
    SCTUnitTestModels models = new SCTUnitTestModels();
    List<Statechart> originalStatecharts = models.loadAllStatecharts();
    List<Statechart> targetStatecharts = models.loadAllStatecharts();
    for (int i = 0; i < originalStatecharts.size(); i++) {
        Statechart statechart = originalStatecharts.get(i);
        Statechart targetStatechart = targetStatecharts.get(i);
        Resource targetResource = targetStatechart.eResource();
        assertTrue(statechart != targetStatechart);
        assertTrue(EcoreUtil.equals(statechart, targetStatechart));
        TreeIterator<EObject> allContents = EcoreUtil.getAllContents(statechart.eResource(), true);
        while (allContents.hasNext()) {
            EObject next = allContents.next();
            String fragment = EcoreUtil.getURI(next).fragment();
            EObject targetObject = targetResource.getEObject(fragment);
            assertNotNull("Could not resolve fragment " + fragment + " for EObject " + next + "in statechart " + statechart.getName(), targetObject);
            assertTrue(EcoreUtil.equals(next, targetObject));
        }
    }
}
Also used : SCTUnitTestModels(org.yakindu.sct.test.models.SCTUnitTestModels) EObject(org.eclipse.emf.ecore.EObject) StextResource(org.yakindu.sct.model.stext.resource.StextResource) Resource(org.eclipse.emf.ecore.resource.Resource) Statechart(org.yakindu.sct.model.sgraph.Statechart) Test(org.junit.Test)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Test (org.junit.Test)1 Statechart (org.yakindu.sct.model.sgraph.Statechart)1 StextResource (org.yakindu.sct.model.stext.resource.StextResource)1 SCTUnitTestModels (org.yakindu.sct.test.models.SCTUnitTestModels)1