Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Belle2018-09-28 04:37:35 -0400
committerJan Belle2018-09-28 07:52:11 -0400
commitcb1b76052fbc2f85f4db45a3caf08cdf96b5b502 (patch)
treed7abafb363608ab8635089190d52c5977e2987de /tests
parentf8f82d046d2b781b44af7c418e1d30c12e329e5b (diff)
downloadorg.eclipse.etrice-cb1b76052fbc2f85f4db45a3caf08cdf96b5b502.tar.gz
org.eclipse.etrice-cb1b76052fbc2f85f4db45a3caf08cdf96b5b502.tar.xz
org.eclipse.etrice-cb1b76052fbc2f85f4db45a3caf08cdf96b5b502.zip
[core] Avoid repeated injector creation
* Create custom validator extensions using dependeny injection. * Add factories for generator model builders. Change-Id: I8d72e336ab981c0c218f17aca9d38688c46ac3fe
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java14
-rw-r--r--tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend10
-rw-r--r--tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java5
-rw-r--r--tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend5
4 files changed, 22 insertions, 12 deletions
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java
index eb38f62ad..9283ef249 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java
@@ -20,14 +20,14 @@ import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.abstractexec.behavior.AbstractExecutionValidator;
-import org.eclipse.etrice.abstractexec.behavior.util.AbstractExecutionUtil;
import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.abstractexec.behavior.AbstractExecutionValidator;
import org.eclipse.etrice.core.fsm.fSM.State;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
import org.eclipse.etrice.core.fsm.fSM.Transition;
import org.eclipse.etrice.core.fsm.fSM.Trigger;
+import org.eclipse.etrice.core.fsm.naming.FSMNameProvider;
import org.eclipse.xtext.validation.AbstractValidationDiagnostic;
import org.eclipse.xtext.validation.FeatureBasedDiagnostic;
import org.junit.Assert;
@@ -60,6 +60,8 @@ public class TestSemantics {
TestBase basic, cashTerminal, current = null;
+ private FSMNameProvider fsmNameProvider = new FSMNameProvider();
+
@Before
public void setUp() {
basic = new TestBase();
@@ -113,7 +115,7 @@ public class TestSemantics {
Object source = list.get(d.getIndex());
if (source instanceof StateGraphItem) {
StateGraphItem sgi = (StateGraphItem) source;
- checkItem(sgi.getName(), AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(sgi), marker);
+ checkItem(sgi.getName(), fsmNameProvider.getName(sgi), marker);
items.remove(source);
}
}
@@ -121,7 +123,7 @@ public class TestSemantics {
if (container.eContainer() instanceof Transition) {
Transition transition = (Transition) container.eContainer();
checkItem(transition.getName(),
- AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(transition),
+ fsmNameProvider.getName(transition),
marker);
items.remove(container.eContainer());
} else
@@ -129,13 +131,13 @@ public class TestSemantics {
} else if (container instanceof Transition) {
Transition transition = (Transition) container;
checkItem(transition.getName(),
- AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(transition),
+ fsmNameProvider.getName(transition),
marker);
items.remove(container);
} else if (container instanceof State) {
State state = (State) container;
checkItem(state.getName(),
- AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(state),
+ fsmNameProvider.getName(state),
marker);
items.remove(container);
} else
diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend
index 1ffd72ab8..2c5432e29 100644
--- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend
+++ b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend
@@ -19,12 +19,13 @@ import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.etrice.core.RoomStandaloneSetup
import org.eclipse.etrice.core.TestBase
-import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import org.eclipse.etrice.core.room.ActorClass
import org.eclipse.etrice.core.room.RoomModel
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder
class FsmGenTestBase extends TestBase {
@@ -32,13 +33,16 @@ class FsmGenTestBase extends TestBase {
protected ActorClass actor
protected IDiagnostician diagnostician = new NullDiagnostician
protected extension ExtendedFsmGenBuilder builder
+
+ new() {
+ val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
+ builder = injector.getInstance(ExtendedFsmGenBuilderFactory).create(diagnostician)
+ }
protected def getGraphContainer(String roomFile, String actorName) {
prepare(FSMGenModelTestsActivator.getInstance().getBundle())
res = getResource(roomFile)
actor = (res.contents.get(0) as RoomModel).actorClasses.findFirst[name.equals(actorName)]
- val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
- builder = new ExtendedFsmGenBuilder(injector, diagnostician)
builder.createTransformedModel(actor)
}
diff --git a/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java b/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java
index 68425382b..bf1422389 100644
--- a/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java
+++ b/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java
@@ -31,8 +31,10 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.RoomStandaloneSetup;
import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilder;
+import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilderFactory;
import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
@@ -74,6 +76,7 @@ public class TestInstanceModelBuilderBase {
private String basePath;
protected HashMap<EClass, ArrayList<EObject>> instances;
private RoomNameProvider roomNameProvider = new RoomNameProvider();
+ private GeneratorModelBuilderFactory genModelFactory = new RoomStandaloneSetup().createInjector().getInstance(GeneratorModelBuilderFactory.class);
protected void prepare() {
try {
@@ -102,7 +105,7 @@ public class TestInstanceModelBuilderBase {
}
protected Root buildInstanceModel(String modelName) {
- GeneratorModelBuilder builder = new GeneratorModelBuilder(new NullLogger(), new Diagnostician());
+ GeneratorModelBuilder builder = genModelFactory.create(new NullLogger(), new Diagnostician());
LinkedList<RoomModel> models = getModels(modelName);
ArrayList<RoomModel> importedModels = new ArrayList<>();
Root root = builder.createGeneratorModel(models, importedModels, false);
diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend b/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend
index 2c5b6f990..dc4c947b1 100644
--- a/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend
+++ b/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend
@@ -39,12 +39,13 @@ import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
import org.eclipse.etrice.generator.base.logging.NullLogger
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
class TestFSMGenModel extends TestBase {
val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
protected IDiagnostician diagnostician = new NullDiagnostician
- protected extension ExtendedFsmGenBuilder builder = new ExtendedFsmGenBuilder(injector, diagnostician)
+ protected extension ExtendedFsmGenBuilder builder = injector.getInstance(ExtendedFsmGenBuilderFactory).create(diagnostician)
protected def createResourceSetWithGc(String roomFile, String actorName) {
prepare(BehaviorTestActivator.^default.getBundle())
@@ -116,7 +117,7 @@ class TestFSMGenModel extends TestBase {
assertEquals(stateGraphItemsNames, namesFromGenModel)
}
- private def <T extends Comparable> toSortedSet(Iterable<T> iterable) {
+ private def <T extends Comparable<?>> toSortedSet(Iterable<T> iterable) {
Sets.<T>newTreeSet(iterable)
}

Back to the top