File tree Expand file tree Collapse file tree 4 files changed +29
-11
lines changed
main/kotlin/in/rcard/assertj/arrowcore
test/kotlin/in/rcard/assertj/arrowcore Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,14 @@ abstract class AbstractEitherAssert<
8282 return myself
8383 }
8484
85- fun hasRightValueSatisfying (requirement : Consumer <RIGHT >): SELF {
85+ /* *
86+ * Verifies that the actual [Either] contains a right-sided value and gives this value to the given
87+ * consumer for further assertions. Should be used as a way of deeper asserting on the
88+ * containing object, as further requirement(s) for the value.
89+ */
90+ fun hasRightValueSatisfying (requirement : (RIGHT ) -> Unit ): SELF {
8691 assertIsRight()
87- actual.onRight { requirement.accept (it) }
92+ actual.onRight { requirement(it) }
8893 return myself
8994 }
9095
@@ -121,9 +126,14 @@ abstract class AbstractEitherAssert<
121126 return myself
122127 }
123128
124- fun hasLeftValueSatisfying (requirement : Consumer <LEFT >): SELF {
129+ /* *
130+ * Verifies that the actual [Either] contains a left-sided value and gives this value to the given
131+ * consumer for further assertions. Should be used as a way of deeper asserting on the
132+ * containing object, as further requirement(s) for the value.
133+ */
134+ fun hasLeftValueSatisfying (requirement : (LEFT ) -> Unit ): SELF {
125135 assertIsLeft()
126- actual.onLeft { requirement.accept (it) }
136+ actual.onLeft { requirement(it) }
127137 return myself
128138 }
129139
Original file line number Diff line number Diff line change @@ -86,9 +86,17 @@ abstract class AbstractOptionAssert<
8686 return myself
8787 }
8888
89- fun hasValueSatisfying (requirement : Consumer <VALUE >): SELF {
89+ /* *
90+ * Verifies that the actual [Option] contains a value and gives this value to the given
91+ * consumer for further assertions. Should be used as a way of deeper asserting on the
92+ * containing object, as further requirement(s) for the value.
93+ *
94+ * @param requirement to further assert on the object contained inside the [Option].
95+ * @return this assertion object.
96+ */
97+ fun hasValueSatisfying (requirement : (VALUE ) -> Unit ): SELF {
9098 assertValueIsPresent()
91- actual.onSome { requirement.accept (it) }
99+ actual.onSome { requirement(it) }
92100 return myself
93101 }
94102
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import org.assertj.core.util.FailureMessages.actualIsNull
88import org.junit.jupiter.api.Test
99
1010
11- class EitherAssert_hasLeftValueSatisfying_Test {
11+ internal class EitherAssert_hasLeftValueSatisfying_Test {
1212
1313 @Test
1414 internal fun `should fail when either is null` () {
@@ -35,8 +35,8 @@ class EitherAssert_hasLeftValueSatisfying_Test {
3535 }
3636
3737 @Test
38- fun should_pass_if_consumer_passes () {
38+ internal fun `should pass if consumer passes` () {
3939 val actual: Either <Int , String > = Either .Left (42 )
40- EitherAssert (actual).hasLeftValueSatisfying { assertThat(it).isEqualTo(42 ) }
40+ EitherAssert .assertThat (actual).hasLeftValueSatisfying { assertThat(it).isEqualTo(42 ) }
4141 }
4242}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import org.assertj.core.util.FailureMessages.actualIsNull
88import org.junit.jupiter.api.Test
99
1010
11- class EitherAssert_hasRightValueSatisfying_Test {
11+ internal class EitherAssert_hasRightValueSatisfying_Test {
1212
1313 @Test
1414 internal fun `should fail when either is null` () {
@@ -37,6 +37,6 @@ class EitherAssert_hasRightValueSatisfying_Test {
3737 @Test
3838 internal fun `should pass if consumer passes` () {
3939 val actual: Either <Int , String > = Either .Right (" something" )
40- EitherAssert (actual).hasRightValueSatisfying { assertThat(it).isEqualTo(" something" ) }
40+ EitherAssert .assertThat (actual).hasRightValueSatisfying { assertThat(it).isEqualTo(" something" ) }
4141 }
4242}
You can’t perform that action at this time.
0 commit comments