Skip to content

Commit 36daf93

Browse files
committed
test(bulk-model-sync-gradle): add test for add children
1 parent d1cac5c commit 36daf93

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

bulk-model-sync-gradle-test/src/test/kotlin/org/modelix/model/sync/bulk/gradle/test/ChangeApplier.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.modelix.model.sync.bulk.gradle.test
1818

19+
import GraphLang.C_Node
1920
import GraphLang.L_GraphLang
2021
import GraphLang.N_Edge
2122
import GraphLang.N_Graph
@@ -27,6 +28,7 @@ import jetbrains.mps.lang.core.L_jetbrains_mps_lang_core
2728
import kotlinx.coroutines.runBlocking
2829
import org.modelix.metamodel.TypedLanguagesRegistry
2930
import org.modelix.metamodel.typed
31+
import org.modelix.metamodel.untyped
3032
import org.modelix.model.ModelFacade
3133
import org.modelix.model.api.BuiltinLanguages
3234
import org.modelix.model.api.ConceptReference
@@ -63,6 +65,11 @@ class ChangeApplier {
6365
graphNodes[1].name = "Y"
6466
graphNodes[2].name = "Z"
6567

68+
val graph = graphNodes[0].untyped().parent?.typed<N_Graph>() ?: error("parent not found")
69+
graph.nodes.addNew(3, C_Node).apply {
70+
name = "NewNode"
71+
}
72+
6673
val edges = rootNode
6774
.getDescendants(false)
6875
.filter { it.getConceptReference() == ConceptReference(_C_UntypedImpl_Edge.getUID()) }

bulk-model-sync-gradle-test/src/test/kotlin/org/modelix/model/sync/bulk/gradle/test/PullTest.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.TestInstance
2121
import org.xmlunit.builder.Input
2222
import org.xmlunit.xpath.JAXPXPathEngine
2323
import java.io.File
24+
import kotlin.test.assertContains
2425
import kotlin.test.assertContentEquals
2526
import kotlin.test.assertEquals
2627

@@ -46,11 +47,23 @@ class PullTest {
4647
.selectNodes("model/node/node[@concept='1DmExO']/property", solution1Xml)
4748

4849
val actual = properties.map { it.attributes.getNamedItem("value").nodeValue }
49-
val expected = listOf("X", "Y", "Z", "D", "E")
50+
val expected = listOf("X", "Y", "Z", "NewNode", "D", "E")
5051

5152
assertContentEquals(expected, actual)
5253
}
5354

55+
@Test
56+
fun `added child was synced to local`() {
57+
val xpath = JAXPXPathEngine()
58+
val nodes = xpath.selectNodes("model/node/node[@concept='1DmExO']", solution1Xml)
59+
60+
val nodeNames = nodes.flatMap { xpath.selectNodes("property", it) }
61+
.map { it.attributes.getNamedItem("value").nodeValue }
62+
63+
assertEquals(6, nodes.count())
64+
assertContains(nodeNames, "NewNode")
65+
}
66+
5467
@Test
5568
fun `references were synced to local`() {
5669
val references = JAXPXPathEngine()

0 commit comments

Comments
 (0)