|
7 | 7 |
|
8 | 8 | # assertj-arrow-core |
9 | 9 |
|
10 | | -This project provides a set of [AssertJ](https://assertj.github.io/doc/) assertions for the [Arrow](https://arrow-kt.io/) library. In detail, the project provides assertions for the following Arrow types: |
| 10 | +This project provides a set of [AssertJ](https://assertj.github.io/doc/) assertions for |
| 11 | +the [Arrow](https://arrow-kt.io/) library. In detail, the project provides assertions for the following Arrow types: |
11 | 12 |
|
12 | 13 | - [x] `Either<E, A>` |
13 | 14 | - [x] `Option<A>` |
14 | 15 | - [x] `Raise<E>.() -> A` |
15 | 16 |
|
16 | | -Maybe you're asking yourself: "Why do we need AssertJ assertions for Arrow types?". The answer is simple: We often use Kotlin and Arrow Kt inside a Java project using Spring Boot. In this case, we already have AssertJ in the classpath as an assertion library. So, why not use it to assert Arrow types? |
| 17 | +Maybe you're asking yourself: "Why do we need AssertJ assertions for Arrow types?". The answer is simple: We often use |
| 18 | +Kotlin and Arrow Kt inside a Java project using Spring Boot. In this case, we already have AssertJ in the classpath as |
| 19 | +an assertion library. So, why not use it to assert Arrow types? |
17 | 20 |
|
18 | 21 | ## Usage |
19 | 22 |
|
20 | 23 | The library is available on Maven Central. To use it, add the following dependency to your `pom.xml` file: |
21 | 24 |
|
22 | 25 | ```xml |
| 26 | + |
23 | 27 | <dependency> |
24 | | - <groupId>in.rcard</groupId> |
25 | | - <artifactId>assertj-arrow-core</artifactId> |
26 | | - <version>1.1.0</version> |
27 | | - <scope>test</scope> |
| 28 | + <groupId>in.rcard</groupId> |
| 29 | + <artifactId>assertj-arrow-core</artifactId> |
| 30 | + <version>1.1.0</version> |
| 31 | + <scope>test</scope> |
28 | 32 | </dependency> |
29 | 33 | ``` |
| 34 | + |
| 35 | +Otherwise, if you're using Gradle, add the following dependency to your `build.gradle.kts` file: |
| 36 | + |
| 37 | +```kotlin |
| 38 | +testImplementation("in.rcard:assertj-arrow-core:1.1.0") |
| 39 | +``` |
| 40 | + |
| 41 | +## Assertions Guide |
| 42 | + |
| 43 | +This section describes the assertions provided by the `assertj-arrow-core` library. |
| 44 | + |
| 45 | +### `Option<A>` |
| 46 | + |
| 47 | +Use the `in.rcard.assertj.arrowcore.OptionAssert` class as an entry point to assert `Option<A>` instances. |
| 48 | + |
| 49 | +| Assertions | Description | |
| 50 | +|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 51 | +| `isEmpty` | Verifies that the actual `Option` is empty. | |
| 52 | +| `contains` | Verifies that the actual `Option` contains the given value. | |
| 53 | +| `containsInstanceOf` | Verifies that the actual `Option` contains a value that is an instance of the argument. | |
| 54 | +| `get` | Verifies that the actual Option is not null and not empty and returns an Object assertion that allows chaining (object) assertions on the optional value. | |
| 55 | +| `isDefined` | Verifies that there is a value present in the actual `Option`. | |
| 56 | + |
| 57 | +### `Either<E, A>` |
| 58 | + |
| 59 | +Use the `in.rcard.assertj.arrowcore.EitherAssert` class as an entry point to assert `Either<E, A>` instances. |
| 60 | + |
| 61 | +| Assertions | Description | |
| 62 | +|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 63 | +| `isRight` | Verifies that the actual `Either` is right. | |
| 64 | +| `isLeft` | Verifies that the actual `Either` is left. | |
| 65 | +| `containsOnRight` | Verifies that the actual `Either` is `Either.Right` and contains the given value. | |
| 66 | +| `containsRightInstanceOf` | Verifies that the actual right-sided `Either` contains a value that is an instance of the argument. | |
| 67 | +| `asRight` | Verifies that the actual `Either` is not `null` and contains a right-sided value and returns an `Object` assertion that allows chaining (object) assertions on the value. | |
| 68 | +| `containsOnLeft` | Verifies that the actual `Either` is `Either.Left` and contains the given value. | |
| 69 | +| `containsLeftInstanceOf` | Verifies that the actual left-sided `Either` contains a value that is an instance of the argument. | |
| 70 | +| `asLeft` | Verifies that the actual `Either` is not `null` and contains a left-sided value and returns an `Object` assertion that allows chaining (object) assertions on the value. | |
0 commit comments