Open sylvain-barrepersyn opened 1 year ago
Enabling out with generics for extension test().
out
test()
fun aMono(): Mono<out CharSequence> { return Mono.just("Hello") }
StepVerifier.create(aMono()) .expectNext( "Hello" // OK ) .verifyComplete()
aMono() .test() .expectNext( "Hello" // Compilation error ) .verifyComplete()
It can be good to accept generics. Maybe a modification like this can be added ?
Example of modification:
// ↓ add `out` fun <T> Flux<out T>.test(): StepVerifier.FirstStep<T> = StepVerifier.create(this)
StepVerifier.create(...)
StepVerifierExtensions
/** * Extension for testing [Flux] with [StepVerifier] API. * * @author Sebastien Deleuze */ fun <T> Flux<T>.test(): StepVerifier.FirstStep<T> = StepVerifier.create(this) /** * Extension for testing [Flux] with [StepVerifier] API. * * @author Sebastien Deleuze */ fun <T> Flux<T>.test(n: Long): StepVerifier.FirstStep<T> = StepVerifier.create(this, n) /** * Extension for testing [Flux] with [StepVerifier] API. * * @author Cristian Romero */ fun <T> Flux<T>.test(options: StepVerifierOptions): StepVerifier.FirstStep<T> = StepVerifier.create(this, options) /** * Extension for testing [Mono] with [StepVerifier] API. * * @author Sebastien Deleuze */ fun <T> Mono<T>.test(): StepVerifier.FirstStep<T> = StepVerifier.create(this) /** * Extension for testing [Mono] with [StepVerifier] API. * * @author Sebastien Deleuze */ fun <T> Mono<T>.test(n: Long): StepVerifier.FirstStep<T> = StepVerifier.create(this, n) /** * Extension for testing [Mono] with [StepVerifier] API. * * @author Cristian Romero */ fun <T> Mono<T>.test(options: StepVerifierOptions): StepVerifier.FirstStep<T> = StepVerifier.create(this, options)
Motivation
Enabling
out
with generics for extensiontest()
.Desired solution
It can be good to accept generics. Maybe a modification like this can be added ?
Example of modification:
Considered alternatives
StepVerifier.create(...)
Additional context
StepVerifierExtensions