@@ -6,6 +6,7 @@ import `in`.rcard.assertj.arrowcore.errors.OptionShouldBePresent.Companion.shoul
66import `in`.rcard.assertj.arrowcore.errors.OptionShouldContain.Companion.shouldContain
77import `in`.rcard.assertj.arrowcore.errors.OptionShouldContainInstanceOf.Companion.shouldContainInstanceOf
88import org.assertj.core.api.AbstractObjectAssert
9+ import org.assertj.core.api.Assertions
910import org.assertj.core.internal.ComparisonStrategy
1011import org.assertj.core.internal.StandardComparisonStrategy
1112
@@ -26,16 +27,6 @@ abstract class AbstractOptionAssert<
2627
2728 private val comparisonStrategy: ComparisonStrategy = StandardComparisonStrategy .instance()
2829
29- /* *
30- * Verifies that there is a value present in the actual [Option].
31- *
32- * @return this assertion object.
33- */
34- fun isDefined (): SELF {
35- assertValueIsPresent()
36- return myself
37- }
38-
3930 /* *
4031 * Verifies that the actual [Option] is empty.
4132 *
@@ -96,12 +87,38 @@ abstract class AbstractOptionAssert<
9687 * @return this assertion object.
9788 * @since 0.1.0
9889 */
90+ @Deprecated(
91+ " hasValueSatisfying can be replaced using the method get() and chaining assertions on the returned object." ,
92+ ReplaceWith (" get().satisfies(requirement)" ),
93+ )
9994 fun hasValueSatisfying (requirement : (VALUE ) -> Unit ): SELF {
10095 assertValueIsPresent()
10196 actual.onSome { requirement(it) }
10297 return myself
10398 }
10499
100+ /* *
101+ * Verifies that the actual [Option] is not null and not empty and returns an Object assertion that allows
102+ * chaining (object) assertions on the optional value.
103+ *
104+ * @since 0.2.0
105+ * @return a new [AbstractObjectAssert] for assertions chaining on the value of the [Option].
106+ */
107+ fun get (): AbstractObjectAssert <* , VALUE > {
108+ isDefined()
109+ return Assertions .assertThat(actual.getOrNull())
110+ }
111+
112+ /* *
113+ * Verifies that there is a value present in the actual [Option].
114+ *
115+ * @return this assertion object.
116+ */
117+ fun isDefined (): SELF {
118+ assertValueIsPresent()
119+ return myself
120+ }
121+
105122 private fun assertValueIsPresent () {
106123 isNotNull
107124 if (actual.isNone()) throwAssertionError(shouldBePresent())
0 commit comments