Skip to content

Commit f560ec7

Browse files
committed
test(bulk-model-sync-gradle): test for references
1 parent 04c04b5 commit f560ec7

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,45 @@
1616

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

19+
import org.junit.jupiter.api.BeforeAll
1920
import org.junit.jupiter.api.Test
2021
import org.xmlunit.builder.Input
2122
import org.xmlunit.xpath.JAXPXPathEngine
2223
import java.io.File
24+
import javax.xml.transform.Source
2325
import kotlin.test.assertContentEquals
2426

2527
class PullTest {
28+
companion object {
29+
private lateinit var source: Source
30+
31+
@JvmStatic
32+
@BeforeAll
33+
fun initSource() {
34+
val localModel = File("build/test-repo/solutions/GraphSolution/models/GraphSolution.example.mps").readText()
35+
source = Input.fromString(localModel).build()
36+
}
37+
}
2638

2739
@Test
28-
fun `nodes were synced to local`() {
29-
val localModel = File("build/test-repo/solutions/GraphSolution/models/GraphSolution.example.mps").readText()
30-
val source = Input.fromString(localModel).build()
31-
val properties = JAXPXPathEngine().selectNodes("model/node/node[@concept='1DmExO']/property", source)
40+
fun `properties were synced to local`() {
41+
val properties = JAXPXPathEngine()
42+
.selectNodes("model/node/node[@concept='1DmExO']/property", source)
3243

3344
val actual = properties.map { it.attributes.getNamedItem("value").nodeValue }
3445
val expected = listOf("X", "Y", "Z", "D", "E")
3546

3647
assertContentEquals(expected, actual)
3748
}
49+
50+
@Test
51+
fun `references were synced to local`() {
52+
val references = JAXPXPathEngine()
53+
.selectNodes("model/node/node[@id='pSCM1J8Fg1']/ref", source)
54+
55+
val actual = references.map { it.attributes.getNamedItem("node").nodeValue }
56+
val expected = listOf("pSCM1J8FfX", "pSCM1J8FfZ")
57+
58+
assertContentEquals(expected, actual)
59+
}
3860
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.modelix.model.sync.bulk.gradle.test
22

33
import GraphLang.L_GraphLang
4+
import GraphLang.N_Edge
45
import GraphLang.N_Node
6+
import GraphLang._C_UntypedImpl_Edge
57
import GraphLang._C_UntypedImpl_Node
68
import jetbrains.mps.lang.core.L_jetbrains_mps_lang_core
79
import kotlinx.coroutines.runBlocking
@@ -67,6 +69,15 @@ class PushTest {
6769
graphNodes[0].name = "X"
6870
graphNodes[1].name = "Y"
6971
graphNodes[2].name = "Z"
72+
73+
val edges = rootNode
74+
.getDescendants(false)
75+
.filter { it.getConceptReference() == ConceptReference(_C_UntypedImpl_Edge.getUID()) }
76+
.map { it.typed<N_Edge>() }
77+
.toList()
78+
79+
edges[0].source = graphNodes[1]
80+
edges[0].target = graphNodes[3]
7081
}
7182
}
7283
}

0 commit comments

Comments
 (0)