File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
src/main/kotlin/in/rcard/assertj/arrowcore Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import `in`.rcard.assertj.arrowcore.errors.EitherShouldContainInstanceOf.Compani
1010import org.assertj.core.api.AbstractObjectAssert
1111import org.assertj.core.internal.ComparisonStrategy
1212import org.assertj.core.internal.StandardComparisonStrategy
13+ import java.util.function.Consumer
1314
1415/* *
1516 * Assertions for [Either].
@@ -81,6 +82,12 @@ abstract class AbstractEitherAssert<
8182 return myself
8283 }
8384
85+ fun hasRightValueSatisfying (requirement : Consumer <RIGHT >): SELF {
86+ assertIsRight()
87+ actual.onRight { requirement.accept(it) }
88+ return myself
89+ }
90+
8491 private fun assertIsRight () {
8592 isNotNull
8693 if (! actual.isRight()) {
@@ -114,6 +121,12 @@ abstract class AbstractEitherAssert<
114121 return myself
115122 }
116123
124+ fun hasLeftValueSatisfying (requirement : Consumer <LEFT >): SELF {
125+ assertIsLeft()
126+ actual.onLeft { requirement.accept(it) }
127+ return myself
128+ }
129+
117130 private fun assertIsLeft () {
118131 isNotNull
119132 if (! actual.isLeft()) {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import `in`.rcard.assertj.arrowcore.errors.OptionShouldContainInstanceOf.Compani
88import org.assertj.core.api.AbstractObjectAssert
99import org.assertj.core.internal.ComparisonStrategy
1010import org.assertj.core.internal.StandardComparisonStrategy
11+ import java.util.function.Consumer
1112
1213/* *
1314 * Assertions for [Option].
@@ -85,6 +86,12 @@ abstract class AbstractOptionAssert<
8586 return myself
8687 }
8788
89+ fun hasValueSatisfying (requirement : Consumer <VALUE >): SELF {
90+ assertValueIsPresent()
91+ actual.onSome { requirement.accept(it) }
92+ return myself
93+ }
94+
8895 private fun assertValueIsPresent () {
8996 isNotNull
9097 if (actual.isEmpty()) throwAssertionError(shouldBePresent())
You can’t perform that action at this time.
0 commit comments