|
16 | 16 |
|
17 | 17 | package org.modelix.model.sync.bulk.gradle.test
|
18 | 18 |
|
| 19 | +import org.junit.jupiter.api.BeforeAll |
19 | 20 | import org.junit.jupiter.api.Test
|
20 | 21 | import org.xmlunit.builder.Input
|
21 | 22 | import org.xmlunit.xpath.JAXPXPathEngine
|
22 | 23 | import java.io.File
|
| 24 | +import javax.xml.transform.Source |
23 | 25 | import kotlin.test.assertContentEquals
|
24 | 26 |
|
25 | 27 | 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 | + } |
26 | 38 |
|
27 | 39 | @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) |
32 | 43 |
|
33 | 44 | val actual = properties.map { it.attributes.getNamedItem("value").nodeValue }
|
34 | 45 | val expected = listOf("X", "Y", "Z", "D", "E")
|
35 | 46 |
|
36 | 47 | assertContentEquals(expected, actual)
|
37 | 48 | }
|
| 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 | + } |
38 | 60 | }
|
0 commit comments