14
14
*/
15
15
16
16
import io .vavr .control .Either ;
17
-
18
17
import org .assertj .core .error .BasicErrorMessageFactory ;
19
18
20
19
/**
@@ -30,52 +29,49 @@ class EitherShouldContain extends BasicErrorMessageFactory {
30
29
private static final String EXPECTING_TO_CONTAIN_SAME = "%nExpecting:%n <%s>%nto contain the instance (i.e. compared with ==):%n <%s>%nbut did not." ;
31
30
private static final String EXPECTING_TO_CONTAIN_BUT_IS_LEFT = "%nExpecting:%n <%s>%nto contain on right side:%n <%s>%nbut was left sided." ;
32
31
private static final String EXPECTING_TO_CONTAIN_BUT_IS_RIGHT = "%nExpecting:%n <%s>%nto contain on right side:%n <%s>%nbut was right sided." ;
33
-
32
+ private static final String EXPECTING_TO_CONTAIN_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [LEFT]%nbut did not." ;
33
+ private static final String EXPECTING_TO_CONTAIN_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [RIGHT]%nbut did not." ;
34
+ private static final String EXPECTING_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain on the [LEFT]:%n <%s>%nbut had <%s> on the [RIGHT]." ;
35
+ private static final String EXPECTING_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain on the [RIGHT]:%n <%s>%nbut had <%s> on the [LEFT]." ;
34
36
private EitherShouldContain (String message , Object actual , Object expected ) {
35
37
super (message , actual , expected );
36
38
}
37
39
38
- private static final String EXPECTING_TO_CONTAIN_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [LEFT]%nbut did not." ;
39
- private static final String EXPECTING_TO_CONTAIN_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [RIGHT]%nbut did not." ;
40
-
41
- private static final String EXPECTING_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain on the [LEFT]:%n <%s>%nbut had <%s> on the [RIGHT]." ;
42
- private static final String EXPECTING_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain on the [RIGHT]:%n <%s>%nbut had <%s> on the [LEFT]." ;
43
-
44
- private EitherShouldContain (String format , Object ... arguments ) {
45
- super (format , arguments );
46
- }
40
+ private EitherShouldContain (String format , Object ... arguments ) {
41
+ super (format , arguments );
42
+ }
47
43
48
- /**
49
- * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument.
50
- *
51
- * @param either the {@link io.vavr.control.Either} which contains a value.
52
- * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
53
- * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
54
- * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
55
- * @return an error message factory
56
- */
57
- static <LEFT , RIGHT > EitherShouldContain shouldContain (Either <LEFT , RIGHT > either ,
58
- Object expected ) {
59
- return either .isLeft () ?
60
- new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_LEFT , either , expected ) :
61
- new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_RIGHT , either , expected );
62
- }
44
+ /**
45
+ * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument.
46
+ *
47
+ * @param either the {@link io.vavr.control.Either} which contains a value.
48
+ * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
49
+ * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
50
+ * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
51
+ * @return an error message factory
52
+ */
53
+ static <LEFT , RIGHT > EitherShouldContain shouldContain (Either <LEFT , RIGHT > either ,
54
+ Object expected ) {
55
+ return either .isLeft () ?
56
+ new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_LEFT , either , expected ) :
57
+ new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_RIGHT , either , expected );
58
+ }
63
59
64
- /**
65
- * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument on expected side.
66
- *
67
- * @param either the {@link io.vavr.control.Either} which contains a value.
68
- * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
69
- * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
70
- * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
71
- * @return an error message factory
72
- */
73
- static <LEFT , RIGHT > EitherShouldContain shouldContainOnOtherSide (Either <LEFT , RIGHT > either ,
74
- Object expected ) {
75
- return either .isRight ()
76
- ? new EitherShouldContain (EXPECTING_ON_THE_LEFT , either , expected , either .get ())
77
- : new EitherShouldContain (EXPECTING_ON_THE_RIGHT , either , expected , either .getLeft ());
78
- }
60
+ /**
61
+ * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument on expected side.
62
+ *
63
+ * @param either the {@link io.vavr.control.Either} which contains a value.
64
+ * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
65
+ * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
66
+ * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
67
+ * @return an error message factory
68
+ */
69
+ static <LEFT , RIGHT > EitherShouldContain shouldContainOnOtherSide (Either <LEFT , RIGHT > either ,
70
+ Object expected ) {
71
+ return either .isRight ()
72
+ ? new EitherShouldContain (EXPECTING_ON_THE_LEFT , either , expected , either .get ())
73
+ : new EitherShouldContain (EXPECTING_ON_THE_RIGHT , either , expected , either .getLeft ());
74
+ }
79
75
80
76
/**
81
77
* Indicates that the provided {@link Either} does not contain the provided argument as right value.
@@ -84,7 +80,6 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainOnOtherSide(Either<LEFT, R
84
80
* @param expectedValue the value we expect to be in the provided {@link Either} on the right side.
85
81
* @param <LEFT> the type of the value contained in the {@link Either} on the left side.
86
82
* @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
87
- *
88
83
* @return an error message factory
89
84
*/
90
85
static <LEFT , RIGHT > EitherShouldContain shouldContainOnRight (Either <LEFT , RIGHT > either , RIGHT expectedValue ) {
@@ -101,7 +96,6 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainOnRight(Either<LEFT, RIGHT
101
96
* @param expectedValue the value we expect to be in the provided {@link Either} on the right side.
102
97
* @param <LEFT> the type of the value contained in the {@link Either} on the left side.
103
98
* @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
104
- *
105
99
* @return an error message factory
106
100
*/
107
101
static <LEFT , RIGHT > EitherShouldContain shouldContainSameOnRight (Either <LEFT , RIGHT > either , RIGHT expectedValue ) {
@@ -117,14 +111,13 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainSameOnRight(Either<LEFT, R
117
111
* @param expectedValue the value we expect to be in the provided {@link Either} on the left side.
118
112
* @param <LEFT> the type of the value contained in the {@link Either} on the left side.
119
113
* @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
120
- *
121
114
* @return an error message factory
122
115
*/
123
116
static <LEFT , RIGHT > EitherShouldContain shouldContainOnLeft (Either <LEFT , RIGHT > either ,
124
- LEFT expectedValue ) {
117
+ LEFT expectedValue ) {
125
118
return either .isLeft () ?
126
- new EitherShouldContain (EXPECTING_TO_CONTAIN , either , expectedValue ) :
127
- shouldContainButIsRight (either , expectedValue );
119
+ new EitherShouldContain (EXPECTING_TO_CONTAIN , either , expectedValue ) :
120
+ shouldContainButIsRight (either , expectedValue );
128
121
}
129
122
130
123
/**
@@ -135,21 +128,19 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainOnLeft(Either<LEFT, RIGHT>
135
128
* @param expectedValue the value we expect to be in the provided {@link Either} on the left side.
136
129
* @param <LEFT> the type of the value contained in the {@link Either} on the left side.
137
130
* @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
138
- *
139
131
* @return an error message factory
140
132
*/
141
133
static <LEFT , RIGHT > EitherShouldContain shouldContainSameOnLeft (Either <LEFT , RIGHT > either ,
142
- LEFT expectedValue ) {
134
+ LEFT expectedValue ) {
143
135
return either .isLeft () ?
144
- new EitherShouldContain (EXPECTING_TO_CONTAIN_SAME , either , expectedValue ) :
145
- shouldContainButIsRight (either , expectedValue );
136
+ new EitherShouldContain (EXPECTING_TO_CONTAIN_SAME , either , expectedValue ) :
137
+ shouldContainButIsRight (either , expectedValue );
146
138
}
147
139
148
140
/**
149
141
* Indicates that an {@link Either} is left so it doesn't contain the expected right value.
150
142
*
151
143
* @param expectedRightValue the right value we expect to be in an {@link Either}.
152
- *
153
144
* @return an error message factory.
154
145
*/
155
146
static EitherShouldContain shouldContainButIsLeft (Either <?, ?> either , Object expectedRightValue ) {
@@ -160,7 +151,6 @@ static EitherShouldContain shouldContainButIsLeft(Either<?, ?> either, Object ex
160
151
* Indicates that an {@link Either} is right so it doesn't contain the expected left value.
161
152
*
162
153
* @param expectedRightValue the left value we expect to be in an {@link Either}.
163
- *
164
154
* @return an error message factory.
165
155
*/
166
156
static EitherShouldContain shouldContainButIsRight (Either <?, ?> either , Object expectedRightValue ) {
0 commit comments