-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bruk sterkt typet nøkkel i Redis-klasse (#356)
- Loading branch information
Showing
30 changed files
with
301 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
felles-test/src/main/kotlin/no/nav/helsearbeidsgiver/felles/test/mock/MockRedis.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package no.nav.helsearbeidsgiver.felles.test.mock | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.slot | ||
import no.nav.helsearbeidsgiver.felles.rapidsrivers.redis.RedisKey | ||
import no.nav.helsearbeidsgiver.felles.rapidsrivers.redis.RedisStore | ||
|
||
class MockRedis { | ||
val store = mockk<RedisStore>() | ||
|
||
private val mockStorage = mutableMapOf<RedisKey, String>() | ||
|
||
private val redisKey = slot<RedisKey>() | ||
private val newValue = slot<String>() | ||
|
||
// Fungerer som en capture slot for vararg | ||
private val keysToCheck = mutableListOf<RedisKey>() | ||
|
||
init { | ||
setup() | ||
} | ||
|
||
fun setup() { | ||
mockStorage.clear() | ||
|
||
every { store.set(capture(redisKey), capture(newValue)) } answers { | ||
mockStorage[redisKey.captured] = newValue.captured | ||
} | ||
|
||
every { store.get(capture(redisKey)) } answers { | ||
mockStorage[redisKey.captured] | ||
} | ||
|
||
every { store.exist(*varargAll { keysToCheck.add(it) }) } answers { | ||
val allKeys = mockStorage.keys.toSet() | ||
|
||
val keysExist = keysToCheck.intersect(allKeys).size.toLong() | ||
|
||
keysToCheck.clear() | ||
|
||
keysExist | ||
} | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
felles-test/src/main/kotlin/no/nav/helsearbeidsgiver/felles/test/mock/MockRedisStore.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
felles/src/main/kotlin/no/nav/helsearbeidsgiver/felles/rapidsrivers/redis/IRedisStore.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.