Skip to content

Commit 43254d6

Browse files
committed
test(bulk-model-sync-gradle): dispose ReplicatedModel
1 parent 98346e6 commit 43254d6

File tree

1 file changed

+9
-8
lines changed
  • bulk-model-sync-gradle-test/src/test/kotlin/org/modelix/model/sync/bulk/gradle/test

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import org.modelix.metamodel.TypedLanguagesRegistry
1010
import org.modelix.metamodel.typed
1111
import org.modelix.model.ModelFacade
1212
import org.modelix.model.api.ConceptReference
13-
import org.modelix.model.api.IBranch
1413
import org.modelix.model.api.getDescendants
1514
import org.modelix.model.api.getRootNode
1615
import org.modelix.model.client2.ModelClientV2PlatformSpecificBuilder
16+
import org.modelix.model.client2.ReplicatedModel
1717
import org.modelix.model.client2.getReplicatedModel
1818
import org.modelix.model.data.ModelData
1919
import org.modelix.model.data.NodeData
@@ -40,21 +40,21 @@ class PushTest {
4040
val repoId = RepositoryId("ci-test")
4141
val branchName = "master"
4242
val url = "http://0.0.0.0:${Main.DEFAULT_PORT}/v2"
43+
4344
val branchRef = ModelFacade.createBranchReference(repoId, branchName)
44-
val client = ModelClientV2PlatformSpecificBuilder().url(url).build()
45+
val client = ModelClientV2PlatformSpecificBuilder().url(url).build().apply { runBlocking { init() } }
46+
val replicatedModel = client.getReplicatedModel(branchRef)
47+
val branch = runBlocking { replicatedModel.start() }
4548

46-
val branch = runBlocking {
47-
client.init()
48-
client.getReplicatedModel(branchRef).start()
49-
}
5049
branch.runRead {
5150
assertContentEquals(inputModel.root.children, branch.getRootNode().allChildren.map { it.asExported() })
5251
}
5352

54-
applyChangesForPullTest(branch)
53+
applyChangesForPullTest(replicatedModel)
5554
}
5655

57-
private fun applyChangesForPullTest(branch: IBranch) {
56+
private fun applyChangesForPullTest(replicatedModel: ReplicatedModel) {
57+
val branch = replicatedModel.getBranch()
5858
branch.runWrite {
5959
val graphNodes = branch.getRootNode()
6060
.getDescendants(false)
@@ -67,5 +67,6 @@ class PushTest {
6767
graphNodes[2].name = "Z"
6868
}
6969
sleep(5000) // changes are pushed asynchronously to the server. wait for the propagation
70+
replicatedModel.dispose()
7071
}
7172
}

0 commit comments

Comments
 (0)