Search in sources :

Example 81 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class SCTResourceTest method createStatechart.

protected Statechart createStatechart(String exp) {
    Statechart statechart = SGraphFactory.eINSTANCE.createStatechart();
    statechart.setSpecification(exp);
    return statechart;
}
Also used : Statechart(org.yakindu.sct.model.sgraph.Statechart)

Example 82 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class SCTResourceTest method testStatechartParsing.

@Test
public void testStatechartParsing() {
    Statechart statechart = createStatechart("internal: event Event1");
    assertEquals(0, statechart.getScopes().size());
    res.getContents().add(statechart);
    assertEquals(1, statechart.getScopes().size());
    Scope scope = statechart.getScopes().get(0);
    assertTrue(scope instanceof InternalScope);
    EList<Declaration> declarations = ((InternalScope) scope).getDeclarations();
    Declaration declaration = declarations.get(0);
    assertTrue(declaration instanceof EventDefinition);
    assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Declaration(org.yakindu.base.types.Declaration) EventDefinition(org.yakindu.sct.model.stext.stext.EventDefinition) Test(org.junit.Test)

Example 83 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class SCTResourceTest method testStatechartSerializing1.

@Test
public void testStatechartSerializing1() throws Exception {
    res.setSerializerEnabled(true);
    Statechart statechart = createStatechart("internal: event Event1");
    res.getContents().add(statechart);
    Scope internalScope = (InternalScope) statechart.getScopes().get(0);
    Event event = internalScope.getEvents().get(0);
    event.setName("Event2");
    assertEquals("internal: event Event2", statechart.getSpecification().trim());
    assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Event(org.yakindu.base.types.Event) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent) Test(org.junit.Test)

Example 84 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.

the class SCTResourceTest method testLinkingError2.

@Test
public void testLinkingError2() throws Exception {
    Statechart statechart = createStatechart("internal: event Event1");
    res.getContents().add(statechart);
    Transition transition = createTransition("Event1 [true] / 3 * 3");
    res.getContents().add(transition);
    statechart.setSpecification("internal: event Event2");
    res.resolveLazyCrossReferences(CancelIndicator.NullImpl);
    assertEquals(1, res.getLinkingDiagnostics().size());
}
Also used : Transition(org.yakindu.sct.model.sgraph.Transition) Statechart(org.yakindu.sct.model.sgraph.Statechart) Test(org.junit.Test)

Example 85 with Statechart

use of org.yakindu.sct.model.sgraph.Statechart 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

Statechart (org.yakindu.sct.model.sgraph.Statechart)132 Test (org.junit.Test)89 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)65 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)63 Region (org.yakindu.sct.model.sgraph.Region)59 State (org.yakindu.sct.model.sgraph.State)59 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)57 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)57 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)48 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)48 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)47 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)47 Sequence (org.yakindu.sct.model.sexec.Sequence)40 Entry (org.yakindu.sct.model.sgraph.Entry)30 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 Reaction (org.yakindu.sct.model.sexec.Reaction)25 Scope (org.yakindu.sct.model.sgraph.Scope)25 EnterState (org.yakindu.sct.model.sexec.EnterState)21