@@ -8,6 +8,7 @@ import `in`.rcard.assertj.arrowcore.errors.EitherShouldContain.Companion.shouldC
88import `in`.rcard.assertj.arrowcore.errors.EitherShouldContainInstanceOf.Companion.shouldContainOnLeftInstanceOf
99import `in`.rcard.assertj.arrowcore.errors.EitherShouldContainInstanceOf.Companion.shouldContainOnRightInstanceOf
1010import org.assertj.core.api.AbstractObjectAssert
11+ import org.assertj.core.api.Assertions
1112import org.assertj.core.internal.ComparisonStrategy
1213import org.assertj.core.internal.StandardComparisonStrategy
1314
@@ -94,12 +95,28 @@ abstract class AbstractEitherAssert<
9495 *
9596 * @since 0.1.0
9697 */
98+ @Deprecated(
99+ " hasRightValueSatisfying can be replaced using the method asRight() and chaining assertions on the returned object." ,
100+ ReplaceWith (" asRight().satisfies(requirement)" ),
101+ )
97102 fun hasRightValueSatisfying (requirement : (RIGHT ) -> Unit ): SELF {
98103 assertIsRight()
99104 actual.onRight { requirement(it) }
100105 return myself
101106 }
102107
108+ /* *
109+ * Verifies that the actual [Either] is not null and contains a right-sided value and returns an Object assertion
110+ * that allows chaining (object) assertions on the value.
111+ *
112+ * @since 0.2.0
113+ * @return a new [AbstractObjectAssert] for assertions chaining on the right-sided value of the [Either].
114+ */
115+ fun asRight (): AbstractObjectAssert <* , RIGHT > {
116+ assertIsRight()
117+ return Assertions .assertThat(actual.getOrNull())
118+ }
119+
103120 private fun assertIsRight () {
104121 isNotNull
105122 if (! actual.isRight()) {
@@ -149,12 +166,28 @@ abstract class AbstractEitherAssert<
149166 * @return this assertion object.
150167 * @since 0.1.0
151168 */
169+ @Deprecated(
170+ " hasLeftValueSatisfying can be replaced using the method asLeft() and chaining assertions on the returned object." ,
171+ ReplaceWith (" asLeft().satisfies(requirement)" ),
172+ )
152173 fun hasLeftValueSatisfying (requirement : (LEFT ) -> Unit ): SELF {
153174 assertIsLeft()
154175 actual.onLeft { requirement(it) }
155176 return myself
156177 }
157178
179+ /* *
180+ * Verifies that the actual [Either] is not null and contains a left-sided value and returns an Object assertion
181+ * that allows chaining (object) assertions on the value.
182+ *
183+ * @since 0.2.0
184+ * @return a new [AbstractObjectAssert] for assertions chaining on the left-sided value of the [Either].
185+ */
186+ fun asLeft (): AbstractObjectAssert <* , LEFT > {
187+ assertIsLeft()
188+ return Assertions .assertThat(actual.leftOrNull())
189+ }
190+
158191 private fun assertIsLeft () {
159192 isNotNull
160193 if (! actual.isLeft()) {
0 commit comments