Search in sources :

Example 31 with State

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

the class STextJavaValidatorTest method checkUnboundEntryPoints.

@Test
public void checkUnboundEntryPoints() {
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundDefaultEntryPoints.sct");
    Iterator<EObject> iter = statechart.eAllContents();
    // create and add triggers to all transitions to prevent to trigger
    // additional warnings
    // (see Check in SGrapJavaValidator transitionsWithNoGuard)
    Trigger trigger = StextFactoryImpl.init().createDefaultTrigger();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Transition) {
            ((Transition) element).setTrigger(trigger);
            validator.validate(element, diagnostics, new HashMap<>());
        }
        if (element instanceof State) {
            validator.validate(element, diagnostics, new HashMap<>());
        }
    }
    assertIssueCount(diagnostics, 4);
    assertError(diagnostics, TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT);
    assertError(diagnostics, REGION_UNBOUND_DEFAULT_ENTRY_POINT);
    resetDiagnostics();
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundEntryPoints02.sct");
    iter = statechart.eAllContents();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Transition) {
            ((Transition) element).setTrigger(trigger);
            validator.validate(element, diagnostics, new HashMap<>());
        }
        if (element instanceof State) {
            validator.validate(element, diagnostics, new HashMap<>());
        }
    }
    assertIssueCount(diagnostics, 4);
}
Also used : Trigger(org.yakindu.sct.model.sgraph.Trigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) State(org.yakindu.sct.model.sgraph.State) EObject(org.eclipse.emf.ecore.EObject) Transition(org.yakindu.sct.model.sgraph.Transition) Test(org.junit.Test)

Example 32 with State

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

the class SGraphJavaValidationTest method vertexNotReachable_AcceptThroughSubchoice.

/**
 * A transition to a sub choice is considered implies reachability.
 */
@Test
public void vertexNotReachable_AcceptThroughSubchoice() {
    prepareStateTest();
    State stateA = factory.createState();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    State stateC = factory.createState();
    subRegion.getVertices().add(stateC);
    Choice choice = factory.createChoice();
    subRegion.getVertices().add(choice);
    Transition t1 = factory.createTransition();
    t1.setSource(stateA);
    t1.setTarget(choice);
    Transition t2 = factory.createTransition();
    t2.setSource(choice);
    t2.setTarget(stateC);
    validate(state);
    assertNoIssues(diagnostics);
}
Also used : Choice(org.yakindu.sct.model.sgraph.Choice) FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) Test(org.junit.Test)

Example 33 with State

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

the class SGraphJavaValidationTest method synchronizationOutgoingTransitionCount.

@Test
public void synchronizationOutgoingTransitionCount() {
    statechart = loadStatechart("SyncOutgoingTransition.sct");
    State state = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "StateB");
    Synchronization sync = (Synchronization) state.getOutgoingTransitions().get(0).getTarget();
    assertFalse(validator.validate(sync, diagnostics, new HashMap<Object, Object>()));
    assertIssueCount(diagnostics, 1);
    assertError(diagnostics, ISSUE_SYNCHRONIZATION_TRANSITION_OUTGOING);
}
Also used : HashMap(java.util.HashMap) FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Example 34 with State

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

the class SGraphJavaValidationTest method cleanExit.

/**
 * Tests a scenario where no issues for an exit nodes exists.
 */
@Test
public void cleanExit() {
    prepareStateTest();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    Exit exit = factory.createExit();
    subRegion.getVertices().add(exit);
    State s = factory.createState();
    subRegion.getVertices().add(s);
    Transition t = factory.createTransition();
    t.setTarget(exit);
    t.setSource(s);
    assertTrue(validate(exit));
    assertNoIssues(diagnostics);
}
Also used : FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) Exit(org.yakindu.sct.model.sgraph.Exit) Test(org.junit.Test)

Example 35 with State

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

the class SGraphJavaValidationTest method orthogonalTransition.

@Test
public void orthogonalTransition() {
    statechart = loadStatechart("OrthogonalTransition.sct");
    State state = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "B2");
    Transition trans = state.getOutgoingTransitions().get(0);
    assertTrue(validator.validate(trans, diagnostics, new HashMap<Object, Object>()));
    assertNoIssues(diagnostics);
}
Also used : HashMap(java.util.HashMap) FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) Test(org.junit.Test)

Aggregations

State (org.yakindu.sct.model.sgraph.State)106 Test (org.junit.Test)77 Region (org.yakindu.sct.model.sgraph.Region)63 Statechart (org.yakindu.sct.model.sgraph.Statechart)59 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)51 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)51 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)50 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)46 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)46 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)46 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)46 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)39 Sequence (org.yakindu.sct.model.sexec.Sequence)36 FinalState (org.yakindu.sct.model.sgraph.FinalState)35 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)28 Transition (org.yakindu.sct.model.sgraph.Transition)23 EnterState (org.yakindu.sct.model.sexec.EnterState)21