# assertj-arrow-core **Repository Path**: mirrors_assertj/assertj-arrow-core ## Basic Information - **Project Name**: assertj-arrow-core - **Description**: Assertions for Types Defined in Arrow Kt Core LIbrary - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-19 - **Last Updated**: 2026-04-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ![Kotlin Version](https://img.shields.io/badge/Kotlin-2.2.20-blue?style=flat&logo=kotlin) ![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/rcardin/assertj-arrow-core/ci.yml?branch=main) ![Maven Central](https://img.shields.io/maven-central/v/in.rcard/assertj-arrow-core) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/rcardin/assertj-arrow-core) [![javadoc](https://javadoc.io/badge2/in.rcard/assertj-arrow-core/javadoc.svg)](https://javadoc.io/doc/in.rcard/assertj-arrow-core) ktlint # assertj-arrow-core 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: - [x] `Either` - [x] `Option` - [x] `Raise.() -> A` - [x] `NonEmptyList` 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? ## Usage The library is available on Maven Central. To use it, add the following dependency to your `pom.xml` file: ```xml in.rcard assertj-arrow-core 2.0.0 test ``` Otherwise, if you're using Gradle, add the following dependency to your `build.gradle.kts` file: ```kotlin testImplementation("in.rcard:assertj-arrow-core:2.0.0") ``` ## Assertions Guide This section describes the assertions provided by the `assertj-arrow-core` library. ### `Option` Use the `in.rcard.assertj.arrowcore.OptionAssert` class as an entry point to assert `Option` instances. | Assertions | Description | |----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | `isEmpty` | Verifies that the actual `Option` is empty. | | `contains` | Verifies that the actual `Option` contains the given value. | | `containsInstanceOf` | Verifies that the actual `Option` contains a value that is an instance of the argument. | | `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. | | `isDefined` | Verifies that there is a value present in the actual `Option`. | ### `Either` Use the `in.rcard.assertj.arrowcore.EitherAssert` class as an entry point to assert `Either` instances. | Assertions | Description | |---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `isRight` | Verifies that the actual `Either` is right. | | `isLeft` | Verifies that the actual `Either` is left. | | `containsOnRight` | Verifies that the actual `Either` is `Either.Right` and contains the given value. | | `containsRightInstanceOf` | Verifies that the actual right-sided `Either` contains a value that is an instance of the argument. | | `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. | | `containsOnLeft` | Verifies that the actual `Either` is `Either.Left` and contains the given value. | | `containsLeftInstanceOf` | Verifies that the actual left-sided `Either` contains a value that is an instance of the argument. | | `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. | ### `Raise.() -> A` Use the `in.rcard.assertj.arrowcore.RaiseAssert` class as an entry point to assert `Raise.() -> A` instances. There are many different entry points, all of them available boh for regular and `suspend` functions: | Entry Point | Description | |----------------------|-----------------------------------------------------------------------------------------------------------------------------| | `assertThat` | Entry point to assert a `Raise.() -> A` instance. | | `assertThatThrownBy` | Verifies that the function in the `Raise` context throws an exception and let chaining assertion on the thrown exception | | `assertThatRaisedBy` | Verifies that the function in the `Raise` context raises a logic-typed error and let chaining assertion on the raised error | The available assertions are: | Assertions | Description | |----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `succeedsWith` | Verifies that the function in the `Raise` context succeeds with the given value. | | `succeeds` | Verifies that the function in the `Raise` context succeeded. No check on the value returned by the function is performed. | | `raises` | Verifies that the function in the Raise context fails with the given error. | | `fails` | Verifies that the function in the Raise context fails, no matter the type of the logical error. | | `result` | Verifies that the actual function in the `Raise` context succeeds and returns an `Object` assertion that allows chaining (object) assertions on the returned value. | | `error` | Verifies that the actual function in the Raise context fails and returns an Object assertion that allows chaining (object) assertions on the raised error. | ### `NonEmptyList` Use the `in.rcard.assertj.arrowcore.NonEmptyListAssert` class as an entry point to assert `NonEmptyList` instances. | Assertions | Description | |-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `shouldContain` | Verifies that the actual `NonEmptyList` contains the expected element. | | `shouldContainAll` | Verifies that the actual `NonEmptyList` contains all the expected elements. | | `shouldContainNoNulls` | Verifies that the actual `NonEmptyList` does not contain null. | | `shouldContainOnlyNulls` | Verifies that the actual `NonEmptyList` contains only null. | | `shouldContainNull` | Verifies that the actual `NonEmptyList` contains null. | | `shouldHaveDuplicates` | Verifies that the actual `NonEmptyList` contains at least one duplicate. | | `shouldBeSingleElement` | Verifies that the actual `NonEmptyList` has a single element which is expected element. | | `shouldBeSorted` | Verifies that the actual `NonEmptyList` is sorted. |