mocking stuff with mockito is cool… take a function, setup expected input values and define a return result… easy when the input value is fix… and can not be bigger then…
ok what was my problem… i had a simple function, which i needed to mock: (a little more complex, with acutally complex objects and enums, but it would have in a problem with following aswell)
int methodName(String s, int i);
the problem was that the return int is similar then the i is greater then or equal a value… lets say 3 (which actually was the case in my case, but who cares…)… so the mocks:
Mockito.when(this.myMock.methodName(“Hello”, 1)).thenReturn(7);
Mockito.when(this.myMock.methodName(“Hello”, 2)).thenReturn(23);
Greater then is:
Mockito.when(this.myMock.methodName(Mockito.eq(“Hello”), AdditionalMathcer.geq(3))).thenReturn(63456);
The problem or the confusing thing is, when you add an Matcher, all parameters need to have a Matcher… :/