@@ -19,93 +19,93 @@ import org.assertj.core.internal.StandardComparisonStrategy
1919 * @author Riccardo Cardin
2020 */
2121abstract class AbstractEitherAssert <
22- SELF : AbstractEitherAssert <SELF , LEFT , RIGHT >, LEFT : Any , RIGHT : Any > (
23- either: Either <LEFT , RIGHT >?
22+ SELF : AbstractEitherAssert <SELF , LEFT , RIGHT >, LEFT : Any , RIGHT : Any , > (
23+ either: Either <LEFT , RIGHT >? ,
2424) : AbstractObjectAssert <SELF , Either <LEFT , RIGHT >>(either, AbstractEitherAssert ::class .java) {
2525
26- private val comparisonStrategy: ComparisonStrategy = StandardComparisonStrategy .instance()
26+ private val comparisonStrategy: ComparisonStrategy = StandardComparisonStrategy .instance()
2727
28- /* *
29- * Verifies that the actual [Either] is right.
30- *
31- * @return this assertion object.
32- */
33- fun isRight (): SELF {
34- isNotNull
35- assertIsRight()
36- return myself
37- }
28+ /* *
29+ * Verifies that the actual [Either] is right.
30+ *
31+ * @return this assertion object.
32+ */
33+ fun isRight (): SELF {
34+ isNotNull
35+ assertIsRight()
36+ return myself
37+ }
3838
39- /* *
40- * Verifies that the actual [Either] is left.
41- *
42- * @return this assertion object.
43- */
44- fun isLeft (): SELF {
45- assertIsLeft()
46- return myself
47- }
39+ /* *
40+ * Verifies that the actual [Either] is left.
41+ *
42+ * @return this assertion object.
43+ */
44+ fun isLeft (): SELF {
45+ assertIsLeft()
46+ return myself
47+ }
4848
49- /* *
50- * Verifies that the actual [Either] is [Either.Right] and contains the given value.
51- *
52- * @param expectedValue the expected value inside the [Either].
53- * @return this assertion object.
54- */
55- fun containsOnRight (expectedValue : RIGHT ): SELF {
56- assertIsRight()
57- actual.onRight { right ->
58- if (! comparisonStrategy.areEqual(right, expectedValue)) {
59- throwAssertionError(shouldContainOnRight(actual, expectedValue))
60- }
49+ /* *
50+ * Verifies that the actual [Either] is [Either.Right] and contains the given value.
51+ *
52+ * @param expectedValue the expected value inside the [Either].
53+ * @return this assertion object.
54+ */
55+ fun containsOnRight (expectedValue : RIGHT ): SELF {
56+ assertIsRight()
57+ actual.onRight { right ->
58+ if (! comparisonStrategy.areEqual(right, expectedValue)) {
59+ throwAssertionError(shouldContainOnRight(actual, expectedValue))
60+ }
61+ }
62+ return myself
6163 }
62- return myself
63- }
6464
65- /* *
66- * Verifies that the actual right-sided [Either] contains a value that is an
67- * instance of the argument.
68- *
69- * @param expectedClass the expected class of the value inside the right-sided [Either].
70- * @return this assertion object.
71- */
72- fun containsRightInstanceOf (expectedClass : Class <* >): SELF {
73- assertIsRight()
74- actual.onRight { right ->
75- if (! expectedClass.isInstance(right)) {
76- throwAssertionError(shouldContainOnRightInstanceOf(actual, expectedClass))
77- }
65+ /* *
66+ * Verifies that the actual right-sided [Either] contains a value that is an
67+ * instance of the argument.
68+ *
69+ * @param expectedClass the expected class of the value inside the right-sided [Either].
70+ * @return this assertion object.
71+ */
72+ fun containsRightInstanceOf (expectedClass : Class <* >): SELF {
73+ assertIsRight()
74+ actual.onRight { right ->
75+ if (! expectedClass.isInstance(right)) {
76+ throwAssertionError(shouldContainOnRightInstanceOf(actual, expectedClass))
77+ }
78+ }
79+ return myself
7880 }
79- return myself
80- }
8181
82- private fun assertIsRight () {
83- isNotNull
84- if (! actual.isRight()) {
85- throwAssertionError(shouldBeRight(actual))
82+ private fun assertIsRight () {
83+ isNotNull
84+ if (! actual.isRight()) {
85+ throwAssertionError(shouldBeRight(actual))
86+ }
8687 }
87- }
8888
89- /* *
90- * Verifies that the actual [Either] is [Either.Left] and contains the given value.
91- *
92- * @param expectedValue the expected value inside the [Either].
93- * @return this assertion object.
94- */
95- fun containsOnLeft (expectedValue : LEFT ): SELF {
96- assertIsLeft()
97- actual.onLeft { left ->
98- if (! comparisonStrategy.areEqual(left, expectedValue)) {
99- throwAssertionError(shouldContainOnLeft(actual, expectedValue))
100- }
89+ /* *
90+ * Verifies that the actual [Either] is [Either.Left] and contains the given value.
91+ *
92+ * @param expectedValue the expected value inside the [Either].
93+ * @return this assertion object.
94+ */
95+ fun containsOnLeft (expectedValue : LEFT ): SELF {
96+ assertIsLeft()
97+ actual.onLeft { left ->
98+ if (! comparisonStrategy.areEqual(left, expectedValue)) {
99+ throwAssertionError(shouldContainOnLeft(actual, expectedValue))
100+ }
101+ }
102+ return myself
101103 }
102- return myself
103- }
104104
105- private fun assertIsLeft () {
106- isNotNull
107- if (! actual.isLeft()) {
108- throwAssertionError(shouldBeLeft(actual))
105+ private fun assertIsLeft () {
106+ isNotNull
107+ if (! actual.isLeft()) {
108+ throwAssertionError(shouldBeLeft(actual))
109+ }
109110 }
110- }
111111}
0 commit comments