Polishing

This commit is contained in:
Sam Brannen
2023-06-06 11:29:25 +02:00
parent c0cd55a8fa
commit 05eab703cc
9 changed files with 126 additions and 127 deletions

View File

@@ -22,7 +22,6 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
@@ -35,6 +34,9 @@ import kotlin.coroutines.Continuation
class KotlinScheduledAnnotationReactiveSupportTests {
private var target: SuspendingFunctions? = SuspendingFunctions()
@Test
fun ensureReactor() {
assertThat(ScheduledAnnotationReactiveSupport.reactorPresent).isTrue
@@ -65,44 +67,6 @@ class KotlinScheduledAnnotationReactiveSupportTests {
assertThat(isReactive(method)).isFalse
}
internal class SuspendingFunctions {
suspend fun suspending() {
}
suspend fun suspendingReturns(): String = "suspended"
suspend fun withParam(param: String): String {
return param
}
suspend fun throwsIllegalState() {
throw IllegalStateException("expected")
}
var subscription = AtomicInteger()
suspend fun suspendingTracking() {
subscription.incrementAndGet()
}
fun notSuspending() { }
fun flow(): Flow<Void> {
return flowOf()
}
fun deferred(): Deferred<Void> {
return CompletableDeferred()
}
}
private var target: SuspendingFunctions? = null
@BeforeEach
fun init() {
target = SuspendingFunctions()
}
@Test
fun checkKotlinRuntimeIfNeeded() {
val suspendingMethod = ReflectionUtils.findMethod(SuspendingFunctions::class.java, "suspending", Continuation::class.java)!!
@@ -152,4 +116,36 @@ class KotlinScheduledAnnotationReactiveSupportTests {
mono.block()
assertThat(target!!.subscription).describedAs("after subscription").hasValue(1)
}
}
internal class SuspendingFunctions {
suspend fun suspending() {
}
suspend fun suspendingReturns(): String = "suspended"
suspend fun withParam(param: String): String {
return param
}
suspend fun throwsIllegalState() {
throw IllegalStateException("expected")
}
var subscription = AtomicInteger()
suspend fun suspendingTracking() {
subscription.incrementAndGet()
}
fun notSuspending() { }
fun flow(): Flow<Void> {
return flowOf()
}
fun deferred(): Deferred<Void> {
return CompletableDeferred()
}
}
}