问题
Here I am mocking it and expecting nothing from the method, but when I send the request body through eventbus request was going inside the method, which I am not expecting.
Can anyone help me with this issue? I didn't mocked any JDBC client and in the config file too I am giving empty credentials, since I am mocking it.
public class verticle extends AbstractVertcile {
private void jdbcCall(JsonArray data, Future<JsonArray> promise) {
String first_name = data.getValue(first_name);
String last_name = data.getValue(last_name);
JDBCClient jdbcClient = JDBCClient.createshared(vertx, JsonObject.mapFrom(jdbcConfig));
jdbcClient.query("select * from something where firstName = first_name and lastName = last_name", result -> {
if(result.succeeded()) {
List<JsonObject> resultset = result.result().getResults();
promise.complete(resultset);
}});
return promise;
}
}
@Test
public void testing(TestContext ctx) throws Exception{
verticle verts = mock(verticle.class);
PowerMockito.doNothing().when(verts).jdbcCall(isA(JsonArray.class), isA(Future.class));
vertx.eventBus().send("address", message, ctx.asyncAssertSuccess (resul -> {
String jsonResponse = resul.body().toString();
});
}
来源:https://stackoverflow.com/questions/60500323/i-am-mocking-the-method-but-in-the-test-when-i-called-the-method-debugger-going