selectGatewayInfoConfig

selectGatewayInfoConfig

我正在尝试将通配符传递给mockito any()方法。
这是方法

selectGatewayInfoConfig(Operation<?> o)

我正在尝试做的是:
when(gatewayConfigSelector.selectGatewayInfoConfig( any(**!!!!!! HERE I NEED THIS WILDCARD !!!!**));
                .thenReturn(...something...);

提前致谢。

最佳答案

怎么样?

when(gatewayConfigSelector.selectGatewayInfoConfig( any(Operation.class));
            .thenReturn(...something...);

例子:
@Test
public void test() {
    Tester mock = Mockito.mock(Tester.class);
    Mockito.when(mock.selectGatewayInfoConfig(Mockito.any(Operation.class))).thenReturn("blah");

    System.out.println(mock.selectGatewayInfoConfig(null));
}


class Operation<T> {

}

class Tester {

    public String selectGatewayInfoConfig(Operation<?> o) {
        return "hi";
    }
}

09-27 02:58