Skip to content

Commit 0b59265

Browse files
committed
test(model-datastructure): use SetConceptOp in existing tests
1 parent fe09d0d commit 0b59265

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

model-datastructure/src/commonTest/kotlin/RandomTreeChangeGenerator.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import org.modelix.model.api.ConceptReference
1718
import org.modelix.model.api.IBranch
1819
import org.modelix.model.api.IConcept
1920
import org.modelix.model.api.IIdGenerator
@@ -27,6 +28,7 @@ class RandomTreeChangeGenerator(private val idGenerator: IIdGenerator, private v
2728
val childRoles = listOf("cRole1", "cRole2", "cRole3")
2829
val propertyRoles = listOf("pRole1", "pRole2", "pRole3")
2930
val referenceRoles = listOf("rRole1", "rRole2", "rRole3")
31+
val concepts = listOf("concept1", "concept2", "concept3")
3032
val deleteOp: (IWriteTransaction, ExpectedTreeData?) -> Unit = { t, expectedTree ->
3133
val nodeToDelete = TreeTestUtil(t.tree, rand).randomLeafNode
3234
if (nodeToDelete != 0L && nodeToDelete != ITree.ROOT_ID) {
@@ -98,11 +100,18 @@ class RandomTreeChangeGenerator(private val idGenerator: IIdGenerator, private v
98100
}
99101
}
100102
}
103+
104+
val setConceptOp: (IWriteTransaction, ExpectedTreeData?) -> Unit = { transaction, expectedTree ->
105+
val node = TreeTestUtil(transaction.tree, rand).randomNodeWithRoot
106+
transaction.setConcept(node, ConceptReference(concepts[rand.nextInt(concepts.size)]))
107+
}
108+
101109
var operations: List<(IWriteTransaction, ExpectedTreeData?) -> Unit> = listOf(
102110
deleteOp,
103111
addNewOp,
104112
setPropertyOp,
105113
setReferenceOp,
114+
setConceptOp,
106115
moveOp,
107116
)
108117

@@ -111,6 +120,7 @@ class RandomTreeChangeGenerator(private val idGenerator: IIdGenerator, private v
111120
addNewOp,
112121
setPropertyOp,
113122
setReferenceOp,
123+
setConceptOp,
114124
)
115125
return this
116126
}

model-datastructure/src/commonTest/kotlin/RevertTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class RevertTest {
4444

4545
val allVersions = mutableListOf<CLVersion>()
4646

47-
randomChanges(baseBranch, 5, idGenerator, rand)
47+
randomChanges(baseBranch, 10, idGenerator, rand)
4848

4949
allVersions += createVersion(baseBranch.operationsAndTree, null, versionIdGenerator, store)
5050

model-datastructure/src/commonTest/kotlin/TreeDiffTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class TreeDiffTest {
135135
private open class DiffCollector() : ITreeChangeVisitor {
136136
val changedRoles = HashSet<RoleInNode>()
137137
val changedContainments = HashSet<Long>()
138+
val changedConcepts = HashSet<Long>()
138139

139140
open fun assertEquals(expected: DiffData) {
140141
assertEquals(expected.changedContainments, changedContainments)
@@ -150,7 +151,7 @@ class TreeDiffTest {
150151
}
151152

152153
override fun conceptChanged(nodeId: Long) {
153-
TODO("Not yet implemented")
154+
changedConcepts.add(nodeId)
154155
}
155156

156157
override fun propertyChanged(nodeId: Long, role: String) {

0 commit comments

Comments
 (0)