I am refactoring our EasyMock based test cases to use Vertx.3. Specifically, I am refactoring the code that used to use registerHandler (......) to use consumer(......) method now.
All is good until I encounter the below method.
@Override
public <T> MessageConsumer<T> consumer(String address) {
Objects.requireNonNull(address, "address");
return new HandlerRegistration<>(address, false, false, -1);
}
The below chunk won't compile.
......
MessageConsumer<JsonObject> consumer = createMock(MessageConsumer.class);
expect(eventBus.consumer("address"))andReturn(consumer)times(1);
......
The compilation error message is as below:
andReturn (io.vertx.core.eventbus.MessageConsumer<java.lang.Object>) in IExpectationSetters cannot be applied to (io.vertx.core.eventbus.MessageConsumer<io.vertx.core.json.JsonObject>)
The problem is that the return type of the consumer method is not really maintained.
I consider this ill-typed method a defect in Vertx (EasyMock just exposes this issue expliicitly).
Can someone in Vertx team have a look on this or explain the design goal of this method and guide me what should do in mock tests to get around it?