Search in sources :

Example 41 with Entry

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

the class SGraphJavaValidationTest method regionCantBeEnteredUsingShallowHistory.

@Test
public void regionCantBeEnteredUsingShallowHistory() {
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "RegionCantBeEnteredUsingShallowHistory.sct");
    Iterator<EObject> iter = statechart.eAllContents();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Entry) {
            validator.validate(element, diagnostics, new HashMap<Object, Object>());
        }
    }
    assertIssueCount(diagnostics, 2);
    Diagnostic issue = issueByName(diagnostics, ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY);
    assertTrue(issue.getSeverity() == Diagnostic.ERROR);
    assertEquals("r_a", ((NamedElement) issue.getData().get(0)).getName());
    issue = issueByName(diagnostics, ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY);
    assertTrue(issue.getSeverity() == Diagnostic.ERROR);
    assertEquals("r_c", ((NamedElement) issue.getData().get(0)).getName());
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) EObject(org.eclipse.emf.ecore.EObject) BasicDiagnostic(org.eclipse.emf.common.util.BasicDiagnostic) Diagnostic(org.eclipse.emf.common.util.Diagnostic) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 42 with Entry

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

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

the class SGraphJavaValidationTest method initialEntryWithoutOutgoingTransition.

/**
 * An initial entry should have an outgoing transition
 */
@Test
public void initialEntryWithoutOutgoingTransition() {
    prepareStateTest();
    Entry entry = factory.createEntry();
    region.getVertices().add(entry);
    assertEquals(EntryKind.INITIAL, entry.getKind());
    validator.validate(entry, diagnostics, new HashMap<Object, Object>());
    assertWarning(diagnostics, ISSUE_INITIAL_ENTRY_WITHOUT_OUT_TRANS);
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 44 with Entry

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

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

the class SGraphTestFactory method _createEntry.

public static Entry _createEntry(EntryKind kind, String name, Region r) {
    Entry entry = SGraphFactory.eINSTANCE.createEntry();
    if (kind != null)
        entry.setKind(kind);
    else
        entry.setKind(EntryKind.INITIAL);
    entry.setName(name);
    if (r != null)
        r.getVertices().add(entry);
    return entry;
}
Also used : Entry(org.yakindu.sct.model.sgraph.Entry)

Aggregations

Entry (org.yakindu.sct.model.sgraph.Entry)47 Test (org.junit.Test)38 Region (org.yakindu.sct.model.sgraph.Region)38 State (org.yakindu.sct.model.sgraph.State)30 Statechart (org.yakindu.sct.model.sgraph.Statechart)30 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)29 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)29 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)29 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)29 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)28 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)27 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)27 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)26 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)25 Sequence (org.yakindu.sct.model.sexec.Sequence)22 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)22 EnterState (org.yakindu.sct.model.sexec.EnterState)13 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)13 Reaction (org.yakindu.sct.model.sexec.Reaction)10 Transition (org.yakindu.sct.model.sgraph.Transition)10