Skip to content

Commit a616567

Browse files
Add in ObjectEnumerableAssert javadoc references for assertions taking a vararg (ex: containsAnyOf) to their counterpart taking an iterable (ex: containsAnyElementsOf).
1 parent d001e89 commit a616567

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

src/main/java/org/assertj/core/api/ObjectEnumerableAssert.java

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
4545
*
4646
* // assertion will fail
4747
* assertThat(abc).contains("d");</code></pre>
48+
* <p>
49+
* If you want to specify the elements to check with an {@link Iterable}, use {@link #containsAll(Iterable) containsAll(Iterable)} instead.
4850
*
4951
* @param values the given values.
5052
* @return {@code this} assertion object.
@@ -58,8 +60,6 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
5860
/**
5961
* Verifies that the actual group contains only the given values and nothing else, in any order.
6062
* <p>
61-
* Use {@link #isSubsetOf(Iterable)} to check that actual is a subset of given iterable
62-
* <p>
6363
* Example :
6464
* <pre><code class='java'> Iterable&lt;String&gt; abc = newArrayList("a", "b", "c");
6565
*
@@ -68,8 +68,12 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
6868
*
6969
* // assertion will fail because "c" is missing
7070
* assertThat(abc).containsOnly("a", "b");
71-
* // assertion will fail because "d" is missing in abc
71+
* // assertion will fail because "d" is missing in abc (use isSubsetOf if you want this assertion to pass)
7272
* assertThat(abc).containsOnly("a", "b", "c", "d");</code></pre>
73+
* <p>
74+
* If you need to check that actual is a subset of the given values, use {@link #isSubsetOf(Object...)}.
75+
* <p>
76+
* If you want to specify the elements to check with an {@link Iterable}, use {@link #containsOnlyElementsOf(Iterable) containsOnlyElementsOf(Iterable)} instead.
7377
*
7478
* @param values the given values.
7579
* @return {@code this} assertion object.
@@ -143,6 +147,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
143147
*
144148
* // assertion will fail as actual and expected order differ
145149
* assertThat(elvesRings).containsExactly(nenya, vilya, narya);</code></pre>
150+
* <p>
151+
* If you want to specify the elements to check with an {@link Iterable}, use {@link #containsExactlyElementsOf(Iterable) containsExactlyElementsOf(Iterable)} instead.
146152
*
147153
* @param values the given values.
148154
* @return {@code this} assertion object.
@@ -167,6 +173,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
167173
*
168174
* // assertion will fail as vilya is contained twice in elvesRings.
169175
* assertThat(elvesRings).containsExactlyInAnyOrder(nenya, vilya, narya);</code></pre>
176+
* <p>
177+
* If you want to specify the elements to check with an {@link Iterable}, use {@link #containsExactlyInAnyOrderElementsOf(Iterable) containsExactlyInAnyOrderElementsOf(Iterable)} instead.
170178
*
171179
* @param values the given values.
172180
* @return {@code this} assertion object.
@@ -192,6 +200,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
192200
*
193201
* // assertion will fail as vilya is contained twice in elvesRings.
194202
* assertThat(elvesRings).containsExactlyInAnyOrder(elvesRingsSomeMissing);</code></pre>
203+
* <p>
204+
* If you want to directly specify the elements to check, use {@link #containsExactlyInAnyOrder(Object...) containsExactlyInAnyOrder(Object...)} instead.
195205
*
196206
* @param values the given values.
197207
* @return {@code this} assertion object.
@@ -219,6 +229,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
219229
* // assertions will fail, the elements order is correct but there is a value between them (nenya)
220230
* assertThat(elvesRings).containsSequence(vilya, narya);
221231
* assertThat(elvesRings).containsSequence(nenya, vilya);</code></pre>
232+
* <p>
233+
* If you want to specify the sequence to check with an {@link Iterable}, use {@link #containsSequence(Iterable) containsSequence(Iterable)} instead.
222234
*
223235
* @param sequence the sequence of objects to look for.
224236
* @return this assertion object.
@@ -243,6 +255,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
243255
* // assertions will fail, the elements order is correct but there is a value between them (nenya)
244256
* assertThat(elvesRings).containsSequence(newArrayList(vilya, narya));
245257
* assertThat(elvesRings).containsSequence(newArrayList(nenya, vilya));</code></pre>
258+
* <p>
259+
* If you want to directly specify the elements of the sequence to check, use {@link #containsSequence(Object...) containsSequence(Object...)} instead.
246260
*
247261
* @param sequence the sequence of objects to look for.
248262
* @return this assertion object.
@@ -269,6 +283,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
269283
* // assertions will fail
270284
* assertThat(elvesRings).doesNotContainSequence(vilya, nenya);
271285
* assertThat(elvesRings).doesNotContainSequence(nenya, narya);</code></pre>
286+
* <p>
287+
* If you want to specify the sequence not to find with an {@link Iterable}, use {@link #doesNotContainSequence(Iterable) doesNotContainSequence(Iterable)} instead.
272288
*
273289
* @param sequence the sequence of objects to look for.
274290
* @return this assertion object.
@@ -295,6 +311,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
295311
* // assertions will fail
296312
* assertThat(elvesRings).doesNotContainSequence(newArrayList(vilya, nenya));
297313
* assertThat(elvesRings).doesNotContainSequence(newArrayList(nenya, narya));</code></pre>
314+
* <p>
315+
* If you want to directly specify the elements of the sequence not to find, use {@link #doesNotContainSequence(Object...) doesNotContainSequence(Object...)} instead.
298316
*
299317
* @param sequence the sequence of objects to look for.
300318
* @return this assertion object.
@@ -317,7 +335,9 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
317335
*
318336
* // assertion will fail
319337
* assertThat(elvesRings).containsSubsequence(nenya, vilya);</code></pre>
320-
*
338+
* <p>
339+
* If you want to specify the elements of the subsequence to check with an {@link Iterable}, use {@link #containsSubsequence(Iterable) containsSubsequence(Iterable)} instead.
340+
321341
* @param sequence the sequence of objects to look for.
322342
* @return this assertion object.
323343
* @throws AssertionError if the actual group is {@code null}.
@@ -338,6 +358,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
338358
*
339359
* // assertion will fail
340360
* assertThat(elvesRings).containsSubsequence(newArrayList(nenya, vilya));</code></pre>
361+
* <p>
362+
* If you want to directly specify the subsequence to check, use {@link #containsSubsequence(Object...) containsSubsequence(Object...)} instead.
341363
*
342364
* @param sequence the sequence of objects to look for.
343365
* @return this assertion object.
@@ -362,6 +384,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
362384
* // assertion will fail
363385
* assertThat(elvesRings).doesNotContainSubsequence(vilya, nenya);
364386
* assertThat(elvesRings).doesNotContainSubsequence(vilya, narya);</code></pre>
387+
* <p>
388+
* If you want to specify the subsequence not to find with an {@link Iterable}, use {@link #doesNotContainSubsequence(Iterable) doesNotContainSubsequence(Iterable)} instead.
365389
*
366390
* @param sequence the sequence of objects to look for.
367391
* @return this assertion object.
@@ -385,6 +409,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
385409
* // assertion will fail
386410
* assertThat(elvesRings).doesNotContainSubsequence(newArrayList(vilya, nenya));
387411
* assertThat(elvesRings).doesNotContainSubsequence(newArrayList(vilya, narya));</code></pre>
412+
* <p>
413+
* If you want to directly specify the elements of the subsequence not to find, use {@link #doesNotContainSubsequence(Object...) doesNotContainSubsequence(Object...)} instead.
388414
*
389415
* @param sequence the sequence of objects to look for.
390416
* @return this assertion object.
@@ -409,6 +435,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
409435
* assertThat(abc).doesNotContain("a");
410436
* assertThat(abc).doesNotContain("a", "b");
411437
* assertThat(abc).doesNotContain("c", "d");</code></pre>
438+
* <p>
439+
* If you want to specify the elements not to find with an {@link Iterable}, use {@link #doesNotContainAnyElementsOf(Iterable) doesNotContainAnyElementsOf(Iterable)} instead.
412440
*
413441
* @param values the given values.
414442
* @return {@code this} assertion object.
@@ -870,6 +898,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
870898
* // assertions will fail
871899
* assertThat(abc).containsAll(Arrays.asList("d"));
872900
* assertThat(abc).containsAll(Arrays.asList("a", "b", "c", "d"));</code></pre>
901+
* <p>
902+
* If you want to directly specify the elements to check, use {@link #contains(Object...) contains(Object...)} instead.
873903
*
874904
* @param iterable the given {@code Iterable} we will get elements from.
875905
* @return {@code this} assertion object.
@@ -975,6 +1005,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
9751005
*
9761006
* // assertion will fail as actual and expected order differ
9771007
* assertThat(elvesRings).containsExactlyElementsOf(newLinkedList(nenya, vilya, narya));</code></pre>
1008+
* <p>
1009+
* If you want to directly specify the elements to check, use {@link #containsExactly(Object...) containsExactly(Object...)} instead.
9781010
*
9791011
* @param iterable the given {@code Iterable} we will get elements from.
9801012
*
@@ -999,6 +1031,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
9991031
* assertThat(rings).containsOnlyElementsOf(newLinkedList(nenya, vilya, narya));
10001032
* // assertion will fail as actual contains nenya
10011033
* assertThat(rings).containsOnlyElementsOf(newLinkedList(vilya));</code></pre>
1034+
* <p>
1035+
* If you want to directly specify the elements to check, use {@link #containsOnly(Object...) containsOnly(Object...)} instead.
10021036
*
10031037
* @param iterable the given {@code Iterable} we will get elements from.
10041038
*
@@ -1041,6 +1075,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
10411075
*
10421076
* // assertion fails:
10431077
* assertThat(actual).doesNotContainAnyElementsOf(newArrayList("d", "e", "a"));</code></pre>
1078+
* <p>
1079+
* If you want to directly specify the elements not to find, use {@link #doesNotContain(Object...) doesNotContain(Object...)} instead.
10441080
*
10451081
* @param iterable the {@link Iterable} whose elements must not be in the actual group.
10461082
* @return {@code this} assertion object.
@@ -1064,6 +1100,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
10641100
*
10651101
* // assertion will fail:
10661102
* assertThat(elvesRings).isSubsetOf(newArrayList(nenya, narya));</code></pre>
1103+
* <p>
1104+
* If you want to directly specify the set of elements, use {@link #isSubsetOf(Object...) isSubsetOf(Object...)} instead.
10671105
*
10681106
* @param values the {@code Iterable} that should contain all actual elements.
10691107
* @return this assertion object.
@@ -1087,6 +1125,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
10871125
* // assertions will fail:
10881126
* assertThat(elvesRings).isSubsetOf(vilya, nenya);
10891127
* assertThat(elvesRings).isSubsetOf(vilya, nenya, dwarfRing);</code></pre>
1128+
* <p>
1129+
* If you want to specify the set of elements an {@link Iterable}, use {@link #isSubsetOf(Iterable) isSubsetOf(Iterable)} instead.
10901130
*
10911131
* @param values the values that should be used for checking the elements of actual.
10921132
* @return this assertion object.
@@ -1111,6 +1151,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
11111151
* // assertions will fail
11121152
* assertThat(abc).containsAnyOf("d");
11131153
* assertThat(abc).containsAnyOf("d", "e", "f", "g");</code></pre>
1154+
* <p>
1155+
* If you want to specify the elements to check with an {@link Iterable}, use {@link #containsAnyElementsOf(Iterable) containsAnyElementsOf(Iterable)} instead.
11141156
*
11151157
* @param values the values whose at least one which is expected to be in the {@code Iterable} under test.
11161158
* @return {@code this} assertion object.
@@ -1138,6 +1180,8 @@ public interface ObjectEnumerableAssert<SELF extends ObjectEnumerableAssert<SELF
11381180
* // assertions will fail
11391181
* assertThat(abc).containsAnyElementsOf(Arrays.asList("d"));
11401182
* assertThat(abc).containsAnyElementsOf(Arrays.asList("d", "e", "f", "g"));</code></pre>
1183+
* <p>
1184+
* If you want to directly specify the elements to check, use {@link #containsAnyOf(Object...) containsAnyOf(Object...)} instead.
11411185
*
11421186
* @param iterable the iterable whose at least one element is expected to be in the {@code Iterable} under test.
11431187
* @return {@code this} assertion object.

0 commit comments

Comments
 (0)