This time, however, I get a ParameterResolutionException, because I'm accepting a io.vertx.rxjava.core.Vertx, not an io.vertx.core.Vertx:
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [io.vertx.rxjava.core.Vertx arg0] in executable [public void com.nml.ips.bnymellon.rest.AuthenticatorTest.testGetNewToken(io.vertx.rxjava.core.Vertx,io.vertx.junit5.VertxTestContext) throws java.lang.InterruptedException].
...
While I was able to workaround the issue with the code below, I feel like this module should optionally depend on io.vertx:vertx-rx-java (ie, use maven's scope provided or similar) and, if a test signature accepts an io.vertx.rxjava.core.Vertx, the extension should supply a new io.vertx.rxjava.core.Vertx(vertx), where vertx is the io.vertx.core.Vertx that the extension would normally supply.
Here's my workaround:
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import io.vertx.rxjava.core.Vertx;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import rx.Single;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@ExtendWith(VertxExtension.class)
public class AuthenticatorTest2 {
public static class AuthenticatorStub {
public AuthenticatorStub(Vertx vertx) {}
public Single<Token> getToken() {
return Single.just(new Token().setValue("bogus").setExpiry(Instant.now().plusSeconds(60 * 5)));
}
}
public Vertx rxvertx;
@BeforeEach
public void setup(io.vertx.core.Vertx vertx) {
rxvertx = new Vertx(vertx);
}
@Test
public void testGetNewToken(VertxTestContext context) throws InterruptedException {
AuthenticatorStub auth = new AuthenticatorStub(rxvertx);
auth.getToken().subscribe(token -> {
try {
fail("bogus");
context.completeNow();
} catch (Throwable t) {
context.failNow(t);
}
}, context::failNow);
assertTrue(context.awaitCompletion(60, TimeUnit.SECONDS));
}
}
As a follow up to #40, I made the suggested fix:
This time, however, I get a
ParameterResolutionException
, because I'm accepting a io.vertx.rxjava.core.Vertx, not an io.vertx.core.Vertx:While I was able to workaround the issue with the code below, I feel like this module should optionally depend on
io.vertx:vertx-rx-java
(ie, use maven's scopeprovided
or similar) and, if a test signature accepts anio.vertx.rxjava.core.Vertx
, the extension should supply anew io.vertx.rxjava.core.Vertx(vertx)
, wherevertx
is theio.vertx.core.Vertx
that the extension would normally supply.Here's my workaround: