I am mocking the method but in the test when i called the method, debugger going inside the method and expecting something i am not sure why

廉价感情. 提交于 2021-01-29 17:20:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!