I am trying to pass wildcard into mockito any() method. This is the method
selectGatewayInfoConfig(Operation<?> o)
What I am trying to do is:
when(gatewayConfigSelector.selectGatewayInfoConfig( any(**!!!!!! HERE I NEED THIS WILDCARD !!!!**));
.thenReturn(...something...);
Thanks in advance.
How about?
when(gatewayConfigSelector.selectGatewayInfoConfig( any(Operation.class));
.thenReturn(...something...);
Example:
@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";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With