use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class SCTResourceTest method createStatechart.
protected Statechart createStatechart(String exp) {
Statechart statechart = SGraphFactory.eINSTANCE.createStatechart();
statechart.setSpecification(exp);
return statechart;
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class SCTResourceTest method testStatechartParsing.
@Test
public void testStatechartParsing() {
Statechart statechart = createStatechart("internal: event Event1");
assertEquals(0, statechart.getScopes().size());
res.getContents().add(statechart);
assertEquals(1, statechart.getScopes().size());
Scope scope = statechart.getScopes().get(0);
assertTrue(scope instanceof InternalScope);
EList<Declaration> declarations = ((InternalScope) scope).getDeclarations();
Declaration declaration = declarations.get(0);
assertTrue(declaration instanceof EventDefinition);
assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class SCTResourceTest method testStatechartSerializing1.
@Test
public void testStatechartSerializing1() throws Exception {
res.setSerializerEnabled(true);
Statechart statechart = createStatechart("internal: event Event1");
res.getContents().add(statechart);
Scope internalScope = (InternalScope) statechart.getScopes().get(0);
Event event = internalScope.getEvents().get(0);
event.setName("Event2");
assertEquals("internal: event Event2", statechart.getSpecification().trim());
assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
use of org.yakindu.sct.model.sgraph.Statechart 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.Statechart in project statecharts by Yakindu.
the class SCTResourceTest method testFragments.
@Test
public void testFragments() throws Exception {
SCTUnitTestModels models = new SCTUnitTestModels();
List<Statechart> originalStatecharts = models.loadAllStatecharts();
List<Statechart> targetStatecharts = models.loadAllStatecharts();
for (int i = 0; i < originalStatecharts.size(); i++) {
Statechart statechart = originalStatecharts.get(i);
Statechart targetStatechart = targetStatecharts.get(i);
Resource targetResource = targetStatechart.eResource();
assertTrue(statechart != targetStatechart);
assertTrue(EcoreUtil.equals(statechart, targetStatechart));
TreeIterator<EObject> allContents = EcoreUtil.getAllContents(statechart.eResource(), true);
while (allContents.hasNext()) {
EObject next = allContents.next();
String fragment = EcoreUtil.getURI(next).fragment();
EObject targetObject = targetResource.getEObject(fragment);
assertNotNull("Could not resolve fragment " + fragment + " for EObject " + next + "in statechart " + statechart.getName(), targetObject);
assertTrue(EcoreUtil.equals(next, targetObject));
}
}
}
Aggregations