Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling out with generics for extension test() #60

Open
sylvain-barrepersyn opened this issue Oct 19, 2023 · 0 comments
Open

Enabling out with generics for extension test() #60

sylvain-barrepersyn opened this issue Oct 19, 2023 · 0 comments
Labels
❓need-triage This issue needs triage, hasn't been looked at by a team member yet

Comments

@sylvain-barrepersyn
Copy link

sylvain-barrepersyn commented Oct 19, 2023

Motivation

Enabling out with generics for extension test().

fun aMono(): Mono<out CharSequence> {
    return Mono.just("Hello")
}
StepVerifier.create(aMono())
    .expectNext(
        "Hello" // OK
    )
    .verifyComplete()
aMono()
    .test()
    .expectNext(
        "Hello" // Compilation error
    )
    .verifyComplete()

Desired solution

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)

Considered alternatives

  • Create new method for generics
  • Use directly StepVerifier.create(...)

Additional context

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)
@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓need-triage This issue needs triage, hasn't been looked at by a team member yet
Projects
None yet
Development

No branches or pull requests

2 participants