use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class ModelSequencerStateReactionTest method testTransitionCheckSequenceWithoutTrigger.
@Test
public void testTransitionCheckSequenceWithoutTrigger() {
ReactionTrigger tr1 = _createReactionTrigger(null);
PrimitiveValueExpression exp = _createValue(false);
tr1.setGuard(createGuardExpression(exp));
Transition t = SGraphFactory.eINSTANCE.createTransition();
t.setTrigger(tr1);
Statechart sc = _createStatechart("test");
Region region = _createRegion("r1", sc);
t.setSource(_createState("A", region));
t.setTarget(_createState("B", region));
Reaction reaction = behaviorMapping.mapTransition(t);
// now check the expression structure ...
// the root is an and condition with the trigger check as the first
// (left) part and the guard as the right (second) part.
PrimitiveValueExpression guard = (PrimitiveValueExpression) reaction.getCheck().getCondition();
assertBoolLiteral(false, guard.getValue());
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class ModelSequencerStateTest method testFinalStateEnterSequenceCall.
/**
* The enter sequence must be called withnin incoming transitions.
*/
@SuppressWarnings("unused")
@Test
public void testFinalStateEnterSequenceCall() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
EventDefinition e1 = _createEventDefinition("e1", s_scope);
Region r = _createRegion("r", sc);
{
State s1 = _createState("s1", r);
FinalState fs = _createFinalState(r);
Transition t_s1_fs = _createTransition(s1, fs);
_createReactionTrigger(t_s1_fs);
_createRegularEventSpec(e1, (ReactionTrigger) t_s1_fs.getTrigger());
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s1 = flow.getStates().get(0);
assertEquals("sc.r.s1", _s1.getName());
ExecutionState _fs = flow.getStates().get(1);
assertEquals("sc.r._final_", _fs.getName());
assertNull(_fs.getEntryAction());
assertNull(_fs.getExitAction());
// the transition s1 -> fs must includes the fs exit sequence call
Sequence cycle = _s1.getReactSequence();
If _if = (If) SCTTestUtil.flattenSequenceStepsAsList(cycle).get(0);
assertCall(_if.getThenStep(), _s1.getReactions().get(0).getEffect());
Sequence _seq = (Sequence) _s1.getReactions().get(0).getEffect();
assertCall(_seq, 1, _fs.getEnterSequences().get(0));
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class AbstractSTextValidationTest method createTransition.
protected Transition createTransition(Vertex source, Vertex target) {
Transition trans = SGraphFactory.eINSTANCE.createTransition();
trans.setSource(source);
trans.setTarget(target);
source.getOutgoingTransitions().add(trans);
target.getIncomingTransitions().add(trans);
return trans;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class TransitionsWithNoTriggerTest method noTriggerOnSyncOutgoing.
/**
* The outgoing transitions of a sync (fork / join) node must not have any
* trigger part. Thus empty transitions must not have any warning. This test
* case addresses a bug #75 (
* https://code.google.com/a/eclipselabs.org/p/yakindu/issues/detail?id=75 )
* .
*/
@Test
public void noTriggerOnSyncOutgoing() {
statechart = loadStatechart("ValidEmptyTransitionFromSync.sct");
Region validRegion = firstNamed(eAllOfType(statechart, Region.class), "valid");
Synchronization sync = eAllOfType(validRegion, Synchronization.class).get(0);
for (Transition t : sync.getOutgoingTransitions()) {
assertTrue(validate(t));
assertIssueCount(diagnostics, 0);
}
}
use of org.yakindu.sct.model.sgraph.Transition 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);
}
Aggregations