Skip to content

Commit

Permalink
make schema reg url private
Browse files Browse the repository at this point in the history
  • Loading branch information
rtc11 committed Apr 25, 2022
1 parent 04fa1a1 commit 3ea269d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.util.*

class KafkaStreamsMock : KStreams {
lateinit var streams: TopologyTestDriver
var schemaRegistryUrl: String? = null
private var schemaRegistryUrl: String? = null

override fun start(config: KafkaConfig, registry: MeterRegistry, builder: StreamsBuilder.() -> Unit) {
val topology = StreamsBuilder().apply(builder).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import java.util.*
import kotlin.test.assertNotNull
import kotlin.test.assertNull

private inline fun KafkaStreamsMock.schemaRegistryUrl(): String? =
javaClass.getDeclaredField("schemaRegistryUrl").let {
it.isAccessible = true
return@let it.get(this) as? String;
}

class KStreamsMockTest {

@Test
Expand All @@ -27,7 +33,7 @@ class KStreamsMockTest {

kafka.start(config, registry) {}

assertNull(kafka.schemaRegistryUrl)
assertNull(kafka.schemaRegistryUrl())
}

@Test
Expand All @@ -49,6 +55,6 @@ class KStreamsMockTest {

kafka.start(config, registry) {}

assertNotNull(UUID.fromString(kafka.schemaRegistryUrl?.removePrefix("$schemaUrl/")))
assertNotNull(UUID.fromString(kafka.schemaRegistryUrl()?.removePrefix("$schemaUrl/")))
}
}

0 comments on commit 3ea269d

Please sign in to comment.