use of org.yakindu.sct.model.stext.stext.RegularEventSpec in project statecharts by Yakindu.
the class STextJavaValidator method checkReactionTriggerRegularEvent.
@Check(CheckType.FAST)
public void checkReactionTriggerRegularEvent(ReactionTrigger reactionTrigger) {
for (int i = 0; i < reactionTrigger.getTriggers().size(); i++) {
EventSpec eventSpec = reactionTrigger.getTriggers().get(i);
if (eventSpec instanceof RegularEventSpec) {
EObject element = unwrap(((RegularEventSpec) eventSpec).getEvent());
if (element != null && (!(element instanceof Event))) {
String elementName = "";
if (element instanceof NamedElement) {
elementName = "'" + ((NamedElement) element).getName() + "' ";
}
error("Trigger " + elementName + "is no event.", StextPackage.Literals.REACTION_TRIGGER__TRIGGERS, i, TRIGGER_IS_NO_EVENT);
}
}
}
}
use of org.yakindu.sct.model.stext.stext.RegularEventSpec 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.RegularEventSpec in project statecharts by Yakindu.
the class SCTResourceTest method testParsingOnLoad.
@Test
public void testParsingOnLoad() throws Exception {
File tmpFile = File.createTempFile("SCTResource", "test.test");
tmpFile.deleteOnExit();
URI uri = URI.createFileURI(tmpFile.getPath().toString());
Resource resource = new XMIResourceImpl(uri);
Statechart statechart = createStatechart("internal: event Event1");
resource.getContents().add(statechart);
Transition transition = createTransition("Event1 [true] / 3 * 3");
resource.getContents().add(transition);
resource.save(Collections.EMPTY_MAP);
res.setURI(uri);
res.load(Collections.EMPTY_MAP);
statechart = (Statechart) res.getContents().get(0);
transition = (Transition) res.getContents().get(1);
assertEquals("" + res.getErrors(), 0, res.getErrors().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.RegularEventSpec in project statecharts by Yakindu.
the class StextTestFactory method _createRegularEventSpec.
public static RegularEventSpec _createRegularEventSpec(EventDefinition e1, ReactionTrigger rt) {
RegularEventSpec e1Spec = StextFactory.eINSTANCE.createRegularEventSpec();
e1Spec.setEvent(_createElementReferenceExpression(e1));
if (rt != null)
rt.getTriggers().add(e1Spec);
return e1Spec;
}
Aggregations