# ArgumentMatcher

Basic Rule to match any statement with Mockito is to correctly match its parameters. If any of the parameter did not match then instruction will not be mocked.

```java
// example statement
final int addition = calculator.getAddition(2, 3);

// you have to match exact parameters, in this case (2,3)
Mockito.when(mckCalculator.getAddition(2, 3)).thenReturn(5);

// If you mock for (3,4), you mocked result will not be returned
Mockito.when(mckCalculator.getAddition(3, 4)).thenReturn(5);

// For cases, where you do not know exact parameter then you can use Mockito.anyInt()
Mockito.when(mckCalculator.getAddition(Mockito.anyInt(), Mockito.anyInt())).thenReturn(5);
```

Similarly we have `Mockito.any()`, `Mockito.anyLong()`, `Mockito.anyString()`, `Mockito.anyBoolean()`, `Mockito.anyByte()`, `Mockito.anyChar()`, `Mockito.anyFloat()`, `Mockito.anyDouble()`, `Mockito.anyShort()`, `Mockito.anyList()`, `Mockito.anySet()` and `Mockito.anyMap()`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.tejpratapsingh.com/_/java-testing/mockito/argumentmatcher.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
