use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method createEntryBlock.
private EList<Expression> createEntryBlock(List<Expression> actionsToAdd) {
EList<Expression> actionsOriginal;
LocalReaction newLocalReaction = StextFactory.eINSTANCE.createLocalReaction();
ReactionTrigger newReactionTrigger = StextFactory.eINSTANCE.createReactionTrigger();
EntryEvent entryEvent = StextFactory.eINSTANCE.createEntryEvent();
ReactionEffect newReactionEffect = StextFactory.eINSTANCE.createReactionEffect();
newLocalReaction.setTrigger(newReactionTrigger);
newReactionTrigger.getTriggers().add(entryEvent);
newReactionEffect.getActions().addAll(actionsToAdd);
newLocalReaction.setEffect(newReactionEffect);
Scope scope = getContextObject().getScopes().get(0);
scope.getReactions().add(newLocalReaction);
actionsOriginal = newReactionEffect.getActions();
return actionsOriginal;
}
use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.
the class SCTResourceTest method testLinkingSuccess.
@Test
public void testLinkingSuccess() throws Exception {
Statechart statechart = createStatechart("internal: event Event1");
res.getContents().add(statechart);
Transition transition = createTransition("Event1 [true] / 3 * 3");
res.getContents().add(transition);
res.resolveLazyCrossReferences(CancelIndicator.NullImpl);
assertEquals("" + res.getLinkingDiagnostics(), 0, res.getLinkingDiagnostics().size());
ReactionTrigger trigger = (ReactionTrigger) transition.getTrigger();
RegularEventSpec eventSpec = (RegularEventSpec) trigger.getTriggers().get(0);
ElementReferenceExpression expression = (ElementReferenceExpression) eventSpec.getEvent();
EventDefinition reference = (EventDefinition) expression.getReference();
assertNotNull(reference);
assertEquals("Event1", reference.getName());
}
use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.
the class SCTResourceTest method testStateSerializing.
@Test
public void testStateSerializing() throws Exception {
res.setSerializerEnabled(true);
State state = createState("entry / 3 * 3");
res.getContents().add(state);
LocalReaction reaction = (LocalReaction) state.getLocalReactions().get(0);
ReactionTrigger trigger = (ReactionTrigger) reaction.getTrigger();
ExitEvent exitEvent = stextFac.createExitEvent();
trigger.getTriggers().add(exitEvent);
assertEquals("entry , exit / 3 * 3", state.getSpecification());
assertEquals("" + res.getErrors(), 0, res.getErrors().size());
}
use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.
the class ModelSequencerStateReactionTest method testAlwaysTriggerCondition.
/**
* The 'always' trigger event will be converted to a simple 'true'
* condition.
*/
@Test
public void testAlwaysTriggerCondition() {
ReactionTrigger tr1 = _createReactionTrigger(null);
_createAlwaysEventSpec(tr1);
Expression s = behaviorMapping.buildCondition(tr1);
assertNotNull(s);
assertTrue(s instanceof PrimitiveValueExpression);
assertBoolLiteral(true, ((PrimitiveValueExpression) s).getValue());
}
use of org.yakindu.sct.model.stext.stext.ReactionTrigger in project statecharts by Yakindu.
the class ModelSequencerStateReactionTest method testSingleRegularEventTriggerCondition.
/**
* Single trigger events of a Reaction Trigger will be converted into a
* single condition that consists of a ElementReferenceExpression to the
* corresponding event definition.
*/
@Test
public void testSingleRegularEventTriggerCondition() {
EventDefinition e1 = _createEventDefinition("e1", null);
ReactionTrigger tr1 = _createReactionTrigger(null);
_createRegularEventSpec(e1, tr1);
Expression s = behaviorMapping.buildCondition(tr1);
assertClass(ElementReferenceExpression.class, s);
}
Aggregations