Search in sources :

Example 81 with Region

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

the class SGraphJavaValidationTest method choiceWithoutOutgoingTransition.

/**
 * A choice must have at least one outgoing transition
 */
@Test
public void choiceWithoutOutgoingTransition() {
    statechart = factory.createStatechart();
    Region region = factory.createRegion();
    statechart.getRegions().add(region);
    Choice choice = factory.createChoice();
    region.getVertices().add(choice);
    State state = factory.createState();
    region.getVertices().add(state);
    createTransition(state, choice);
    assertFalse(validator.validate(choice, diagnostics, new HashMap<Object, Object>()));
    assertIssueCount(diagnostics, 1);
    assertError(diagnostics, ISSUE_CHOICE_WITHOUT_OUTGOING_TRANSITION);
}
Also used : Choice(org.yakindu.sct.model.sgraph.Choice) HashMap(java.util.HashMap) FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Region(org.yakindu.sct.model.sgraph.Region) Test(org.junit.Test)

Example 82 with Region

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

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

Example 84 with Region

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

the class SGraphJavaValidationTest method vertexNotReachable_AcceptThroughSubstate.

/**
 * A transition to a sub entry is considered implies reachability.
 */
@Test
public void vertexNotReachable_AcceptThroughSubstate() {
    prepareStateTest();
    State stateA = factory.createState();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    State stateC = factory.createState();
    subRegion.getVertices().add(stateC);
    Transition t1 = factory.createTransition();
    t1.setSource(stateA);
    t1.setTarget(stateC);
    validate(state);
    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) Test(org.junit.Test)

Example 85 with Region

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

the class SGraphJavaValidationTest method exitWithoutIncomingTransition.

/**
 * An exit node should have at leat one incoming transition.
 */
@Test
public void exitWithoutIncomingTransition() {
    prepareStateTest();
    Region subRegion = factory.createRegion();
    state.getRegions().add(subRegion);
    Exit exit = factory.createExit();
    subRegion.getVertices().add(exit);
    assertFalse(validate(exit));
    assertWarning(diagnostics, ISSUE_EXIT_WITHOUT_IN_TRANS);
}
Also used : Region(org.yakindu.sct.model.sgraph.Region) Exit(org.yakindu.sct.model.sgraph.Exit) Test(org.junit.Test)

Aggregations

Region (org.yakindu.sct.model.sgraph.Region)93 Test (org.junit.Test)71 State (org.yakindu.sct.model.sgraph.State)63 Statechart (org.yakindu.sct.model.sgraph.Statechart)59 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)57 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)57 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)53 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)51 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)48 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)48 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)47 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)47 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)41 Entry (org.yakindu.sct.model.sgraph.Entry)38 Sequence (org.yakindu.sct.model.sexec.Sequence)36 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 Transition (org.yakindu.sct.model.sgraph.Transition)26 FinalState (org.yakindu.sct.model.sgraph.FinalState)25 Reaction (org.yakindu.sct.model.sexec.Reaction)22