<commit_before># Mockito-Java8 [![Build Status](https://travis-ci.org/szpak/mockito-java8.svg?branch=master)](https://travis-ci.org/szpak/mockito-java8) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8/badge.svg)](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8)

Mockito add-ons leveraging Java 8 and lambda expressions to make mocking even more compact.

## Quick start

### Lambda matcher

Allows for stubbing with matcher logic defined within a lambda expression. Useful when working with complex classes pass as an argument.

```
given(ts.findNumberOfShipsInRangeByCriteria(
    argLambda(c -> c.getMinimumRange() > 1000))).willReturn(4);
```

### Argument Captor - Java 8 edition

Allows to use ArgumentCaptor in one line (here with AssertJ):

```
verify(ts).findNumberOfShipsInRangeByCriteria(
    assertArg(sc -> assertThat(sc.getMinimumRange()).isLessThan(2000)));
```

### Mockito API methods available via interfaces (without static imports)

Allows to use methods from Mockito API without the need to use static imports. It is enough to make your test class implement `WithBDDMockito`
interface to have all methods from Mockito API available directly (especially useful for Eclipse users).

```
class SpaceShipTest implements WithBDDMockito {
    //stub and verify as usual without static imports
}
```

Available interfaces: [`WithBDDMockito`](https://github.com/szpak/mockito-java8/blob/master/src/main/java/info/solidsoft/mockito/java8/api/WithBDDMockito.java),
[`WithMockito`](https://github.com/szpak/mockito-java8/blob/master/src/main/java/info/solidsoft/mockito/java8/api/WithMockito.java) and
[`WithAdditionalMatchers`](https://github.com/szpak/mockito-java8/blob/master/src/main/java/info/solidsoft/mockito/java8/api/WithAdditionalMatchers.java).


## Configuration in a project

mockito-java8 jars are available in Maven Central.

### Gradle

```
testCompile 'info.solidsoft.mockito:mockito-java8:1.0.0-beta'
```

### Maven

```
<dependency>
    <groupId>info.solidsoft.mockito</groupId>
    <artifactId>mockito-java8</artifactId>
    <version>1.0.0-beta</version>
    <scope>test</scope>
</dependency>
```

### Other

Click Maven Central badge [![Maven Central](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8/badge.svg)](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8) to get configuration snippets for SBT, Ivy and more.

## Mockito compatibility

Mockito-Java8 has two development lines. Versions 1.x (and 0.3.x) should be compatible with Mockito 1.10.12+ and 2.0.x-beta up to 2.0.21-beta.
Versions 2.x supports the new matchers API and should be compatible with Mockito 2.0.22-beta and newer versions.

## Provided add-ons

### Lambda matcher

Allows to define matcher logic within a lambda expression. Useful when working with complex classes pass as an argument.

```
@Immutable
class ShipSearchCriteria {
    int minimumRange;
    int numberOfPhasers;<commit_msg>Release version: 2.0.0-beta<commit_after># Mockito-Java8 [![Build Status](https://travis-ci.org/szpak/mockito-java8.svg?branch=master)](https://travis-ci.org/szpak/mockito-java8) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8/badge.svg)](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8)

Mockito add-ons leveraging Java 8 and lambda expressions to make mocking even more compact.

## Quick start

### Lambda matcher

Allows for stubbing with matcher logic defined within a lambda expression. Useful when working with complex classes pass as an argument.

```
given(ts.findNumberOfShipsInRangeByCriteria(
    argLambda(c -> c.getMinimumRange() > 1000))).willReturn(4);
```

### Argument Captor - Java 8 edition

Allows to use ArgumentCaptor in one line (here with AssertJ):

```
verify(ts).findNumberOfShipsInRangeByCriteria(
    assertArg(sc -> assertThat(sc.getMinimumRange()).isLessThan(2000)));
```

### Mockito API methods available via interfaces (without static imports)

Allows to use methods from Mockito API without the need to use static imports. It is enough to make your test class implement `WithBDDMockito`
interface to have all methods from Mockito API available directly (especially useful for Eclipse users).

```
class SpaceShipTest implements WithBDDMockito {
    //stub and verify as usual without static imports
}
```

Available interfaces: [`WithBDDMockito`](https://github.com/szpak/mockito-java8/blob/master/src/main/java/info/solidsoft/mockito/java8/api/WithBDDMockito.java),
[`WithMockito`](https://github.com/szpak/mockito-java8/blob/master/src/main/java/info/solidsoft/mockito/java8/api/WithMockito.java) and
[`WithAdditionalMatchers`](https://github.com/szpak/mockito-java8/blob/master/src/main/java/info/solidsoft/mockito/java8/api/WithAdditionalMatchers.java).


## Configuration in a project

mockito-java8 jars are available in Maven Central.

### Gradle

```
testCompile 'info.solidsoft.mockito:mockito-java8:2.0.0-beta'
```

### Maven

```
<dependency>
    <groupId>info.solidsoft.mockito</groupId>
    <artifactId>mockito-java8</artifactId>
    <version>2.0.0-beta</version>
    <scope>test</scope>
</dependency>
```

### Other

Click Maven Central badge [![Maven Central](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8/badge.svg)](https://maven-badges.herokuapp.com/maven-central/info.solidsoft.mockito/mockito-java8) to get configuration snippets for SBT, Ivy and more.

## Mockito compatibility

Mockito-Java8 has two development lines. Versions 1.x (and 0.3.x) should be compatible with Mockito 1.10.12+ and 2.0.x-beta up to 2.0.21-beta.
Versions 2.x supports the new matchers API and should be compatible with Mockito 2.0.22-beta and newer versions.

## Provided add-ons

### Lambda matcher

Allows to define matcher logic within a lambda expression. Useful when working with complex classes pass as an argument.

```
@Immutable
class ShipSearchCriteria {
    int minimumRange;
    int numberOfPhasers;
{'fraction_non_alphanumeric': 0.12312703583061889, 'fraction_numerical': 0.01775244299674267, 'mean_word_length': 4.962135922330097, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '582529', 'n_tokens_mistral': 2073, 'n_tokens_neox': 1938, 'n_words': 479}