1
1
package org.modelix.model.sync.bulk.gradle.test
2
2
3
- import GraphLang.L_GraphLang
4
- import GraphLang.N_Edge
5
- import GraphLang.N_Node
6
- import GraphLang._C_UntypedImpl_Edge
7
- import GraphLang._C_UntypedImpl_Node
8
- import jetbrains.mps.lang.core.L_jetbrains_mps_lang_core
9
3
import kotlinx.coroutines.runBlocking
10
4
import org.junit.jupiter.api.Test
11
- import org.modelix.metamodel.TypedLanguagesRegistry
12
- import org.modelix.metamodel.typed
5
+ import org.junit.jupiter.api.TestInstance
13
6
import org.modelix.model.ModelFacade
14
- import org.modelix.model.api.ConceptReference
15
- import org.modelix.model.api.getDescendants
16
7
import org.modelix.model.api.getRootNode
17
- import org.modelix.model.client2.IModelClientV2
18
8
import org.modelix.model.client2.ModelClientV2PlatformSpecificBuilder
19
9
import org.modelix.model.client2.getReplicatedModel
20
- import org.modelix.model.client2.runWrite
21
10
import org.modelix.model.data.ModelData
22
11
import org.modelix.model.data.NodeData
23
- import org.modelix.model.lazy.BranchReference
24
12
import org.modelix.model.lazy.RepositoryId
25
13
import org.modelix.model.sync.bulk.asExported
26
14
import java.io.File
27
15
import kotlin.test.assertContentEquals
28
16
17
+ @TestInstance(TestInstance .Lifecycle .PER_CLASS )
29
18
class PushTest {
19
+ private val url = " http://0.0.0.0:28309/v2"
20
+ private val branchRef = ModelFacade .createBranchReference(RepositoryId (" ci-test" ), " master" )
21
+ private val client = ModelClientV2PlatformSpecificBuilder ().url(url).build().apply { runBlocking { init () } }
30
22
31
23
@Test
32
24
fun `nodes were synced to server` () {
@@ -36,48 +28,12 @@ class PushTest {
36
28
val modules = files.map { ModelData .fromJson(it.readText()) }
37
29
val inputModel = ModelData (root = NodeData (children = modules.map { it.root }))
38
30
39
- TypedLanguagesRegistry .register(L_GraphLang )
40
- TypedLanguagesRegistry .register(L_jetbrains_mps_lang_core )
41
-
42
- val repoId = RepositoryId (" ci-test" )
43
- val branchName = " master"
44
- val url = " http://0.0.0.0:28309/v2"
45
-
46
- val branchRef = ModelFacade .createBranchReference(repoId, branchName)
47
- val client = ModelClientV2PlatformSpecificBuilder ().url(url).build().apply { runBlocking { init () } }
48
31
val replicatedModel = client.getReplicatedModel(branchRef)
49
32
val branch = runBlocking { replicatedModel.start() }
50
33
51
34
branch.runRead {
52
35
assertContentEquals(inputModel.root.children, branch.getRootNode().allChildren.map { it.asExported() })
53
36
}
54
37
replicatedModel.dispose()
55
-
56
- applyChangesForPullTest(client, branchRef)
57
- }
58
-
59
- private fun applyChangesForPullTest (client : IModelClientV2 , branchRef : BranchReference ) {
60
- runBlocking {
61
- client.runWrite(branchRef) { rootNode ->
62
- val graphNodes = rootNode
63
- .getDescendants(false )
64
- .filter { it.getConceptReference() == ConceptReference (_C_UntypedImpl_Node .getUID()) }
65
- .map { it.typed<N_Node >() }
66
- .toList()
67
-
68
- graphNodes[0 ].name = " X"
69
- graphNodes[1 ].name = " Y"
70
- graphNodes[2 ].name = " Z"
71
-
72
- val edges = rootNode
73
- .getDescendants(false )
74
- .filter { it.getConceptReference() == ConceptReference (_C_UntypedImpl_Edge .getUID()) }
75
- .map { it.typed<N_Edge >() }
76
- .toList()
77
-
78
- edges[0 ].source = graphNodes[1 ]
79
- edges[0 ].target = graphNodes[3 ]
80
- }
81
- }
82
38
}
83
39
}
0 commit comments