Search in sources :

Example 51 with Transition

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

the class SGraphJavaValidationTest method orthogonalTransition_BetweenStateRegions.

@Test
public void orthogonalTransition_BetweenStateRegions() {
    statechart = loadStatechart("OrthogonalTransition.sct");
    State state = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "B1");
    Transition trans = state.getOutgoingTransitions().get(0);
    assertFalse(validator.validate(trans, diagnostics, new HashMap<Object, Object>()));
    assertIssueCount(diagnostics, 1);
    assertError(diagnostics, ISSUE_TRANSITION_ORTHOGONAL);
}
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)

Example 52 with Transition

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

the class SGraphJavaValidationTest method initialEntryWithTransitionToContainer.

@Test
public void initialEntryWithTransitionToContainer() {
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "EntryTransitionToParentState.sct");
    Iterator<EObject> iter = statechart.eAllContents();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Transition) {
            validator.validate(element, diagnostics, new HashMap<Object, Object>());
        }
    }
    assertIssueCount(diagnostics, 1);
    assertError(diagnostics, ISSUE_INITIAL_ENTRY_WITH_TRANSITION_TO_CONTAINER);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Transition(org.yakindu.sct.model.sgraph.Transition) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 53 with Transition

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

the class SGraphJavaValidationTest method disallowTrigger.

@Test
public void disallowTrigger() {
    prepareStateTest();
    Entry entry = factory.createEntry();
    region.getVertices().add(entry);
    Transition trans = createTransition(entry, state);
    trans.setTrigger(sTextFactory.createReactionTrigger());
    diagnostics = new BasicDiagnostic();
    assertFalse(validator.validate(entry, diagnostics, new HashMap<Object, Object>()));
    assertError(diagnostics, ISSUE_ENTRY_WITH_TRIGGER);
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) HashMap(java.util.HashMap) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Transition(org.yakindu.sct.model.sgraph.Transition) Test(org.junit.Test)

Example 54 with Transition

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

the class SGraphJavaValidationTest method exitWithOutgoingTransition.

/**
 * An exit node must have no outgoing transitions.
 */
@Test
public void exitWithOutgoingTransition() {
    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.setSource(exit);
    t.setTarget(s);
    assertFalse(validate(exit));
    assertError(diagnostics, ISSUE_EXIT_WITH_OUT_TRANS);
}
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 55 with Transition

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

the class SGraphJavaValidationTest method vertexNotReachable_AcceptThroughSubentry.

/**
 * A transition to a sub entry is considered implies reachability.
 */
@Test
public void vertexNotReachable_AcceptThroughSubentry() {
    prepareStateTest();
    State stateA = factory.createState();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    State stateC = factory.createState();
    subRegion.getVertices().add(stateC);
    Entry entry = factory.createEntry();
    subRegion.getVertices().add(entry);
    Transition t1 = factory.createTransition();
    t1.setSource(stateA);
    t1.setTarget(entry);
    Transition t2 = factory.createTransition();
    t2.setSource(entry);
    t2.setTarget(stateC);
    validate(state);
    assertNoIssues(diagnostics);
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) 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)

Aggregations

Transition (org.yakindu.sct.model.sgraph.Transition)63 Test (org.junit.Test)34 Region (org.yakindu.sct.model.sgraph.Region)26 State (org.yakindu.sct.model.sgraph.State)23 Statechart (org.yakindu.sct.model.sgraph.Statechart)19 FinalState (org.yakindu.sct.model.sgraph.FinalState)13 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)13 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)13 SGraphTestFactory._createTransition (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition)13 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)13 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)10 Entry (org.yakindu.sct.model.sgraph.Entry)10 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)10 StextTestFactory._createReactionTrigger (org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger)9 EventDefinition (org.yakindu.sct.model.stext.stext.EventDefinition)8 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)8 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)8 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)7 If (org.yakindu.sct.model.sexec.If)7 Vertex (org.yakindu.sct.model.sgraph.Vertex)7