1
1
import org.modelix.model.lazy.AccessTrackingStore
2
2
import org.modelix.model.lazy.NonCachingObjectStore
3
3
import org.modelix.model.lazy.PrefetchCache
4
+ import org.modelix.model.lazy.WrittenEntry
5
+ import org.modelix.model.persistent.CPNode
4
6
import org.modelix.model.persistent.MapBasedStore
5
7
import kotlin.test.Test
6
8
import kotlin.test.assertEquals
@@ -24,4 +26,28 @@ class PrefetchCacheTest {
24
26
assertEquals(result, listOf (" value" ))
25
27
assertTrue(accessTrackingKeyValueStore.accessedEntries.isEmpty())
26
28
}
29
+
30
+ @Test
31
+ fun entriesAreCachedAfterGettingMultipleEntriesAsMap () {
32
+ val regularKey = " regularKey"
33
+ val prefetchKey = " prefetchKey"
34
+ val nodeForRegularKey = CPNode .create(
35
+ 2 , null , 1 , null , LongArray (0 ),
36
+ emptyArray(), emptyArray(), emptyArray(), emptyArray(),
37
+ )
38
+ val nodeForPrefetchKey = CPNode .create(
39
+ 3 , null , 1 , null , LongArray (0 ),
40
+ emptyArray(), emptyArray(), emptyArray(), emptyArray(),
41
+ )
42
+ keyValueStore.putAll(mapOf (regularKey to nodeForRegularKey.serialize(), prefetchKey to nodeForPrefetchKey.serialize()))
43
+ val regularKeyReference = WrittenEntry (regularKey) { nodeForRegularKey }
44
+ val prefetchKeyReference = WrittenEntry (prefetchKey) { nodeForPrefetchKey }
45
+ prefetchCache.getAll(listOf (regularKeyReference), listOf (prefetchKeyReference))
46
+ accessTrackingKeyValueStore.accessedEntries.clear()
47
+
48
+ val result = prefetchCache.getAll(listOf (regularKeyReference), listOf (prefetchKeyReference))
49
+
50
+ assertEquals(result, mapOf (regularKey to nodeForRegularKey, prefetchKey to nodeForPrefetchKey))
51
+ assertTrue(accessTrackingKeyValueStore.accessedEntries.isEmpty())
52
+ }
27
53
}
0 commit comments