File tree Expand file tree Collapse file tree 3 files changed +20
-15
lines changed
mps-model-adapters-plugin/src/test/kotlin/org/modelix/model/mpsadapters Expand file tree Collapse file tree 3 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,11 @@ class ChangePropertyTest : MpsAdaptersTestBase("SimpleProject") {
2828
2929 val repositoryNode: INode = MPSRepositoryAsNode (mpsProject.repository)
3030
31- writeActionOnEdt {
31+ runCommandOnEDT {
3232 val module = repositoryNode.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Repository .modules)
3333 .single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1" }
34- val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models).single()
34+ val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models)
35+ .single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1.model1" }
3536 val rootNode = model.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Model .rootNodes).single()
3637 assertEquals(" Class1" , rootNode.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name))
3738 rootNode.setPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name, " MyRenamedClass" )
Original file line number Diff line number Diff line change @@ -97,18 +97,18 @@ abstract class MpsAdaptersTestBase(val testDataName: String?) : UsefulTestCase()
9797 return checkNotNull(ProjectHelper .fromIdeaProject(project)) { " MPS project not loaded" }
9898 }
9999
100- protected fun <R > writeAction (body : () -> R ): R {
101- return mpsProject.modelAccess.computeWriteAction(body)
102- }
103-
104- protected fun <R > writeActionOnEdt (body : () -> R ): R {
105- return onEdt { writeAction { body() } }
106- }
107-
108- protected fun <R > onEdt (body : () -> R ): R {
100+ protected fun <R > runCommandOnEDT (body : () -> R ): R {
109101 var result: R ? = null
110- ThreadUtils .runInUIThreadAndWait {
111- result = body()
102+ val exception = ThreadUtils .runInUIThreadAndWait {
103+ mpsProject.modelAccess.executeCommand {
104+ result = body()
105+ }
106+ }
107+ if (exception != null ) {
108+ throw exception
109+ }
110+ checkNotNull(result) {
111+ " The result was null even those no exception was thrown."
112112 }
113113 return result as R
114114 }
Original file line number Diff line number Diff line change 1616
1717package org.modelix.model.mpsadapters
1818
19+ import org.junit.Ignore
1920import org.modelix.model.api.BuiltinLanguages
2021import org.modelix.model.api.ConceptReference
2122import org.modelix.model.api.INode
2223import org.modelix.model.api.IReplaceableNode
2324
25+ @Ignore(" Replacing a node through MPS-model-adapters is broken. See MODELIX-920" )
2426class ReplaceNodeTest : MpsAdaptersTestBase (" SimpleProject" ) {
2527
2628 fun testReplaceNode () {
@@ -30,10 +32,12 @@ class ReplaceNodeTest : MpsAdaptersTestBase("SimpleProject") {
3032
3133 val repositoryNode: INode = MPSRepositoryAsNode (mpsProject.repository)
3234
33- writeActionOnEdt {
35+ runCommandOnEDT {
3436 val module = repositoryNode.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Repository .modules)
3537 .single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1" }
36- val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models).single()
38+ val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models)
39+ .single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1.model1" }
40+
3741 val rootNode = model.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Model .rootNodes).single() as IReplaceableNode
3842
3943 val oldProperties = rootNode.getAllProperties().toSet()
You can’t perform that action at this time.
0 commit comments