use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SCTResourceTest method testLinkingError2.
@Test
public void testLinkingError2() throws Exception {
Statechart statechart = createStatechart("internal: event Event1");
res.getContents().add(statechart);
Transition transition = createTransition("Event1 [true] / 3 * 3");
res.getContents().add(transition);
statechart.setSpecification("internal: event Event2");
res.resolveLazyCrossReferences(CancelIndicator.NullImpl);
assertEquals(1, res.getLinkingDiagnostics().size());
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SCTResourceTest method testTransitionSerializing.
@Test
public void testTransitionSerializing() throws Exception {
res.setSerializerEnabled(true);
Transition transition = createTransition("after 10\n s [true] / 3 * 3");
res.getContents().add(transition);
ReactionTrigger trigger = (ReactionTrigger) transition.getTrigger();
TimeEventSpec timeTrigger = stextFac.createTimeEventSpec();
timeTrigger.setType(TimeEventType.EVERY);
timeTrigger.setUnit(TimeUnit.SECOND);
PrimitiveValueExpression exp = expFac.createPrimitiveValueExpression();
IntLiteral literal = expFac.createIntLiteral();
literal.setValue(42);
exp.setValue(literal);
timeTrigger.setValue(exp);
trigger.getTriggers().add(timeTrigger);
assertEquals("after 10\n s , every 42 s [true] / 3 * 3", transition.getSpecification());
assertEquals("" + res.getErrors(), 0, res.getErrors().size());
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SCTResourceTest method testLinkingError1.
@Test
public void testLinkingError1() throws Exception {
Statechart statechart = createStatechart("internal: event Event1");
res.getContents().add(statechart);
Transition transition = createTransition("Event2 [true] / 3 * 3");
res.getContents().add(transition);
res.resolveLazyCrossReferences(CancelIndicator.NullImpl);
System.out.println(res.getLinkingDiagnostics());
assertEquals(1, res.getLinkingDiagnostics().size());
}
use of org.yakindu.sct.model.sgraph.Transition 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.sgraph.Transition in project statecharts by Yakindu.
the class SCTResourceTest method createTransition.
protected Transition createTransition(String exp) {
Transition transition = SGraphFactory.eINSTANCE.createTransition();
transition.setSpecification(exp);
return transition;
}
Aggregations