Search in sources :

Example 11 with Synchronization

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

the class TransitionsWithNoTriggerTest method noTriggerOnSyncIncoming.

/**
 * If a sync node has multiple incoming transitions then the transitions can omit the trigger.
 */
@Test
public void noTriggerOnSyncIncoming() {
    statechart = loadStatechart("ValidEmptyTransitionFromSync.sct");
    Region validRegion = firstNamed(eAllOfType(statechart, Region.class), "valid");
    Synchronization sync = eAllOfType(validRegion, Synchronization.class).get(0);
    for (Transition t : sync.getIncomingTransitions()) {
        assertTrue(validate(t));
        assertIssueCount(diagnostics, 0);
    }
}
Also used : Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Example 12 with Synchronization

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

the class SGraphJavaValidationTest method orthogonalTargetStates_StateInTopLevelRegion.

@Test
public void orthogonalTargetStates_StateInTopLevelRegion() {
    statechart = loadStatechart("NotOrthogonalRegion02.sct");
    State b = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "B");
    Synchronization sync = (Synchronization) b.getOutgoingTransitions().get(0).getTarget();
    assertFalse(validator.validate(sync, diagnostics, new HashMap<Object, Object>()));
    assertIssueCount(diagnostics, 1);
    assertError(diagnostics, ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_ORTHOGONAL);
}
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 13 with Synchronization

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

the class SGraphJavaValidationTest method synchronizationTransitionCount.

@Test
public void synchronizationTransitionCount() {
    statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "SynchronizationTransitionCount.sct");
    Iterator<EObject> iter = statechart.eAllContents();
    while (iter.hasNext()) {
        EObject element = iter.next();
        if (element instanceof Synchronization) {
            assertFalse(validator.validate(element, diagnostics, new HashMap<Object, Object>()));
        }
    }
    assertIssueCount(diagnostics, 2);
    assertError(diagnostics, ISSUE_SYNCHRONIZATION_TRANSITION_COUNT);
}
Also used : HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Example 14 with Synchronization

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

the class SGraphJavaValidationTest method orthogonalSourceStates.

@Test
public void orthogonalSourceStates() {
    statechart = loadStatechart("OrthogonalRegion01.sct");
    State b = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "AA");
    Synchronization sync = (Synchronization) b.getOutgoingTransitions().get(0).getTarget();
    assertTrue(validator.validate(sync, 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) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Example 15 with Synchronization

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

the class SGraphJavaValidationTest method syncLocation_Issue58.

@Test
public void syncLocation_Issue58() {
    statechart = loadStatechart("SyncLocation_Issue58.sct");
    State state = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "AA");
    Synchronization sync = (Synchronization) state.getOutgoingTransitions().get(0).getTarget();
    assertTrue(validator.validate(sync, 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) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Aggregations

Synchronization (org.yakindu.sct.model.sgraph.Synchronization)16 Test (org.junit.Test)14 HashMap (java.util.HashMap)11 FinalState (org.yakindu.sct.model.sgraph.FinalState)10 State (org.yakindu.sct.model.sgraph.State)10 Region (org.yakindu.sct.model.sgraph.Region)4 EObject (org.eclipse.emf.ecore.EObject)2 Transition (org.yakindu.sct.model.sgraph.Transition)2 LinkedList (java.util.LinkedList)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 Check (org.eclipse.xtext.validation.Check)1 CompositeElement (org.yakindu.sct.model.sgraph.CompositeElement)1 Vertex (org.yakindu.sct.model.sgraph.Vertex)1