use of org.yakindu.sct.model.sgraph.Statechart 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.Statechart 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.Statechart in project statecharts by Yakindu.
the class SCTResourceTest method testRemoveOrphanedSyntaxDiagnostics.
@Test
public void testRemoveOrphanedSyntaxDiagnostics() throws Exception {
Statechart statechart = createStatechart("invalid expression");
res.getContents().add(statechart);
assertEquals(1, res.getSyntaxDiagnostics().size());
statechart.setSpecification("internal: event Event1");
assertEquals(0, res.getSyntaxDiagnostics().size());
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class SCTUnitClassifierTest method checkEClassesCoveredByTestModels.
@Test
public void checkEClassesCoveredByTestModels() throws Exception {
Set<EClassifier> classifier = new HashSet<EClassifier>();
Iterables.addAll(classifier, SGraphPackage.eINSTANCE.getEClassifiers());
Iterables.addAll(classifier, StextPackage.eINSTANCE.getEClassifiers());
Iterables.addAll(classifier, ExpressionsPackage.eINSTANCE.getEClassifiers());
classifier = Sets.newHashSet(Iterables.filter(classifier, new Predicate<EClassifier>() {
public boolean apply(EClassifier clazz) {
if (clazz instanceof EClass) {
return !((EClass) clazz).isAbstract();
}
return false;
}
}));
// Remove classes to ignore
for (EClassifier eClassifier : IGNORE_ME) {
classifier.remove(eClassifier);
}
// Remove all classes used within SCTUnit tests
List<Statechart> allStatecharts = testModels.loadAllStatecharts();
for (Statechart statechart : allStatecharts) {
TreeIterator<EObject> eAllContents = statechart.eAllContents();
while (eAllContents.hasNext()) {
EClass eClass = eAllContents.next().eClass();
if (classifier.contains(eClass)) {
classifier.remove(eClass);
}
}
}
for (EClassifier current : classifier) {
System.out.println(current.getInstanceTypeName());
}
org.junit.Assert.assertTrue("Classifiers not covered by SCTUnit Tests: " + classifier, classifier.size() == 0);
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testBottomUpExitSequence_TwoLevels.
/**
* When exiting an orthogonal state exits must be performed in a well
* defined order bottom up with highest priority/order states first.
*/
@Test
public void testBottomUpExitSequence_TwoLevels() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
State s = _createState("s", r);
{
_createExitAssignment(v1, s, 42);
Region r2 = _createRegion("r2", s);
{
State s2 = _createState("s2", r2);
{
_createExitAssignment(v1, s2, 42);
Region r2a = _createRegion("r2a", s2);
{
_createState("s2a1", r2a);
_createState("s2a2", r2a);
}
Region r2b = _createRegion("r2b", s2);
{
_createState("s2b1", r2b);
_createState("s2b2", r2b);
}
Region r2c = _createRegion("r2c", s2);
{
_createState("s2c1", r2c);
_createState("s2c2", r2c);
}
}
}
Region r3 = _createRegion("r3", s);
{
State s3 = _createState("s3", r3);
{
_createExitAssignment(v1, s3, 42);
Region r3a = _createRegion("r3a", s3);
{
_createState("s3a1", r3a);
_createState("s3a2", r3a);
}
Region r3b = _createRegion("r3b", s3);
{
_createState("s3b1", r3b);
_createState("s3b2", r3b);
}
}
}
Region r4 = _createRegion("r4", s);
{
State s4 = _createState("s4", r4);
{
_createExitAssignment(v1, s4, 42);
Region r4a = _createRegion("r4a", s4);
{
_createState("s4a1", r4a);
_createState("s4a2", r4a);
}
Region r4b = _createRegion("r4b", s4);
{
_createState("s4b1", r4b);
_createState("s4b2", r4b);
}
}
}
}
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s = assertedState(flow, 0, "sc.r.s");
ExecutionState _s2 = assertedState(flow, 1, "sc.r.s.r2.s2");
ExecutionState _s2a1 = assertedState(flow, 2, "sc.r.s.r2.s2.r2a.s2a1");
ExecutionState _s2a2 = assertedState(flow, 3, "sc.r.s.r2.s2.r2a.s2a2");
ExecutionState _s2b1 = assertedState(flow, 4, "sc.r.s.r2.s2.r2b.s2b1");
ExecutionState _s2b2 = assertedState(flow, 5, "sc.r.s.r2.s2.r2b.s2b2");
ExecutionState _s2c1 = assertedState(flow, 6, "sc.r.s.r2.s2.r2c.s2c1");
ExecutionState _s2c2 = assertedState(flow, 7, "sc.r.s.r2.s2.r2c.s2c2");
ExecutionState _s3 = assertedState(flow, 8, "sc.r.s.r3.s3");
ExecutionState _s3a1 = assertedState(flow, 9, "sc.r.s.r3.s3.r3a.s3a1");
ExecutionState _s3a2 = assertedState(flow, 10, "sc.r.s.r3.s3.r3a.s3a2");
ExecutionState _s3b1 = assertedState(flow, 11, "sc.r.s.r3.s3.r3b.s3b1");
ExecutionState _s3b2 = assertedState(flow, 12, "sc.r.s.r3.s3.r3b.s3b2");
ExecutionState _s4 = assertedState(flow, 13, "sc.r.s.r4.s4");
ExecutionState _s4a1 = assertedState(flow, 14, "sc.r.s.r4.s4.r4a.s4a1");
ExecutionState _s4a2 = assertedState(flow, 15, "sc.r.s.r4.s4.r4a.s4a2");
ExecutionState _s4b1 = assertedState(flow, 16, "sc.r.s.r4.s4.r4b.s4b1");
ExecutionState _s4b2 = assertedState(flow, 17, "sc.r.s.r4.s4.r4b.s4b2");
// check the exit sequence of _s
Sequence _exit = _s.getExitSequence();
assertEquals("wrong steps: " + stepListAsString(_exit), 4, _exit.getSteps().size());
assertCall(_exit, 0, _s2.getSuperScope().getExitSequence());
assertCall(_exit, 1, _s3.getSuperScope().getExitSequence());
assertCall(_exit, 2, _s4.getSuperScope().getExitSequence());
StateSwitch _switch0 = assertedSwitch(_s2.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch0, _s2a1, _s2a2);
assertSequenceSize(1, assertedStateCase(_switch0, _s2a1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch0, _s2a1).getStep()), 0, _s2a1.getExitSequence());
assertSequenceSize(1, assertedStateCase(_switch0, _s2a2).getStep());
assertCall(assertedSequence(assertedStateCase(_switch0, _s2a2).getStep()), 0, _s2a2.getExitSequence());
StateSwitch _switch1 = assertedSwitch(_s2b1.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch1, _s2b1, _s2b2);
assertSequenceSize(1, assertedStateCase(_switch1, _s2b1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch1, _s2b1).getStep()), 0, _s2b1.getExitSequence());
assertSequenceSize(1, assertedStateCase(_switch1, _s2b2).getStep());
assertCall(assertedSequence(assertedStateCase(_switch1, _s2b2).getStep()), 0, _s2b2.getExitSequence());
StateSwitch _switch2 = assertedSwitch(_s2c1.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch2, _s2c1, _s2c2);
assertSequenceSize(1, assertedStateCase(_switch2, _s2c1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch2, _s2c1).getStep()), 0, _s2c1.getExitSequence());
assertSequenceSize(4, _s2.getExitSequence());
assertCall(_s2.getExitSequence(), 3, _s2.getExitAction());
assertSequenceSize(1, assertedStateCase(_switch2, _s2c2).getStep());
assertCall(assertedSequence(assertedStateCase(_switch2, _s2c2).getStep()), 0, _s2c2.getExitSequence());
StateSwitch _switch3 = assertedSwitch(_s3a1.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch3, _s3a1, _s3a2);
assertSequenceSize(1, assertedStateCase(_switch3, _s3a1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch3, _s3a1).getStep()), 0, _s3a1.getExitSequence());
assertSequenceSize(1, assertedStateCase(_switch3, _s3a2).getStep());
assertCall(assertedSequence(assertedStateCase(_switch3, _s3a2).getStep()), 0, _s3a2.getExitSequence());
StateSwitch _switch4 = assertedSwitch(_s3b1.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch4, _s3b1, _s3b2);
assertSequenceSize(1, assertedStateCase(_switch4, _s3b1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch4, _s3b1).getStep()), 0, _s3b1.getExitSequence());
assertCall(assertedSequence(assertedStateCase(_s3.getSuperScope().getExitSequence().getSteps().get(1), _s3b1).getStep()), 1, _s3.getExitAction());
assertSequenceSize(1, assertedStateCase(_switch4, _s3b2).getStep());
assertCall(assertedSequence(assertedStateCase(_switch4, _s3b2).getStep()), 0, _s3b2.getExitSequence());
assertCall(assertedSequence(assertedStateCase(_s3.getSuperScope().getExitSequence().getSteps().get(1), _s3b2).getStep()), 1, _s3.getExitAction());
StateSwitch _switch5 = assertedSwitch(_s4a1.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch5, _s4a1, _s4a2);
assertSequenceSize(1, assertedStateCase(_switch5, _s4a1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch5, _s4a1).getStep()), 0, _s4a1.getExitSequence());
assertSequenceSize(1, assertedStateCase(_switch5, _s4a2).getStep());
assertCall(assertedSequence(assertedStateCase(_switch5, _s4a2).getStep()), 0, _s4a2.getExitSequence());
StateSwitch _switch6 = assertedSwitch(_s4b1.getSuperScope().getExitSequence().getSteps().get(0));
assertStateSwitch(_switch6, _s4b1, _s4b2);
assertSequenceSize(1, assertedStateCase(_switch6, _s4b1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch6, _s4b1).getStep()), 0, _s4b1.getExitSequence());
assertCall(assertedSequence(assertedStateCase(_s4.getSuperScope().getExitSequence().getSteps().get(1), _s4b1).getStep()), 1, _s4.getExitAction());
assertSequenceSize(1, assertedStateCase(_switch6, _s4b1).getStep());
assertCall(assertedSequence(assertedStateCase(_switch6, _s4b2).getStep()), 0, _s4b2.getExitSequence());
assertCall(_s4.getExitSequence(), 2, _s4.getExitAction());
assertCall(_exit, 3, _s.getExitAction());
}
Aggregations