-
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.
La til funksjoner for bedre asserts mot test topics
- Loading branch information
Showing
5 changed files
with
34 additions
and
15 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
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,8 @@ | ||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(libs.kafka.streams.test) | ||
implementation(libs.test.kotest.assertionsCore) | ||
} |
22 changes: 22 additions & 0 deletions
22
...kafka-streams-test-functions/src/main/kotlin/no/nav/paw/test/KafkaStreamsTestExtension.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,22 @@ | ||
package no.nav.paw.test | ||
|
||
import io.kotest.assertions.withClue | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.types.shouldBeInstanceOf | ||
import org.apache.kafka.streams.TestOutputTopic | ||
import java.time.Duration | ||
|
||
inline fun <reified T : Any, A> TestOutputTopic<*, in T>.assertEvent(function: (T) -> A): A = | ||
assertEvent<T>().let(function) | ||
|
||
inline fun <reified T : Any> TestOutputTopic<*, in T>.assertEvent(): T { | ||
withClue("Expected event of type ${T::class.simpleName}, no event was found") { | ||
isEmpty shouldBe false | ||
} | ||
val event = readValue() | ||
return withClue("Expected event of type ${T::class}, found ${event?.let { it::class }}") { | ||
event.shouldBeInstanceOf<T>() | ||
} | ||
} | ||
|
||
val Int.seconds: Duration get() = Duration.ofSeconds(this.toLong()) |