|
@@ -13,10 +13,13 @@ package org.yakindu.sct.refactoring.refactor;
|
|
|
import static org.junit.Assert.fail;
|
|
import static org.junit.Assert.fail;
|
|
|
import static org.yakindu.sct.test.models.RefactoringTestModels.INITIAL_STATECHART;
|
|
import static org.yakindu.sct.test.models.RefactoringTestModels.INITIAL_STATECHART;
|
|
|
import static org.yakindu.sct.test.models.RefactoringTestModels.RENAMING;
|
|
import static org.yakindu.sct.test.models.RefactoringTestModels.RENAMING;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
import junit.framework.Assert;
|
|
import junit.framework.Assert;
|
|
|
|
|
|
|
|
import org.eclipse.emf.common.util.EList;
|
|
import org.eclipse.emf.common.util.EList;
|
|
|
-import org.eclipse.emf.ecore.util.EcoreUtil;
|
|
|
|
|
|
|
+import org.eclipse.xtext.EcoreUtil2;
|
|
|
import org.eclipse.xtext.junit4.InjectWith;
|
|
import org.eclipse.xtext.junit4.InjectWith;
|
|
|
import org.eclipse.xtext.junit4.XtextRunner;
|
|
import org.eclipse.xtext.junit4.XtextRunner;
|
|
|
import org.eclipse.xtext.parser.IParser;
|
|
import org.eclipse.xtext.parser.IParser;
|
|
@@ -24,11 +27,14 @@ import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
|
import org.yakindu.sct.model.sgraph.Event;
|
|
import org.yakindu.sct.model.sgraph.Event;
|
|
|
import org.yakindu.sct.model.sgraph.Scope;
|
|
import org.yakindu.sct.model.sgraph.Scope;
|
|
|
|
|
+import org.yakindu.sct.model.sgraph.SpecificationElement;
|
|
|
import org.yakindu.sct.model.sgraph.Statechart;
|
|
import org.yakindu.sct.model.sgraph.Statechart;
|
|
|
import org.yakindu.sct.model.sgraph.Variable;
|
|
import org.yakindu.sct.model.sgraph.Variable;
|
|
|
import org.yakindu.sct.model.sgraph.resource.AbstractSCTResource;
|
|
import org.yakindu.sct.model.sgraph.resource.AbstractSCTResource;
|
|
|
|
|
+import org.yakindu.sct.model.stext.resource.impl.StextResource;
|
|
|
import org.yakindu.sct.model.stext.stext.InterfaceScope;
|
|
import org.yakindu.sct.model.stext.stext.InterfaceScope;
|
|
|
import org.yakindu.sct.refactoring.refactor.impl.RenameRefactoring;
|
|
import org.yakindu.sct.refactoring.refactor.impl.RenameRefactoring;
|
|
|
|
|
+import org.yakindu.sct.refactoring.refactor.util.SctEqualityHelper;
|
|
|
import org.yakindu.sct.refactoring.refactor.util.TestHelper;
|
|
import org.yakindu.sct.refactoring.refactor.util.TestHelper;
|
|
|
import org.yakindu.sct.refactoring.refactor.util.TestInjectorProvider;
|
|
import org.yakindu.sct.refactoring.refactor.util.TestInjectorProvider;
|
|
|
import org.yakindu.sct.test.models.RefactoringTestModels;
|
|
import org.yakindu.sct.test.models.RefactoringTestModels;
|
|
@@ -54,7 +60,8 @@ public class RenameRefactoringTest {
|
|
|
protected TestHelper helper = new TestHelper();
|
|
protected TestHelper helper = new TestHelper();
|
|
|
|
|
|
|
|
protected void compareStatecharts(Statechart initial, Statechart expected) {
|
|
protected void compareStatecharts(Statechart initial, Statechart expected) {
|
|
|
- if (!EcoreUtil.equals(initial, expected)) {
|
|
|
|
|
|
|
+ SctEqualityHelper equalityHelper = new SctEqualityHelper();
|
|
|
|
|
+ if (!equalityHelper.equals(initial, expected)) {
|
|
|
Assert.fail("Equality check on statecharts failed!");
|
|
Assert.fail("Equality check on statecharts failed!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -84,6 +91,9 @@ public class RenameRefactoringTest {
|
|
|
Statechart expected = models.loadStatechartFromResource(RENAMING
|
|
Statechart expected = models.loadStatechartFromResource(RENAMING
|
|
|
+ "AfterRenamingVariable.sct");
|
|
+ "AfterRenamingVariable.sct");
|
|
|
|
|
|
|
|
|
|
+ parseAllSpecifications(initial);
|
|
|
|
|
+ parseAllSpecifications(expected);
|
|
|
|
|
+
|
|
|
compareStatecharts(initial, expected);
|
|
compareStatecharts(initial, expected);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -116,6 +126,9 @@ public class RenameRefactoringTest {
|
|
|
Statechart expected = models.loadStatechartFromResource(RENAMING
|
|
Statechart expected = models.loadStatechartFromResource(RENAMING
|
|
|
+ "AfterRenamingEvent.sct");
|
|
+ "AfterRenamingEvent.sct");
|
|
|
|
|
|
|
|
|
|
+ parseAllSpecifications(initial);
|
|
|
|
|
+ parseAllSpecifications(expected);
|
|
|
|
|
+
|
|
|
compareStatecharts(initial, expected);
|
|
compareStatecharts(initial, expected);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -143,6 +156,9 @@ public class RenameRefactoringTest {
|
|
|
Statechart expected = models.loadStatechartFromResource(RENAMING
|
|
Statechart expected = models.loadStatechartFromResource(RENAMING
|
|
|
+ "AfterRenamingInterface.sct");
|
|
+ "AfterRenamingInterface.sct");
|
|
|
|
|
|
|
|
|
|
+ parseAllSpecifications(initial);
|
|
|
|
|
+ parseAllSpecifications(expected);
|
|
|
|
|
+
|
|
|
compareStatecharts(initial, expected);
|
|
compareStatecharts(initial, expected);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -150,5 +166,12 @@ public class RenameRefactoringTest {
|
|
|
public void testNoRenamingIntoExistingName() {
|
|
public void testNoRenamingIntoExistingName() {
|
|
|
fail("Not yet implemented.");
|
|
fail("Not yet implemented.");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private void parseAllSpecifications(Statechart sct) {
|
|
|
|
|
+ List<SpecificationElement> allSpecElements = EcoreUtil2.getAllContentsOfType(sct, SpecificationElement.class);
|
|
|
|
|
+ for (SpecificationElement specificationElement : allSpecElements) {
|
|
|
|
|
+ ((StextResource)sct.eResource()).parseSpecificationElement(specificationElement);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|