11package org.modelix.model.sync.bulk.gradle.test
22
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
93import kotlinx.coroutines.runBlocking
104import org.junit.jupiter.api.Test
11- import org.modelix.metamodel.TypedLanguagesRegistry
12- import org.modelix.metamodel.typed
5+ import org.junit.jupiter.api.TestInstance
136import org.modelix.model.ModelFacade
14- import org.modelix.model.api.ConceptReference
15- import org.modelix.model.api.getDescendants
167import org.modelix.model.api.getRootNode
17- import org.modelix.model.client2.IModelClientV2
188import org.modelix.model.client2.ModelClientV2PlatformSpecificBuilder
199import org.modelix.model.client2.getReplicatedModel
20- import org.modelix.model.client2.runWrite
2110import org.modelix.model.data.ModelData
2211import org.modelix.model.data.NodeData
23- import org.modelix.model.lazy.BranchReference
2412import org.modelix.model.lazy.RepositoryId
2513import org.modelix.model.sync.bulk.asExported
2614import java.io.File
2715import kotlin.test.assertContentEquals
2816
17+ @TestInstance(TestInstance .Lifecycle .PER_CLASS )
2918class 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 () } }
3022
3123 @Test
3224 fun `nodes were synced to server` () {
@@ -36,48 +28,12 @@ class PushTest {
3628 val modules = files.map { ModelData .fromJson(it.readText()) }
3729 val inputModel = ModelData (root = NodeData (children = modules.map { it.root }))
3830
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 () } }
4831 val replicatedModel = client.getReplicatedModel(branchRef)
4932 val branch = runBlocking { replicatedModel.start() }
5033
5134 branch.runRead {
5235 assertContentEquals(inputModel.root.children, branch.getRootNode().allChildren.map { it.asExported() })
5336 }
5437 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- }
8238 }
8339}
0 commit comments