How to use compare method of org.assertj.core.api.AtomicReferenceArrayAssert class

Best Assertj code snippet using org.assertj.core.api.AtomicReferenceArrayAssert.compare

Source:AtomicReferenceArrayAssert.java Github

copy

Full Screen

...195 *196 * // assertion will fail197 * assertThat(abc).hasSameSizeAs(sevenEight);</code></pre>198 *199 * @param other the array to compare size with actual AtomicReferenceArray.200 * @return {@code this} assertion object.201 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.202 * @throws AssertionError if the array parameter is {@code null} or is not a true array.203 * @throws AssertionError if actual AtomicReferenceArray and given array don't have the same size.204 * @since 2.7.0 / 3.7.0205 */206 @Override207 public AtomicReferenceArrayAssert<T> hasSameSizeAs(Object other) {208 arrays.assertHasSameSizeAs(info, array, other);209 return myself;210 }211 /**212 * Verifies that the actual AtomicReferenceArray has the same size as the given {@link Iterable}.213 * <p>214 * Example:215 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});216 * Iterable&lt;Ring&gt; elvesRings = newArrayList(vilya, nenya, narya);217 *218 * // assertion will pass219 * assertThat(abc).hasSameSizeAs(elvesRings);220 * 221 * // assertion will fail222 * assertThat(abc).hasSameSizeAs(Arrays.asList("a", "b"));</code></pre>223 *224 * @param other the {@code Iterable} to compare size with actual AtomicReferenceArray.225 * @return {@code this} assertion object.226 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.227 * @throws AssertionError if the other {@code Iterable} is {@code null}.228 * @throws AssertionError if actual AtomicReferenceArray and given {@code Iterable} don't have the same size.229 * @since 2.7.0 / 3.7.0230 */231 @Override232 public AtomicReferenceArrayAssert<T> hasSameSizeAs(Iterable<?> other) {233 arrays.assertHasSameSizeAs(info, array, other);234 return myself;235 }236 /**237 * Verifies that the actual AtomicReferenceArray contains the given values, in any order.238 * <p>239 * Example :240 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});241 *242 * // assertions will pass243 * assertThat(abc).contains("b", "a")244 * .contains("b", "a", "b");245 *246 * // assertions will fail247 * assertThat(abc).contains("d");248 * assertThat(abc).contains("c", "d");</code></pre>249 *250 * @param values the given values.251 * @return {@code this} assertion object.252 * @throws NullPointerException if the given argument is {@code null}.253 * @throws IllegalArgumentException if the given argument is an empty array.254 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.255 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values.256 * @since 2.7.0 / 3.7.0257 */258 @Override259 public AtomicReferenceArrayAssert<T> contains(@SuppressWarnings("unchecked") T... values) {260 arrays.assertContains(info, array, values);261 return myself;262 }263 /**264 * Verifies that the actual AtomicReferenceArray contains only the given values and nothing else, <b>in any order</b>.265 * <p>266 * Example :267 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});268 *269 * // assertions will pass270 * assertThat(abc).containsOnly("c", "b", "a")271 * .containsOnly("a", "a", "b", "c", "c");272 *273 * // assertion will fail because "c" is missing from the given values274 * assertThat(abc).containsOnly("a", "b");275 * // assertion will fail because abc does not contain "d"276 * assertThat(abc).containsOnly("a", "b", "c", "d");</code></pre>277 *278 * @param values the given values.279 * @return {@code this} assertion object.280 * @throws NullPointerException if the given argument is {@code null}.281 * @throws IllegalArgumentException if the given argument is an empty array.282 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.283 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values, i.e. the actual AtomicReferenceArray contains some284 * or none of the given values, or the actual AtomicReferenceArray contains more values than the given ones.285 * @since 2.7.0 / 3.7.0286 */287 @Override288 public AtomicReferenceArrayAssert<T> containsOnly(@SuppressWarnings("unchecked") T... values) {289 arrays.assertContainsOnly(info, array, values);290 return myself;291 }292 /**293 * Same semantic as {@link #containsOnly(Object[])} : verifies that actual contains all elements of the given294 * {@code Iterable} and nothing else, <b>in any order</b>.295 * <p>296 * Example :297 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; rings = new AtomicReferenceArray&lt;&gt;(new Ring[]{nenya, vilya});298 *299 * // assertions will pass300 * assertThat(rings).containsOnlyElementsOf(newArrayList(nenya, vilya))301 * .containsOnlyElementsOf(newArrayList(nenya, nenya, vilya, vilya));302 *303 * // assertion will fail as actual does not contain narya304 * assertThat(rings).containsOnlyElementsOf(newArrayList(nenya, vilya, narya));305 * // assertion will fail as actual contains nenya306 * assertThat(rings).containsOnlyElementsOf(newArrayList(vilya));</code></pre>307 *308 * @param iterable the given {@code Iterable} we will get elements from.309 * @since 2.7.0 / 3.7.0310 */311 @Override312 public AtomicReferenceArrayAssert<T> containsOnlyElementsOf(Iterable<? extends T> iterable) {313 return containsOnly(toArray(iterable));314 }315 /**316 * Verifies that the actual AtomicReferenceArray contains only null elements and nothing else.317 * <p>318 * Example :319 * <pre><code class='java'> // assertion will pass320 * AtomicReferenceArray&lt;String&gt; items = new AtomicReferenceArray&lt;&gt;(new String[]{null, null, null});321 * assertThat(items).containsOnlyNulls();322 *323 * // assertion will fail because items2 contains not null element324 * AtomicReferenceArray&lt;String&gt; items2 = new AtomicReferenceArray&lt;&gt;(new String[]{null, null, "notNull"});325 * assertThat(items2).containsOnlyNulls();326 * 327 * // assertion will fail since an empty array does not contain any element and therefore no null ones.328 * AtomicReferenceArray&lt;String&gt; empty = new AtomicReferenceArray&lt;&gt;(new String[0]);329 * assertThat(empty).containsOnlyNulls();</code></pre>330 *331 * @return {@code this} assertion object.332 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.333 * @throws AssertionError if the actual AtomicReferenceArray is empty or contains non null elements.334 * @since 2.9.0 / 3.9.0335 */336 @Override337 public AtomicReferenceArrayAssert<T> containsOnlyNulls() {338 arrays.assertContainsOnlyNulls(info, array);339 return myself;340 }341 /**342 * An alias of {@link #containsOnlyElementsOf(Iterable)} : verifies that actual contains all elements of the343 * given {@code Iterable} and nothing else, <b>in any order</b>.344 * <p>345 * Example:346 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});347 *348 * // assertions will pass:349 * assertThat(elvesRings).hasSameElementsAs(newArrayList(nenya, narya, vilya))350 * .hasSameElementsAs(newArrayList(nenya, narya, vilya, nenya));351 *352 * // assertions will fail:353 * assertThat(elvesRings).hasSameElementsAs(newArrayList(nenya, narya));354 * assertThat(elvesRings).hasSameElementsAs(newArrayList(nenya, narya, vilya, oneRing));</code></pre>355 *356 * @param iterable the {@code Iterable} whose elements we expect to be present357 * @return this assertion object358 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}359 * @throws NullPointerException if the given {@code Iterable} is {@code null}360 * @throws AssertionError if the actual {@code Iterable} does not have the same elements, in any order, as the given361 * {@code Iterable}362 * @since 2.7.0 / 3.7.0363 */364 @Override365 public AtomicReferenceArrayAssert<T> hasSameElementsAs(Iterable<? extends T> iterable) {366 return containsOnlyElementsOf(iterable);367 }368 /**369 * Verifies that the actual AtomicReferenceArray contains the given values only once.370 * <p>371 * Examples :372 * <pre><code class='java'> // array is a factory method to create arrays.373 * AtomicReferenceArray&lt;String&gt; got = new AtomicReferenceArray&lt;&gt;(new String[]{&quot;winter&quot;, &quot;is&quot;, &quot;coming&quot;});374 *375 * // assertions will pass376 * assertThat(got).containsOnlyOnce(&quot;winter&quot;)377 * .containsOnlyOnce(&quot;coming&quot;, &quot;winter&quot;);378 *379 * // assertions will fail380 * AtomicReferenceArray&lt;String&gt; stark= new AtomicReferenceArray&lt;&gt;(new String[]{&quot;Arya&quot;, &quot;Stark&quot;, &quot;daughter&quot;, &quot;of&quot;, &quot;Ned&quot;, &quot;Stark&quot;)});381 * assertThat(got).containsOnlyOnce(&quot;Lannister&quot;);382 * assertThat(stark).containsOnlyOnce(&quot;Stark&quot;);</code></pre>383 *384 * @param values the given values.385 * @return {@code this} assertion object.386 * @throws NullPointerException if the given argument is {@code null}.387 * @throws IllegalArgumentException if the given argument is an empty array.388 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.389 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values, i.e. the actual AtomicReferenceArray contains some390 * or none of the given values, or the actual AtomicReferenceArray contains more than once these values.391 * @since 2.7.0 / 3.7.0392 */393 @Override394 public AtomicReferenceArrayAssert<T> containsOnlyOnce(@SuppressWarnings("unchecked") T... values) {395 arrays.assertContainsOnlyOnce(info, array, values);396 return myself;397 }398 /**399 * Verifies that the actual AtomicReferenceArray contains only the given values and nothing else, <b>in order</b>.<br>400 * <p>401 * Example :402 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});403 *404 * // assertion will pass405 * assertThat(elvesRings).containsExactly(vilya, nenya, narya);406 *407 * // assertion will fail as actual and expected order differ408 * assertThat(elvesRings).containsExactly(nenya, vilya, narya);</code></pre>409 *410 * @param values the given values.411 * @return {@code this} assertion object.412 * @throws NullPointerException if the given argument is {@code null}.413 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.414 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values with same order, i.e. the actual AtomicReferenceArray415 * contains some or none of the given values, or the actual AtomicReferenceArray contains more values than the given ones416 * or values are the same but the order is not.417 * @since 2.7.0 / 3.7.0418 */419 @Override420 public AtomicReferenceArrayAssert<T> containsExactly(@SuppressWarnings("unchecked") T... values) {421 arrays.assertContainsExactly(info, array, values);422 return myself;423 }424 /**425 * Verifies that the actual AtomicReferenceArray contains exactly the given values and nothing else, <b>in any order</b>.<br>426 *427 * <p>428 * Example :429 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});430 *431 * // assertion will pass432 * assertThat(elvesRings).containsExactlyInAnyOrder(vilya, vilya, nenya, narya);433 *434 * // assertion will fail as vilya is contained twice in elvesRings.435 * assertThat(elvesRings).containsExactlyInAnyOrder(nenya, vilya, narya);</code></pre>436 *437 * @param values the given values.438 * @return {@code this} assertion object.439 * @throws NullPointerException if the given argument is {@code null}.440 * @throws AssertionError if the actual group is {@code null}.441 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values, i.e. it442 * contains some or none of the given values, or more values than the given ones.443 */444 @Override445 public AtomicReferenceArrayAssert<T> containsExactlyInAnyOrder(@SuppressWarnings("unchecked") T... values) {446 arrays.assertContainsExactlyInAnyOrder(info, array, values);447 return myself;448 }449 /**450 * Verifies that the actual AtomicReferenceArray contains exactly the given values and nothing else, <b>in any order</b>.<br>451 *452 * <p>453 * Example :454 * <pre><code class='java'>455 * AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray(new Ring[]{vilya, nenya, narya, vilya});456 * AtomicReferenceArray&lt;Ring&gt; elvesRingsSomeMissing = new AtomicReferenceArray(new Ring[]{vilya, nenya, narya});457 * AtomicReferenceArray&lt;Ring&gt; elvesRingsDifferentOrder = new AtomicReferenceArray(new Ring[]{nenya, narya, vilya, vilya});458 *459 * // assertion will pass460 * assertThat(elvesRings).containsExactlyInAnyOrder(elvesRingsDifferentOrder);461 *462 * // assertion will fail as vilya is contained twice in elvesRings.463 * assertThat(elvesRings).containsExactlyInAnyOrder(elvesRingsSomeMissing);</code></pre>464 *465 * @param values the given values.466 * @return {@code this} assertion object.467 * @throws NullPointerException if the given argument is {@code null}.468 * @throws AssertionError if the actual group is {@code null}.469 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group470 * contains some or none of the given values, or the actual group contains more values than the given ones.471 * @since 2.9.0 / 3.9.0472 */473 @Override474 public AtomicReferenceArrayAssert<T> containsExactlyInAnyOrderElementsOf(Iterable<? extends T> values) {475 return containsExactlyInAnyOrder(toArray(values));476 }477 /**478 * Same as {@link #containsExactly(Object...)} but handles the {@link Iterable} to array conversion : verifies that479 * actual contains all elements of the given {@code Iterable} and nothing else <b>in the same order</b>.480 * <p>481 * Example :482 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});483 *484 * // assertion will pass485 * assertThat(elvesRings).containsExactlyElementsOf(newLinkedList(vilya, nenya, narya));486 *487 * // assertion will fail as actual and expected order differ488 * assertThat(elvesRings).containsExactlyElementsOf(newLinkedList(nenya, vilya, narya));</code></pre>489 *490 * @param iterable the given {@code Iterable} we will get elements from.491 */492 @Override493 public AtomicReferenceArrayAssert<T> containsExactlyElementsOf(Iterable<? extends T> iterable) {494 return containsExactly(toArray(iterable));495 }496 /**497 * Verifies that the actual AtomicReferenceArray contains the given sequence in the correct order and <b>without extra values between the sequence values</b>.498 * <p>499 * Use {@link #containsSubsequence(Object...)} to allow values between the expected sequence values.500 * <p>501 * Example:502 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});503 *504 * // assertion will pass505 * assertThat(elvesRings).containsSequence(vilya, nenya)506 * .containsSequence(nenya, narya);507 *508 * // assertions will fail, the elements order is correct but there is a value between them (nenya)509 * assertThat(elvesRings).containsSequence(vilya, narya);510 * assertThat(elvesRings).containsSequence(nenya, vilya);</code></pre>511 *512 * @param sequence the sequence of objects to look for.513 * @return this assertion object.514 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.515 * @throws AssertionError if the given array is {@code null}.516 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given sequence.517 */518 @Override519 public AtomicReferenceArrayAssert<T> containsSequence(@SuppressWarnings("unchecked") T... sequence) {520 arrays.assertContainsSequence(info, array, sequence);521 return myself;522 }523 /**524 * Verifies that the actual AtomicReferenceArray contains the given sequence in the correct order and <b>without extra values between the sequence values</b>.525 * <p>526 * Use {@link #containsSubsequence(Object...)} to allow values between the expected sequence values.527 * <p>528 * Example:529 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});530 *531 * // assertion will pass532 * assertThat(elvesRings).containsSequence(newArrayList(vilya, nenya))533 * .containsSequence(newArrayList(nenya, narya));534 *535 * // assertions will fail, the elements order is correct but there is a value between them (nenya)536 * assertThat(elvesRings).containsSequence(newArrayList(vilya, narya));537 * assertThat(elvesRings).containsSequence(newArrayList(nenya, vilya));</code></pre>538 *539 * @param sequence the sequence of objects to look for.540 * @return this assertion object.541 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.542 * @throws AssertionError if the given array is {@code null}.543 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given sequence.544 */545 @Override546 public AtomicReferenceArrayAssert<T> containsSequence(Iterable<? extends T> sequence) {547 checkSequenceIsNotNull(sequence);548 arrays.assertContainsSequence(info, array, toArray(sequence));549 return myself;550 }551 /**552 * Verifies that the actual AtomicReferenceArray contains the given sequence in the given order and <b>without extra values between the sequence values</b>.553 * <p>554 * Use {@link #doesNotContainSubsequence(Object...)} to also ensure the sequence does not exist with values between the expected sequence values.555 * <p>556 * Example:557 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});558 *559 * // assertion will pass, the elements order is correct but there is a value between them (nenya)560 * assertThat(elvesRings).containsSequence(vilya, narya);561 * assertThat(elvesRings).containsSequence(nenya, vilya);562 *563 * // assertions will fail564 * assertThat(elvesRings).containsSequence(vilya, nenya);565 * assertThat(elvesRings).containsSequence(nenya, narya);</code></pre>566 *567 * @param sequence the sequence of objects to look for.568 * @return this assertion object.569 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.570 * @throws AssertionError if the given array is {@code null}.571 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given sequence.572 */573 @Override574 public AtomicReferenceArrayAssert<T> doesNotContainSequence(@SuppressWarnings("unchecked") T... sequence) {575 arrays.assertDoesNotContainSequence(info, array, sequence);576 return myself;577 }578 /**579 * Verifies that the actual AtomicReferenceArray contains the given sequence in the given order and <b>without extra values between the sequence values</b>.580 * <p>581 * Use {@link #doesNotContainSubsequence(Iterable)} to also ensure the sequence does not exist with values between the expected sequence values.582 * <p>583 * Example:584 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});585 *586 * // assertion will pass, the elements order is correct but there is a value between them (nenya)587 * assertThat(elvesRings).containsSequence(newArrayList(vilya, narya));588 * assertThat(elvesRings).containsSequence(newArrayList(nenya, vilya));589 *590 * // assertions will fail591 * assertThat(elvesRings).containsSequence(newArrayList(vilya, nenya));592 * assertThat(elvesRings).containsSequence(newArrayList(nenya, narya));</code></pre>593 *594 * @param sequence the sequence of objects to look for.595 * @return this assertion object.596 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.597 * @throws AssertionError if the given array is {@code null}.598 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given sequence.599 */600 @Override601 public AtomicReferenceArrayAssert<T> doesNotContainSequence(Iterable<? extends T> sequence) {602 checkSequenceIsNotNull(sequence);603 arrays.assertDoesNotContainSequence(info, array, toArray(sequence));604 return myself;605 }606 /**607 * Verifies that the actual AtomicReferenceArray contains the given subsequence in the correct order (possibly with other values between them).608 * <p>609 * Example:610 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});611 *612 * // assertions will pass613 * assertThat(elvesRings).containsSubsequence(vilya, nenya)614 * .containsSubsequence(vilya, narya);615 *616 * // assertion will fail617 * assertThat(elvesRings).containsSubsequence(nenya, vilya);</code></pre>618 *619 * @param subsequence the subsequence of objects to look for.620 * @return this assertion object.621 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.622 * @throws AssertionError if the given array is {@code null}.623 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given subsequence.624 */625 @Override626 public AtomicReferenceArrayAssert<T> containsSubsequence(@SuppressWarnings("unchecked") T... subsequence) {627 arrays.assertContainsSubsequence(info, array, subsequence);628 return myself;629 }630 /**631 * Verifies that the actual AtomicReferenceArray contains the given subsequence in the correct order (possibly with other values between them).632 * <p>633 * Example:634 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});635 *636 * // assertions will pass637 * assertThat(elvesRings).containsSubsequence(newArrayList(vilya, nenya))638 * .containsSubsequence(newArrayList(vilya, narya));639 *640 * // assertion will fail641 * assertThat(elvesRings).containsSubsequence(newArrayList(nenya, vilya));</code></pre>642 *643 * @param subsequence the subsequence of objects to look for.644 * @return this assertion object.645 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.646 * @throws AssertionError if the given array is {@code null}.647 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given subsequence.648 */649 @Override650 public AtomicReferenceArrayAssert<T> containsSubsequence(Iterable<? extends T> subsequence) {651 checkSubsequenceIsNotNull(subsequence);652 arrays.assertContainsSubsequence(info, array, toArray(subsequence));653 return myself;654 }655 /**656 * Verifies that the actual AtomicReferenceArray does not contain the given subsequence in the correct order (possibly657 * with other values between them).658 * <p>659 * Example:660 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});661 *662 * // assertions will pass663 * assertThat(elvesRings).doesNotContainSubsequence(nenya, vilya);664 *665 * // assertion will fail666 * assertThat(elvesRings).doesNotContainSubsequence(vilya, nenya);667 * assertThat(elvesRings).doesNotContainSubsequence(vilya, narya);</code></pre>668 *669 * @param subsequence the subsequence of objects to look for.670 * @return this assertion object.671 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.672 * @throws AssertionError if the given array is {@code null}.673 * @throws AssertionError if the actual AtomicReferenceArray contains the given subsequence.674 */675 @Override676 public AtomicReferenceArrayAssert<T> doesNotContainSubsequence(@SuppressWarnings("unchecked") T... subsequence) {677 arrays.assertDoesNotContainSubsequence(info, array, subsequence);678 return myself;679 }680 /**681 * Verifies that the actual AtomicReferenceArray does not contain the given subsequence in the correct order (possibly682 * with other values between them).683 * <p>684 * Example:685 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});686 *687 * // assertions will pass688 * assertThat(elvesRings).doesNotContainSubsequence(newArrayList(nenya, vilya));689 *690 * // assertion will fail691 * assertThat(elvesRings).doesNotContainSubsequence(newArrayList(vilya, nenya));692 * assertThat(elvesRings).doesNotContainSubsequence(newArrayList(vilya, narya));</code></pre>693 *694 * @param subsequence the subsequence of objects to look for.695 * @return this assertion object.696 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.697 * @throws AssertionError if the given array is {@code null}.698 * @throws AssertionError if the actual AtomicReferenceArray contains the given subsequence.699 */700 @Override701 public AtomicReferenceArrayAssert<T> doesNotContainSubsequence(Iterable<? extends T> subsequence) {702 checkSubsequenceIsNotNull(subsequence);703 arrays.assertDoesNotContainSubsequence(info, array, toArray(subsequence));704 return myself;705 }706 /**707 * Verifies that the actual AtomicReferenceArray contains the given object at the given index.708 * <p>709 * Example:710 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});711 *712 * // assertions will pass713 * assertThat(elvesRings).contains(vilya, atIndex(0))714 * .contains(nenya, atIndex(1))715 * .contains(narya, atIndex(2));716 *717 * // assertions will fail718 * assertThat(elvesRings).contains(vilya, atIndex(1));719 * assertThat(elvesRings).contains(nenya, atIndex(2));720 * assertThat(elvesRings).contains(narya, atIndex(0));</code></pre>721 *722 * @param value the object to look for.723 * @param index the index where the object should be stored in the actual AtomicReferenceArray.724 * @return this assertion object.725 * @throws AssertionError if the actual AtomicReferenceArray is {@code null} or empty.726 * @throws NullPointerException if the given {@code Index} is {@code null}.727 * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual728 * AtomicReferenceArray.729 * @throws AssertionError if the actual AtomicReferenceArray does not contain the given object at the given index.730 */731 @Override732 public AtomicReferenceArrayAssert<T> contains(T value, Index index) {733 arrays.assertContains(info, array, value, index);734 return myself;735 }736 /**737 * Verifies that all elements of the actual group are instances of given classes or interfaces.738 * <p>739 * Example :740 * <pre><code class='java'> AtomicReferenceArray&lt;Object&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Object[]{"", new StringBuilder()});741 * 742 * // assertions will pass743 * assertThat(objects).hasOnlyElementsOfTypes(CharSequence.class);744 * assertThat(objects).hasOnlyElementsOfTypes(String.class, StringBuilder.class);745 * 746 * // assertions will fail747 * assertThat(objects).hasOnlyElementsOfTypes(Number.class);748 * assertThat(objects).hasOnlyElementsOfTypes(String.class, Number.class);749 * assertThat(objects).hasOnlyElementsOfTypes(String.class);</code></pre>750 * 751 * @param types the expected classes and interfaces752 * @return {@code this} assertion object.753 * @throws NullPointerException if the given argument is {@code null}.754 * @throws AssertionError if the actual group is {@code null}.755 * @throws AssertionError if not all elements of the actual group are instances of one of the given types756 * @since 2.7.0 / 3.7.0757 */758 @Override759 public AtomicReferenceArrayAssert<T> hasOnlyElementsOfTypes(Class<?>... types) {760 arrays.assertHasOnlyElementsOfTypes(info, array, types);761 return myself;762 }763 /**764 * Verifies that the actual AtomicReferenceArray does not contain the given object at the given index.765 * <p>766 * Example:767 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});768 *769 * // assertions will pass770 * assertThat(elvesRings).doesNotContain(vilya, atIndex(1))771 * .doesNotContain(nenya, atIndex(2))772 * .doesNotContain(narya, atIndex(0));773 *774 * // assertions will fail775 * assertThat(elvesRings).doesNotContain(vilya, atIndex(0));776 * assertThat(elvesRings).doesNotContain(nenya, atIndex(1));777 * assertThat(elvesRings).doesNotContain(narya, atIndex(2));</code></pre>778 *779 * @param value the object to look for.780 * @param index the index where the object should not be stored in the actual AtomicReferenceArray.781 * @return this assertion object.782 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.783 * @throws NullPointerException if the given {@code Index} is {@code null}.784 * @throws AssertionError if the actual AtomicReferenceArray contains the given object at the given index.785 */786 @Override787 public AtomicReferenceArrayAssert<T> doesNotContain(T value, Index index) {788 arrays.assertDoesNotContain(info, array, value, index);789 return myself;790 }791 /**792 * Verifies that the actual AtomicReferenceArray does not contain the given values.793 * <p>794 * Example :795 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});796 *797 * // assertion will pass798 * assertThat(abc).doesNotContain("d", "e");799 *800 * // assertions will fail801 * assertThat(abc).doesNotContain("a");802 * assertThat(abc).doesNotContain("a", "b", "c");803 * assertThat(abc).doesNotContain("a", "x");</code></pre>804 *805 * @param values the given values.806 * @return {@code this} assertion object.807 * @throws NullPointerException if the given argument is {@code null}.808 * @throws IllegalArgumentException if the given argument is an empty array.809 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.810 * @throws AssertionError if the actual AtomicReferenceArray contains any of the given values.811 */812 @Override813 public AtomicReferenceArrayAssert<T> doesNotContain(@SuppressWarnings("unchecked") T... values) {814 arrays.assertDoesNotContain(info, array, values);815 return myself;816 }817 /**818 * Verifies that the actual AtomicReferenceArray does not contain any elements of the given {@link Iterable} (i.e. none).819 * <p>820 * Example:821 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});822 *823 * // assertion will pass824 * assertThat(actual).doesNotContainAnyElementsOf(newArrayList("d", "e"));825 *826 * // assertions will fail827 * assertThat(actual).doesNotContainAnyElementsOf(newArrayList("a", "b"));828 * assertThat(actual).doesNotContainAnyElementsOf(newArrayList("d", "e", "a"));</code></pre>829 *830 * @param iterable the {@link Iterable} whose elements must not be in the actual AtomicReferenceArray.831 * @return {@code this} assertion object.832 * @throws NullPointerException if the given argument is {@code null}.833 * @throws IllegalArgumentException if the given argument is an empty iterable.834 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.835 * @throws AssertionError if the actual AtomicReferenceArray contains some elements of the given {@link Iterable}.836 */837 @Override838 public AtomicReferenceArrayAssert<T> doesNotContainAnyElementsOf(Iterable<? extends T> iterable) {839 arrays.assertDoesNotContainAnyElementsOf(info, array, iterable);840 return myself;841 }842 /**843 * Verifies that the actual AtomicReferenceArray does not contain duplicates.844 * <p>845 * Example :846 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});847 * AtomicReferenceArray&lt;String&gt; aaa = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "a", "a"});848 *849 * // assertion will pass850 * assertThat(abc).doesNotHaveDuplicates();851 *852 * // assertion will fail853 * assertThat(aaa).doesNotHaveDuplicates();</code></pre>854 *855 * @return {@code this} assertion object.856 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.857 * @throws AssertionError if the actual AtomicReferenceArray contains duplicates.858 */859 @Override860 public AtomicReferenceArrayAssert<T> doesNotHaveDuplicates() {861 arrays.assertDoesNotHaveDuplicates(info, array);862 return myself;863 }864 /**865 * Verifies that the actual AtomicReferenceArray starts with the given sequence of objects, without any other objects between them.866 * Similar to <code>{@link #containsSequence(Object...)}</code>, but it also verifies that the first element in the867 * sequence is also the first element of the actual AtomicReferenceArray.868 * <p>869 * Example :870 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});871 *872 * // assertion will pass873 * assertThat(abc).startsWith("a", "b");874 *875 * // assertion will fail876 * assertThat(abc).startsWith("c");</code></pre>877 *878 * @param sequence the sequence of objects to look for.879 * @return this assertion object.880 * @throws NullPointerException if the given argument is {@code null}.881 * @throws IllegalArgumentException if the given argument is an empty array.882 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.883 * @throws AssertionError if the actual AtomicReferenceArray does not start with the given sequence of objects.884 */885 @Override886 public AtomicReferenceArrayAssert<T> startsWith(@SuppressWarnings("unchecked") T... sequence) {887 arrays.assertStartsWith(info, array, sequence);888 return myself;889 }890 /**891 * Verifies that the actual AtomicReferenceArray ends with the given sequence of objects, without any other objects between them.892 * Similar to <code>{@link #containsSequence(Object...)}</code>, but it also verifies that the last element in the893 * sequence is also last element of the actual AtomicReferenceArray.894 * <p>895 * Example :896 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});897 *898 * // assertion will pass899 * assertThat(abc).endsWith("b", "c");900 *901 * // assertion will fail902 * assertThat(abc).endsWith("a");</code></pre>903 *904 * @param first the first element of the end sequence of objects to look for.905 * @param sequence the rest of the end sequence of objects to look for.906 * @return this assertion object.907 * @throws NullPointerException if the given argument is {@code null}.908 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.909 * @throws AssertionError if the actual AtomicReferenceArray does not end with the given sequence of objects.910 */911 @Override912 public AtomicReferenceArrayAssert<T> endsWith(T first, @SuppressWarnings("unchecked") T... sequence) {913 arrays.assertEndsWith(info, array, first, sequence);914 return myself;915 }916 /**917 * Verifies that the actual AtomicReferenceArray ends with the given sequence of objects, without any other objects between them.918 * Similar to <code>{@link #containsSequence(Object...)}</code>, but it also verifies that the last element in the919 * sequence is also last element of the actual AtomicReferenceArray.920 * <p>921 * Example :922 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});923 *924 * // assertions will pass925 * assertThat(abc).endsWith(new String[0])926 * .endsWith(new String[] {"b", "c"});927 *928 * // assertion will fail929 * assertThat(abc).endsWith(new String[] {"a"});</code></pre>930 *931 * @param sequence the (possibly empty) sequence of objects to look for.932 * @return this assertion object.933 * @throws NullPointerException if the given argument is {@code null}.934 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.935 * @throws AssertionError if the actual AtomicReferenceArray does not end with the given sequence of objects.936 */937 @Override938 public AtomicReferenceArrayAssert<T> endsWith(T[] sequence) {939 arrays.assertEndsWith(info, array, sequence);940 return myself;941 }942 /**943 * Verifies that all elements of actual are present in the given {@code Iterable}.944 * <p>945 * Example:946 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});947 * List&lt;Ring&gt; ringsOfPower = newArrayList(oneRing, vilya, nenya, narya, dwarfRing, manRing);948 *949 * // assertion will pass:950 * assertThat(elvesRings).isSubsetOf(ringsOfPower);951 *952 * // assertion will fail:953 * assertThat(elvesRings).isSubsetOf(newArrayList(nenya, narya));</code></pre>954 *955 * @param values the {@code Iterable} that should contain all actual elements.956 * @return this assertion object.957 * @throws AssertionError if the actual {@code Iterable} is {@code null}.958 * @throws NullPointerException if the given {@code Iterable} is {@code null}.959 * @throws AssertionError if the actual {@code Iterable} is not subset of set {@code Iterable}.960 */961 @Override962 public AtomicReferenceArrayAssert<T> isSubsetOf(Iterable<? extends T> values) {963 arrays.assertIsSubsetOf(info, array, values);964 return myself;965 }966 /**967 * Verifies that all elements of actual are present in the given values.968 * <p>969 * Example:970 * <pre><code class='java'> AtomicReferenceArray&lt;Ring&gt; elvesRings = new AtomicReferenceArray&lt;&gt;(new Ring[]{vilya, nenya, narya});971 *972 * // assertions will pass:973 * assertThat(elvesRings).isSubsetOf(vilya, nenya, narya)974 * .isSubsetOf(vilya, nenya, narya, dwarfRing);975 *976 * // assertions will fail:977 * assertThat(elvesRings).isSubsetOf(vilya, nenya);978 * assertThat(elvesRings).isSubsetOf(vilya, nenya, dwarfRing);</code></pre>979 *980 * @param values the values that should be used for checking the elements of actual.981 * @return this assertion object.982 * @throws AssertionError if the actual {@code Iterable} is {@code null}.983 * @throws AssertionError if the actual {@code Iterable} is not subset of the given values.984 */985 @Override986 public AtomicReferenceArrayAssert<T> isSubsetOf(@SuppressWarnings("unchecked") T... values) {987 arrays.assertIsSubsetOf(info, array, Arrays.asList(values));988 return myself;989 }990 /**991 * Verifies that the actual AtomicReferenceArray contains at least a null element.992 * <p>993 * Example :994 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});995 * AtomicReferenceArray&lt;String&gt; abNull = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", null});996 *997 * // assertion will pass998 * assertThat(abNull).containsNull();999 *1000 * // assertion will fail1001 * assertThat(abc).containsNull();</code></pre>1002 *1003 * @return {@code this} assertion object.1004 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.1005 * @throws AssertionError if the actual AtomicReferenceArray does not contain a null element.1006 */1007 @Override1008 public AtomicReferenceArrayAssert<T> containsNull() {1009 arrays.assertContainsNull(info, array);1010 return myself;1011 }1012 /**1013 * Verifies that the actual AtomicReferenceArray does not contain null elements.1014 * <p>1015 * Example :1016 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});1017 * AtomicReferenceArray&lt;String&gt; abNull = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", null});1018 *1019 * // assertion will pass1020 * assertThat(abc).doesNotContainNull();1021 *1022 * // assertion will fail1023 * assertThat(abNull).doesNotContainNull();</code></pre>1024 *1025 * @return {@code this} assertion object.1026 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.1027 * @throws AssertionError if the actual AtomicReferenceArray contains a null element.1028 */1029 @Override1030 public AtomicReferenceArrayAssert<T> doesNotContainNull() {1031 arrays.assertDoesNotContainNull(info, array);1032 return myself;1033 }1034 /**1035 * Verifies that each element value satisfies the given condition1036 * <p>1037 * Example :1038 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});1039 * AtomicReferenceArray&lt;String&gt; abcc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "cc"});1040 *1041 * Condition&lt;String&gt; singleCharacterString1042 * = new Condition&lt;&gt;(s -&gt; s.length() == 1, "single character String");1043 *1044 * // assertion will pass1045 * assertThat(abc).are(singleCharacterString);1046 *1047 * // assertion will fail1048 * assertThat(abcc).are(singleCharacterString);</code></pre>1049 *1050 * @param condition the given condition.1051 * @return {@code this} object.1052 * @throws NullPointerException if the given condition is {@code null}.1053 * @throws AssertionError if an element cannot be cast to T.1054 * @throws AssertionError if one or more elements don't satisfy the given condition.1055 */1056 @Override1057 public AtomicReferenceArrayAssert<T> are(Condition<? super T> condition) {1058 arrays.assertAre(info, array, condition);1059 return myself;1060 }1061 /**1062 * Verifies that each element value does not satisfy the given condition1063 * <p>1064 * Example :1065 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});1066 * AtomicReferenceArray&lt;String&gt; abcc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "cc"});1067 *1068 * Condition&lt;String&gt; moreThanOneCharacter =1069 * = new Condition&lt;&gt;(s -&gt; s.length() &gt; 1, "more than one character");1070 *1071 * // assertion will pass1072 * assertThat(abc).areNot(moreThanOneCharacter);1073 *1074 * // assertion will fail1075 * assertThat(abcc).areNot(moreThanOneCharacter);</code></pre>1076 *1077 * @param condition the given condition.1078 * @return {@code this} object.1079 * @throws NullPointerException if the given condition is {@code null}.1080 * @throws AssertionError if an element cannot be cast to T.1081 * @throws AssertionError if one or more elements satisfy the given condition.1082 */1083 @Override1084 public AtomicReferenceArrayAssert<T> areNot(Condition<? super T> condition) {1085 arrays.assertAreNot(info, array, condition);1086 return myself;1087 }1088 /**1089 * Verifies that all elements satisfy the given condition.1090 * <p>1091 * Example :1092 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});1093 * AtomicReferenceArray&lt;String&gt; abcc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "cc"});1094 *1095 * Condition&lt;String&gt; onlyOneCharacter =1096 * = new Condition&lt;&gt;(s -&gt; s.length() == 1, "only one character");1097 *1098 * // assertion will pass1099 * assertThat(abc).have(onlyOneCharacter);1100 *1101 * // assertion will fail1102 * assertThat(abcc).have(onlyOneCharacter);</code></pre>1103 *1104 * @param condition the given condition.1105 * @return {@code this} object.1106 * @throws NullPointerException if the given condition is {@code null}.1107 * @throws AssertionError if an element cannot be cast to T.1108 * @throws AssertionError if one or more elements do not satisfy the given condition.1109 */1110 @Override1111 public AtomicReferenceArrayAssert<T> have(Condition<? super T> condition) {1112 arrays.assertHave(info, array, condition);1113 return myself;1114 }1115 /**1116 * Verifies that all elements don't satisfy the given condition.1117 * <p>1118 * Example :1119 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});1120 * AtomicReferenceArray&lt;String&gt; abcc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "cc"});1121 *1122 * Condition&lt;String&gt; moreThanOneCharacter =1123 * = new Condition&lt;&gt;(s -&gt; s.length() &gt; 1, "more than one character");1124 *1125 * // assertion will pass1126 * assertThat(abc).doNotHave(moreThanOneCharacter);1127 *1128 * // assertion will fail1129 * assertThat(abcc).doNotHave(moreThanOneCharacter);</code></pre>1130 *1131 * @param condition the given condition.1132 * @return {@code this} object.1133 * @throws NullPointerException if the given condition is {@code null}.1134 * @throws AssertionError if an element cannot be cast to T.1135 * @throws AssertionError if one or more elements satisfy the given condition.1136 */1137 @Override1138 public AtomicReferenceArrayAssert<T> doNotHave(Condition<? super T> condition) {1139 arrays.assertDoNotHave(info, array, condition);1140 return myself;1141 }1142 /**1143 * Verifies that there are <b>at least</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition.1144 * <p>1145 * Example :1146 * <pre><code class='java'> AtomicReferenceArray&lt;Integer&gt; oneThwoThree = new AtomicReferenceArray&lt;&gt;(new Integer[]{1, 2, 3});1147 *1148 * Condition&lt;Integer&gt; oddNumber = new Condition&lt;&gt;(value % 2 == 1, "odd number");1149 *1150 * // assertion will pass1151 * oneThwoThree.areAtLeast(2, oddNumber);1152 *1153 * // assertion will fail1154 * oneThwoThree.areAtLeast(3, oddNumber);</code></pre>1155 *1156 * @param times the minimum number of times the condition should be verified.1157 * @param condition the given condition.1158 * @return {@code this} object.1159 * @throws NullPointerException if the given condition is {@code null}.1160 * @throws AssertionError if an element can not be cast to T.1161 * @throws AssertionError if the number of elements satisfying the given condition is &lt; n.1162 */1163 @Override1164 public AtomicReferenceArrayAssert<T> areAtLeast(int times, Condition<? super T> condition) {1165 arrays.assertAreAtLeast(info, array, times, condition);1166 return myself;1167 }1168 /**1169 * Verifies that there is <b>at least <i>one</i></b> element in the actual AtomicReferenceArray satisfying the given condition.1170 * <p>1171 * This method is an alias for {@code areAtLeast(1, condition)}.1172 * <p>1173 * Example:1174 * <pre><code class='java'> // jedi is a Condition&lt;String&gt;1175 * AtomicReferenceArray&lt;String&gt; rebels = new AtomicReferenceArray&lt;&gt;(new String[]{"Luke", "Solo", "Leia"});1176 * 1177 * assertThat(rebels).areAtLeastOne(jedi);</code></pre>1178 *1179 * @see #haveAtLeast(int, Condition)1180 */1181 @Override1182 public AtomicReferenceArrayAssert<T> areAtLeastOne(Condition<? super T> condition) {1183 areAtLeast(1, condition);1184 return myself;1185 }1186 /**1187 * Verifies that there are <b>at most</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition.1188 * <p>1189 * Example :1190 * <pre><code class='java'> AtomicReferenceArray&lt;Integer&gt; oneThwoThree = new AtomicReferenceArray&lt;&gt;(new Integer[]{1, 2, 3});1191 *1192 * Condition&lt;Integer&gt; oddNumber = new Condition&lt;&gt;(value % 2 == 1, "odd number");1193 *1194 * // assertions will pass1195 * oneThwoThree.areAtMost(2, oddNumber);1196 * oneThwoThree.areAtMost(3, oddNumber);1197 *1198 * // assertion will fail1199 * oneThwoThree.areAtMost(1, oddNumber);</code></pre>1200 *1201 * @param times the number of times the condition should be at most verified.1202 * @param condition the given condition.1203 * @return {@code this} object.1204 * @throws NullPointerException if the given condition is {@code null}.1205 * @throws AssertionError if an element cannot be cast to T.1206 * @throws AssertionError if the number of elements satisfying the given condition is &gt; n.1207 */1208 @Override1209 public AtomicReferenceArrayAssert<T> areAtMost(int times, Condition<? super T> condition) {1210 arrays.assertAreAtMost(info, array, times, condition);1211 return myself;1212 }1213 /**1214 * Verifies that there are <b>exactly</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition.1215 * <p>1216 * Example :1217 * <pre><code class='java'> AtomicReferenceArray&lt;Integer&gt; oneThwoThree = new AtomicReferenceArray&lt;&gt;(new Integer[]{1, 2, 3});1218 *1219 * Condition&lt;Integer&gt; oddNumber = new Condition&lt;&gt;(value % 2 == 1, "odd number");1220 *1221 * // assertion will pass1222 * oneThwoThree.areExactly(2, oddNumber);1223 *1224 * // assertions will fail1225 * oneThwoThree.areExactly(1, oddNumber);1226 * oneThwoThree.areExactly(3, oddNumber);</code></pre>1227 *1228 * @param times the exact number of times the condition should be verified.1229 * @param condition the given condition.1230 * @return {@code this} object.1231 * @throws NullPointerException if the given condition is {@code null}.1232 * @throws AssertionError if an element cannot be cast to T.1233 * @throws AssertionError if the number of elements satisfying the given condition is &ne; n.1234 */1235 @Override1236 public AtomicReferenceArrayAssert<T> areExactly(int times, Condition<? super T> condition) {1237 arrays.assertAreExactly(info, array, times, condition);1238 return myself;1239 }1240 /**1241 * Verifies that there is <b>at least <i>one</i></b> element in the actual AtomicReferenceArray satisfying the given condition.1242 * <p>1243 * This method is an alias for {@code haveAtLeast(1, condition)}.1244 * <p>1245 * Example:1246 * <pre><code class='java'> AtomicReferenceArray&lt;BasketBallPlayer&gt; bullsPlayers = new AtomicReferenceArray&lt;&gt;(new BasketBallPlayer[]{butler, rose});1247 *1248 * // potentialMvp is a Condition&lt;BasketBallPlayer&gt;1249 * assertThat(bullsPlayers).haveAtLeastOne(potentialMvp);</code></pre>1250 *1251 * @see #haveAtLeast(int, Condition)1252 */1253 @Override1254 public AtomicReferenceArrayAssert<T> haveAtLeastOne(Condition<? super T> condition) {1255 return haveAtLeast(1, condition);1256 }1257 /**1258 * Verifies that there are <b>at least <i>n</i></b> elements in the actual AtomicReferenceArray satisfying the given condition.1259 * <p>1260 * Example :1261 * <pre><code class='java'> AtomicReferenceArray&lt;Integer&gt; oneThwoThree = new AtomicReferenceArray&lt;&gt;(new Integer[]{1, 2, 3});1262 *1263 * Condition&lt;Integer&gt; oddNumber = new Condition&lt;&gt;(value % 2 == 1, "odd number");1264 *1265 * // assertion will pass1266 * oneThwoThree.haveAtLeast(2, oddNumber);1267 *1268 * // assertion will fail1269 * oneThwoThree.haveAtLeast(3, oddNumber);</code></pre>1270 *1271 * This method is an alias for {@link #areAtLeast(int, Condition)}.1272 */1273 @Override1274 public AtomicReferenceArrayAssert<T> haveAtLeast(int times, Condition<? super T> condition) {1275 arrays.assertHaveAtLeast(info, array, times, condition);1276 return myself;1277 }1278 /**1279 * Verifies that there are <b>at most</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition.1280 * <p>1281 * Example :1282 * <pre><code class='java'> AtomicReferenceArray&lt;Integer&gt; oneThwoThree = new AtomicReferenceArray&lt;&gt;(new Integer[]{1, 2, 3});1283 *1284 * Condition&lt;Integer&gt; oddNumber = new Condition&lt;&gt;(value % 2 == 1, "odd number");1285 *1286 * // assertions will pass1287 * oneThwoThree.haveAtMost(2, oddNumber);1288 * oneThwoThree.haveAtMost(3, oddNumber);1289 *1290 * // assertion will fail1291 * oneThwoThree.haveAtMost(1, oddNumber);</code></pre>1292 *1293 * This method is an alias {@link #areAtMost(int, Condition)}.1294 */1295 @Override1296 public AtomicReferenceArrayAssert<T> haveAtMost(int times, Condition<? super T> condition) {1297 arrays.assertHaveAtMost(info, array, times, condition);1298 return myself;1299 }1300 /**1301 * Verifies that there are <b>exactly</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition.1302 * <p>1303 * Example :1304 * <pre><code class='java'> AtomicReferenceArray&lt;Integer&gt; oneThwoThree = new AtomicReferenceArray&lt;&gt;(new Integer[]{1, 2, 3});1305 *1306 * Condition&lt;Integer&gt; oddNumber = new Condition&lt;&gt;(value % 2 == 1, "odd number");1307 *1308 * // assertion will pass1309 * oneThwoThree.haveExactly(2, oddNumber);1310 *1311 * // assertions will fail1312 * oneThwoThree.haveExactly(1, oddNumber);1313 * oneThwoThree.haveExactly(3, oddNumber);</code></pre>1314 *1315 * This method is an alias {@link #areExactly(int, Condition)}.1316 */1317 @Override1318 public AtomicReferenceArrayAssert<T> haveExactly(int times, Condition<? super T> condition) {1319 arrays.assertHaveExactly(info, array, times, condition);1320 return myself;1321 }1322 /**1323 * Verifies that at least one element in the actual AtomicReferenceArray has the specified type (matching1324 * includes subclasses of the given type).1325 * <p>1326 * Example:1327 * <pre><code class='java'> AtomicReferenceArray&lt;Number&gt; numbers = new AtomicReferenceArray&lt;&gt;(new Number[]{ 2, 6L, 8.0 });1328 * 1329 * // successful assertion:1330 * assertThat(numbers).hasAtLeastOneElementOfType(Long.class);1331 * 1332 * // assertion failure:1333 * assertThat(numbers).hasAtLeastOneElementOfType(Float.class);</code></pre>1334 *1335 * @param expectedType the expected type.1336 * @return this assertion object.1337 * @throws NullPointerException if the given type is {@code null}.1338 * @throws AssertionError if the actual AtomicReferenceArray does not have any elements of the given type.1339 */1340 @Override1341 public AtomicReferenceArrayAssert<T> hasAtLeastOneElementOfType(Class<?> expectedType) {1342 arrays.assertHasAtLeastOneElementOfType(info, array, expectedType);1343 return myself;1344 }1345 /**1346 * Verifies that all the elements in the actual AtomicReferenceArray belong to the specified type (matching includes1347 * subclasses of the given type).1348 * <p>1349 * Example:1350 * <pre><code class='java'> AtomicReferenceArray&lt;Number&gt; numbers = new AtomicReferenceArray&lt;&gt;(new Number[]{ 2, 6, 8 });1351 * 1352 * // successful assertion:1353 * assertThat(numbers).hasOnlyElementsOfType(Integer.class);1354 * 1355 * // assertion failure:1356 * assertThat(numbers).hasOnlyElementsOfType(Long.class);</code></pre>1357 *1358 * @param expectedType the expected type.1359 * @return this assertion object.1360 * @throws NullPointerException if the given type is {@code null}.1361 * @throws AssertionError if one element is not of the expected type.1362 */1363 @Override1364 public AtomicReferenceArrayAssert<T> hasOnlyElementsOfType(Class<?> expectedType) {1365 arrays.assertHasOnlyElementsOfType(info, array, expectedType);1366 return myself;1367 }1368 /**1369 * Verifies that all the elements in the actual AtomicReferenceArray do not belong to the specified types (including subclasses).1370 * <p>1371 * Example:1372 * <pre><code class='java'> AtomicReferenceArray&lt;Number&gt; numbers = new AtomicReferenceArray&lt;&gt;(new Number[]{ 2, 6, 8.0 });1373 *1374 * // successful assertion:1375 * assertThat(numbers).doesNotHaveAnyElementsOfTypes(Long.class, Float.class);1376 *1377 * // assertion failure:1378 * assertThat(numbers).doesNotHaveAnyElementsOfTypes(Long.class, Integer.class);</code></pre>1379 *1380 * @param unexpectedTypes the not expected types.1381 * @return this assertion object.1382 * @throws NullPointerException if the given types is {@code null}.1383 * @throws AssertionError if one element's type matches the given types.1384 * @since 2.9.0 / 3.9.01385 */1386 @Override1387 public AtomicReferenceArrayAssert<T> doesNotHaveAnyElementsOfTypes(Class<?>... unexpectedTypes) {1388 arrays.assertDoesNotHaveAnyElementsOfTypes(info, array, unexpectedTypes);1389 return myself;1390 }1391 /** {@inheritDoc} */1392 @Override1393 public AtomicReferenceArrayAssert<T> isSorted() {1394 arrays.assertIsSorted(info, array);1395 return myself;1396 }1397 /** {@inheritDoc} */1398 @Override1399 public AtomicReferenceArrayAssert<T> isSortedAccordingTo(Comparator<? super T> comparator) {1400 arrays.assertIsSortedAccordingToComparator(info, array, comparator);1401 return myself;1402 }1403 /**1404 * Verifies that the actual AtomicReferenceArray contains all the elements of given {@code Iterable}, in any order.1405 * <p>1406 * Example :1407 * <pre><code class='java'> AtomicReferenceArray&lt;String&gt; abc = new AtomicReferenceArray&lt;&gt;(new String[]{"a", "b", "c"});1408 *1409 * // assertion will pass1410 * assertThat(abc).containsAll(Arrays.asList("b", "c"));1411 * 1412 * // assertions will fail1413 * assertThat(abc).containsAll(Arrays.asList("d"));1414 * assertThat(abc).containsAll(Arrays.asList("a", "b", "c", "d"));</code></pre>1415 *1416 * @param iterable the given {@code Iterable} we will get elements from.1417 * @return {@code this} assertion object.1418 * @throws NullPointerException if the given argument is {@code null}.1419 * @throws AssertionError if the actual AtomicReferenceArray is {@code null}.1420 * @throws AssertionError if the actual AtomicReferenceArray does not contain all the elements of given {@code Iterable}.1421 */1422 @Override1423 public AtomicReferenceArrayAssert<T> containsAll(Iterable<? extends T> iterable) {1424 arrays.assertContainsAll(info, array, iterable);1425 return myself;1426 }1427 /**1428 * Use given custom comparator instead of relying on actual element type <code>equals</code> method to compare AtomicReferenceArray1429 * elements for incoming assertion checks.1430 * <p>1431 * Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default1432 * comparison strategy.1433 * <p>1434 * Examples :1435 * <pre><code class='java'> // compares invoices by payee1436 * assertThat(invoiceArray).usingComparator(invoicePayeeComparator).isEqualTo(expectedinvoiceArray).1437 *1438 * // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator1439 * assertThat(invoiceArray).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice)1440 *1441 * // as assertThat(invoiceArray) creates a new assertion, it falls back to standard comparison strategy1442 * // based on Invoice's equal method to compare invoiceArray elements to lowestInvoice.1443 * assertThat(invoiceArray).contains(lowestInvoice).1444 *1445 * // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ...1446 * assertThat(fellowshipOfTheRing).contains(gandalf)1447 * .doesNotContain(sauron);1448 *1449 * // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf.1450 * assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator)1451 * .contains(sauron);</code></pre>1452 *1453 * @param elementComparator the comparator to use for incoming assertion checks.1454 * @throws NullPointerException if the given comparator is {@code null}.1455 * @return {@code this} assertion object.1456 */1457 @Override1458 @CheckReturnValue1459 public AtomicReferenceArrayAssert<T> usingElementComparator(Comparator<? super T> elementComparator) {1460 this.arrays = new ObjectArrays(new ComparatorBasedComparisonStrategy(elementComparator));1461 objects = new Objects(new AtomicReferenceArrayElementComparisonStrategy<>(elementComparator));1462 return myself;1463 }1464 private AtomicReferenceArrayAssert<T> usingExtendedByTypesElementComparator(Comparator<Object> elementComparator) {1465 return usingElementComparator(new ExtendedByTypesComparator(elementComparator, comparatorsByType));1466 }1467 /** {@inheritDoc} */1468 @Override1469 @CheckReturnValue1470 public AtomicReferenceArrayAssert<T> usingDefaultElementComparator() {1471 this.arrays = ObjectArrays.instance();1472 return myself;1473 }1474 /**1475 * Allows to set a comparator to compare properties or fields of elements with the given names.1476 * A typical usage is for comparing fields of numeric type at a given precision.1477 * <p>1478 * To be used, comparators need to be specified by this method <b>before</b> calling any of:1479 * <ul>1480 * <li>{@link #usingFieldByFieldElementComparator}</li>1481 * <li>{@link #usingElementComparatorOnFields}</li>1482 * <li>{@link #usingElementComparatorIgnoringFields}</li>1483 * <li>{@link #usingRecursiveFieldByFieldElementComparator}</li>1484 * </ul>1485 * <p>1486 * Comparators specified by this method have precedence over comparators specified by1487 * {@link #usingComparatorForElementFieldsWithType(Comparator, Class) usingComparatorForElementFieldsWithType}.1488 * <p>1489 * Example:1490 * <p>1491 * <pre><code class='java'> public class TolkienCharacter {1492 * private String name;1493 * private double height;1494 * // constructor omitted1495 * }1496 *1497 * TolkienCharacter frodo = new TolkienCharacter(&quot;Frodo&quot;, 1.2);1498 * TolkienCharacter tallerFrodo = new TolkienCharacter(&quot;Frodo&quot;, 1.3);1499 * TolkienCharacter reallyTallFrodo = new TolkienCharacter(&quot;Frodo&quot;, 1.9);1500 *1501 * Comparator&lt;Double&gt; closeEnough = new Comparator&lt;Double&gt;() {1502 * double precision = 0.5;1503 * public int compare(Double d1, Double d2) {1504 * return Math.abs(d1 - d2) &lt;= precision ? 0 : 1;1505 * }1506 * };1507 *1508 * AtomicReferenceArray&lt;TolkienCharacter&gt; hobbits = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[]{frodo});1509 *1510 * // assertions will pass1511 * assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, &quot;height&quot;)1512 * .usingFieldByFieldElementComparator()1513 * .contains(tallerFrodo);1514 *1515 * assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, &quot;height&quot;)1516 * .usingElementComparatorOnFields(&quot;height&quot;)1517 * .contains(tallerFrodo);1518 *1519 * assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, &quot;height&quot;)1520 * .usingElementComparatorIgnoringFields(&quot;name&quot;)1521 * .contains(tallerFrodo);1522 *1523 * assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, &quot;height&quot;)1524 * .usingRecursiveFieldByFieldElementComparator()1525 * .contains(tallerFrodo);1526 *1527 * // assertion will fail1528 * assertThat(hobbits).usingComparatorForElementFieldsWithNames(closeEnough, &quot;height&quot;)1529 * .usingFieldByFieldElementComparator()1530 * .containsExactly(reallyTallFrodo);</code></pre>1531 *1532 * @param comparator the {@link java.util.Comparator} to use1533 * @param elementPropertyOrFieldNames the names of the properties and/or fields of the elements the comparator should be used for1534 * @return {@code this} assertions object1535 * @since 2.7.0 / 3.7.01536 */1537 @CheckReturnValue1538 public <C> AtomicReferenceArrayAssert<T> usingComparatorForElementFieldsWithNames(Comparator<C> comparator,1539 String... elementPropertyOrFieldNames) {1540 for (String elementPropertyOrField : elementPropertyOrFieldNames) {1541 comparatorsForElementPropertyOrFieldNames.put(elementPropertyOrField, comparator);1542 }1543 return myself;1544 }1545 /**1546 * Allows to set a specific comparator to compare properties or fields of elements with the given type.1547 * A typical usage is for comparing fields of numeric type at a given precision.1548 * <p>1549 * To be used, comparators need to be specified by this method <b>before</b> calling any of:1550 * <ul>1551 * <li>{@link #usingFieldByFieldElementComparator}</li>1552 * <li>{@link #usingElementComparatorOnFields}</li>1553 * <li>{@link #usingElementComparatorIgnoringFields}</li>1554 * <li>{@link #usingRecursiveFieldByFieldElementComparator}</li>1555 * </ul>1556 * <p>1557 * Comparators specified by {@link #usingComparatorForElementFieldsWithNames(Comparator, String...) usingComparatorForElementFieldsWithNames}1558 * have precedence over comparators specified by this method.1559 * <p>1560 * Example:1561 * <pre><code class='java'> public class TolkienCharacter {1562 * private String name;1563 * private double height;1564 * // constructor omitted1565 * }1566 * TolkienCharacter frodo = new TolkienCharacter(&quot;Frodo&quot;, 1.2);1567 * TolkienCharacter tallerFrodo = new TolkienCharacter(&quot;Frodo&quot;, 1.3);1568 * TolkienCharacter reallyTallFrodo = new TolkienCharacter(&quot;Frodo&quot;, 1.9);1569 *1570 * Comparator&lt;Double&gt; closeEnough = new Comparator&lt;Double&gt;() {1571 * double precision = 0.5;1572 * public int compare(Double d1, Double d2) {1573 * return Math.abs(d1 - d2) &lt;= precision ? 0 : 1;1574 * }1575 * };1576 *1577 * AtomicReferenceArray&lt;TolkienCharacter&gt; hobbits = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[]{frodo});1578 *1579 * // assertions will pass1580 * assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)1581 * .usingFieldByFieldElementComparator()1582 * .contains(tallerFrodo);1583 *1584 * assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)1585 * .usingElementComparatorOnFields(&quot;height&quot;)1586 * .contains(tallerFrodo);1587 *1588 * assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)1589 * .usingElementComparatorIgnoringFields(&quot;name&quot;)1590 * .contains(tallerFrodo);1591 *1592 * assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)1593 * .usingRecursiveFieldByFieldElementComparator()1594 * .contains(tallerFrodo);1595 *1596 * // assertion will fail1597 * assertThat(hobbits).usingComparatorForElementFieldsWithType(closeEnough, Double.class)1598 * .usingFieldByFieldElementComparator()1599 * .contains(reallyTallFrodo);</code></pre>1600 *1601 * If multiple compatible comparators have been registered for a given {@code type}, the closest in the inheritance 1602 * chain to the given {@code type} is chosen in the following order:1603 * <ol>1604 * <li>The comparator for the exact given {@code type}</li>1605 * <li>The comparator of a superclass of the given {@code type}</li>1606 * <li>The comparator of an interface implemented by the given {@code type}</li>1607 * </ol>1608 *1609 * @param comparator the {@link java.util.Comparator} to use1610 * @param type the {@link java.lang.Class} of the type of the element fields the comparator should be used for1611 * @return {@code this} assertions object1612 * @since 2.7.0 / 3.7.01613 */1614 @CheckReturnValue1615 public <C> AtomicReferenceArrayAssert<T> usingComparatorForElementFieldsWithType(Comparator<C> comparator, Class<C> type) {1616 comparatorsForElementPropertyOrFieldTypes.put(type, comparator);1617 return myself;1618 }1619 /**1620 * Allows to set a specific comparator for the given type of elements or their fields.1621 * Extends {@link #usingComparatorForElementFieldsWithType} by applying comparator specified for given type1622 * to elements themselves, not only to their fields.1623 * <p>1624 * Usage of this method affects comparators set by next methods:1625 * <ul>1626 * <li>{@link #usingFieldByFieldElementComparator}</li>1627 * <li>{@link #usingElementComparatorOnFields}</li>1628 * <li>{@link #usingElementComparatorIgnoringFields}</li>1629 * <li>{@link #usingRecursiveFieldByFieldElementComparator}</li>1630 * </ul>1631 * <p>1632 * Example:1633 * <pre><code class='java'> // assertion will pass1634 * assertThat(new AtomicReferenceArray<>(new Object[] { "some", new BigDecimal("4.2") }))1635 * .usingComparatorForType(BIG_DECIMAL_COMPARATOR, BigDecimal.class)1636 * .contains(new BigDecimal("4.20"));1637 * </code></pre>1638 * </p>1639 *1640 * @param comparator the {@link java.util.Comparator} to use1641 * @param type the {@link java.lang.Class} of the type of the element or element fields the comparator should be used for1642 * @return {@code this} assertions object1643 * @since 2.9.0 / 3.9.01644 */1645 @CheckReturnValue1646 public <C> AtomicReferenceArrayAssert<T> usingComparatorForType(Comparator<C> comparator, Class<C> type) {1647 if (arrays.getComparator() == null) {1648 usingElementComparator(new ExtendedByTypesComparator(comparatorsByType));1649 }1650 comparatorsForElementPropertyOrFieldTypes.put(type, comparator);1651 comparatorsByType.put(type, comparator);1652 return myself;1653 }1654 /**1655 * Use field/property by field/property comparison (including inherited fields/properties) instead of relying on1656 * actual type A <code>equals</code> method to compare AtomicReferenceArray elements for incoming assertion checks. Private fields1657 * are included but this can be disabled using {@link Assertions#setAllowExtractingPrivateFields(boolean)}.1658 * <p>1659 * This can be handy if <code>equals</code> method of the objects to compare does not suit you.1660 * <p>1661 * You can specify a custom comparator per name or type of element field with1662 * {@link #usingComparatorForElementFieldsWithNames(Comparator, String...)}1663 * and {@link #usingComparatorForElementFieldsWithType(Comparator, Class)}.1664 * <p>1665 * Note that the comparison is <b>not</b> recursive, if one of the fields/properties is an Object, it will be compared1666 * to the other field/property using its <code>equals</code> method.1667 * </p>1668 * Example:1669 * <pre><code class='java'> TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);1670 * TolkienCharacter frodoClone = new TolkienCharacter("Frodo", 33, HOBBIT);1671 *1672 * // Fail if equals has not been overridden in TolkienCharacter as equals default implementation only compares references1673 * assertThat(atomicArray(frodo)).contains(frodoClone);1674 *1675 * // frodo and frodoClone are equals when doing a field by field comparison.1676 * assertThat(atomicArray(frodo)).usingFieldByFieldElementComparator().contains(frodoClone);</code></pre>1677 *1678 * @return {@code this} assertion object.1679 * @since 2.7.0 / 3.7.01680 */1681 @CheckReturnValue1682 public AtomicReferenceArrayAssert<T> usingFieldByFieldElementComparator() {1683 return usingExtendedByTypesElementComparator(new FieldByFieldComparator(comparatorsForElementPropertyOrFieldNames,1684 comparatorsForElementPropertyOrFieldTypes));1685 }1686 /**1687 * Use a recursive field/property by field/property comparison (including inherited fields/properties)1688 * instead of relying on actual type A <code>equals</code> method to compare AtomicReferenceArray elements for incoming1689 * assertion checks. This can be useful if actual's {@code equals} implementation does not suit you.1690 * <p>1691 * The recursive property/field comparison is <b>not</b> applied on fields having a custom {@code equals}1692 * implementation, i.e. the overridden {@code equals} method will be used instead of a field/property by field/property comparison.1693 * <p>1694 * You can specify a custom comparator per (nested) name or type of element field with1695 * {@link #usingComparatorForElementFieldsWithNames(Comparator, String...) usingComparatorForElementFieldsWithNames}1696 * and {@link #usingComparatorForElementFieldsWithType(Comparator, Class) usingComparatorForElementFieldsWithType}.1697 * <p>1698 * The recursive comparison handles cycles.1699 * <p>1700 * The objects to compare can be of different types but must have the same properties/fields. For example if actual object has a1701 * {@code name} String field, the other object must also have one.1702 * <p>1703 * If an object has a field and a property with the same name, the property value will be used over the field.1704 * <p>1705 * Example:1706 *1707 * <pre><code class='java'> TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);1708 * TolkienCharacter pippin = new TolkienCharacter("Pippin", 28, HOBBIT);1709 * frodo.setFriend(pippin);1710 * pippin.setFriend(frodo);1711 *1712 * TolkienCharacter frodoClone = new TolkienCharacter("Frodo", 33, HOBBIT);1713 * TolkienCharacter pippinClone = new TolkienCharacter("Pippin", 28, HOBBIT);1714 * frodoClone.setFriend(pippinClone);1715 * pippinClone.setFriend(frodoClone);1716 *1717 * AtomicReferenceArray&lt;TolkienCharacter&gt; hobbits = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[] {frodo, pippin});1718 *1719 * // fails if equals has not been overridden in TolkienCharacter as it would compares object references1720 * assertThat(hobbits).contains(frodoClone, pippinClone);1721 *1722 * // frodo/frodoClone and pippin/pippinClone are equals when doing a recursive property/field by property/field comparison1723 * assertThat(hobbits).usingRecursiveFieldByFieldElementComparator()1724 * .contains(frodoClone, pippinClone);</code></pre>1725 *1726 * @return {@code this} assertion object.1727 * @since 2.7.0 / 3.7.01728 */1729 @CheckReturnValue1730 public AtomicReferenceArrayAssert<T> usingRecursiveFieldByFieldElementComparator() {1731 return usingExtendedByTypesElementComparator(new RecursiveFieldByFieldComparator(comparatorsForElementPropertyOrFieldNames,1732 comparatorsForElementPropertyOrFieldTypes));1733 }1734 /**1735 * Use field/property by field/property comparison on the <b>given fields/properties only</b> (including inherited1736 * fields/properties) instead of relying on actual type A <code>equals</code> method to compare AtomicReferenceArray elements for1737 * incoming assertion checks. Private fields are included but this can be disabled using1738 * {@link Assertions#setAllowExtractingPrivateFields(boolean)}.1739 * <p>1740 * This can be handy if <code>equals</code> method of the objects to compare does not suit you.1741 * <p>1742 * You can specify a custom comparator per name or type of element field with1743 * {@link #usingComparatorForElementFieldsWithNames(Comparator, String...)}1744 * and {@link #usingComparatorForElementFieldsWithType(Comparator, Class)}.1745 * <p>1746 * Note that the comparison is <b>not</b> recursive, if one of the fields/properties is an Object, it will be compared1747 * to the other field/property using its <code>equals</code> method.1748 * </p>1749 * Example:1750 * <pre><code class='java'> TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);1751 * TolkienCharacter sam = new TolkienCharacter("Sam", 38, HOBBIT);1752 *1753 * // frodo and sam both are hobbits, so they are equals when comparing only race1754 * assertThat(atomicArray(frodo)).usingElementComparatorOnFields("race").contains(sam); // OK1755 *1756 * // ... but not when comparing both name and race1757 * assertThat(atomicArray(frodo)).usingElementComparatorOnFields("name", "race").contains(sam); // FAIL</code></pre>1758 *1759 * @return {@code this} assertion object.1760 * @since 2.7.0 / 3.7.01761 */1762 @CheckReturnValue1763 public AtomicReferenceArrayAssert<T> usingElementComparatorOnFields(String... fields) {1764 return usingExtendedByTypesElementComparator(new OnFieldsComparator(comparatorsForElementPropertyOrFieldNames,1765 comparatorsForElementPropertyOrFieldTypes, fields));1766 }1767 /**1768 * Use field/property by field/property on all fields/properties <b>except</b> the given ones (including inherited1769 * fields/properties) instead of relying on actual type A <code>equals</code> method to compare AtomicReferenceArray elements for1770 * incoming assertion checks. Private fields are included but this can be disabled using1771 * {@link Assertions#setAllowExtractingPrivateFields(boolean)}.1772 * <p>1773 * This can be handy if <code>equals</code> method of the objects to compare does not suit you.1774 * <p>1775 * You can specify a custom comparator per name or type of element field with1776 * {@link #usingComparatorForElementFieldsWithNames(Comparator, String...)}1777 * and {@link #usingComparatorForElementFieldsWithType(Comparator, Class)}.1778 * <p>1779 * Note that the comparison is <b>not</b> recursive, if one of the fields/properties is an Object, it will be compared1780 * to the other field/property using its <code>equals</code> method.1781 * </p>1782 * Example:1783 * <pre><code class='java'> TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);1784 * TolkienCharacter sam = new TolkienCharacter("Sam", 38, HOBBIT);1785 *1786 * // frodo and sam both are hobbits, so they are equals when comparing only race (i.e. ignoring all other fields)1787 * assertThat(atomicArray(frodo)).usingElementComparatorIgnoringFields("name", "age").contains(sam); // OK1788 *1789 * // ... but not when comparing both name and race1790 * assertThat(atomicArray(frodo)).usingElementComparatorIgnoringFields("age").contains(sam); // FAIL</code></pre>1791 *1792 * @param fields the names of the fields/properties to ignore1793 * @return {@code this} assertion object.1794 * @since 2.7.0 / 3.7.01795 */1796 @CheckReturnValue1797 public AtomicReferenceArrayAssert<T> usingElementComparatorIgnoringFields(String... fields) {1798 return usingExtendedByTypesElementComparator(new IgnoringFieldsComparator(comparatorsForElementPropertyOrFieldNames,1799 comparatorsForElementPropertyOrFieldTypes, fields));1800 }1801 /**1802 * Extract the values of given field or property from the array's elements under test into a new array, this new array1803 * becoming the array under test.1804 * <p>1805 * It allows you to test a field/property of the array's elements instead of testing the elements themselves, which can1806 * be much less work !1807 * <p>1808 * Let's take an example to make things clearer :1809 * <pre><code class='java'> // Build a array of TolkienCharacter, a TolkienCharacter has a name (String) and a Race (a class)1810 * // they can be public field or properties, both works when extracting their values.1811 * AtomicReferenceArray&lt;TolkienCharacter&gt; fellowshipOfTheRing = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[]{1812 * new TolkienCharacter(&quot;Frodo&quot;, 33, HOBBIT),1813 * new TolkienCharacter(&quot;Sam&quot;, 38, HOBBIT),1814 * new TolkienCharacter(&quot;Gandalf&quot;, 2020, MAIA),1815 * new TolkienCharacter(&quot;Legolas&quot;, 1000, ELF),1816 * new TolkienCharacter(&quot;Pippin&quot;, 28, HOBBIT),1817 * new TolkienCharacter(&quot;Gimli&quot;, 139, DWARF),1818 * new TolkienCharacter(&quot;Aragorn&quot;, 87, MAN,1819 * new TolkienCharacter(&quot;Boromir&quot;, 37, MAN)1820 * };1821 *1822 * // let's verify the names of TolkienCharacter in fellowshipOfTheRing :1823 *1824 * assertThat(fellowshipOfTheRing).extracting(&quot;name&quot;)1825 * .contains(&quot;Boromir&quot;, &quot;Gandalf&quot;, &quot;Frodo&quot;)1826 * .doesNotContain(&quot;Sauron&quot;, &quot;Elrond&quot;);1827 *1828 * // you can also extract nested field/property like the name of Race :1829 *1830 * assertThat(fellowshipOfTheRing).extracting(&quot;race.name&quot;)1831 * .contains(&quot;Hobbit&quot;, &quot;Elf&quot;)1832 * .doesNotContain(&quot;Orc&quot;);</code></pre>1833 *1834 * A property with the given name is looked for first, if it does not exist then a field with the given name1835 * is looked for.1836 * <p>1837 * Note that the order of extracted field/property values is consistent with the array order.1838 *1839 * @param fieldOrProperty the field/property to extract from the array under test1840 * @return a new assertion object whose object under test is the array of extracted field/property values.1841 * @throws IntrospectionError if no field or property exists with the given name1842 * @since 2.7.0 / 3.7.01843 */1844 @CheckReturnValue1845 public ObjectArrayAssert<Object> extracting(String fieldOrProperty) {1846 Object[] values = FieldsOrPropertiesExtractor.extract(array, byName(fieldOrProperty));1847 String extractedDescription = extractedDescriptionOf(fieldOrProperty);1848 String description = mostRelevantDescription(info.description(), extractedDescription);1849 return new ObjectArrayAssert<>(values).as(description);1850 }1851 /**1852 * Extract the values of given field or property from the array's elements under test into a new array, this new array1853 * becoming the array under test with type.1854 * <p>1855 * It allows you to test a field/property of the array's elements instead of testing the elements themselves, which can1856 * be much less work !1857 * <p>1858 * Let's take an example to make things clearer :1859 * <pre><code class='java'> // Build an array of TolkienCharacter, a TolkienCharacter has a name (String) and a Race (a class)1860 * // they can be public field or properties, both works when extracting their values.1861 * AtomicReferenceArray&lt;TolkienCharacter&gt; fellowshipOfTheRing = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[]{1862 * new TolkienCharacter(&quot;Frodo&quot;, 33, HOBBIT),1863 * new TolkienCharacter(&quot;Sam&quot;, 38, HOBBIT),1864 * new TolkienCharacter(&quot;Gandalf&quot;, 2020, MAIA),1865 * new TolkienCharacter(&quot;Legolas&quot;, 1000, ELF),1866 * new TolkienCharacter(&quot;Pippin&quot;, 28, HOBBIT),1867 * new TolkienCharacter(&quot;Gimli&quot;, 139, DWARF),1868 * new TolkienCharacter(&quot;Aragorn&quot;, 87, MAN,1869 * new TolkienCharacter(&quot;Boromir&quot;, 37, MAN)1870 * };1871 *1872 * // let's verify the names of TolkienCharacter in fellowshipOfTheRing :1873 *1874 * assertThat(fellowshipOfTheRing).extracting(&quot;name&quot;, String.class)1875 * .contains(&quot;Boromir&quot;, &quot;Gandalf&quot;, &quot;Frodo&quot;)1876 * .doesNotContain(&quot;Sauron&quot;, &quot;Elrond&quot;);1877 *1878 * // you can also extract nested field/property like the name of Race :1879 *1880 * assertThat(fellowshipOfTheRing).extracting(&quot;race.name&quot;, String.class)1881 * .contains(&quot;Hobbit&quot;, &quot;Elf&quot;)1882 * .doesNotContain(&quot;Orc&quot;);</code></pre>1883 *1884 * A property with the given name is looked for first, if it does not exist then a field with the given name1885 * is looked for.1886 * <p>1887 * Note that the order of extracted field/property values is consistent with the order of the array under test.1888 *1889 * @param fieldOrProperty the field/property to extract from the array under test1890 * @param extractingType type to return1891 * @return a new assertion object whose object under test is the array of extracted field/property values.1892 * @throws IntrospectionError if no field or property exists with the given name1893 * @since 2.7.0 / 3.7.01894 */1895 @CheckReturnValue1896 public <P> ObjectArrayAssert<P> extracting(String fieldOrProperty, Class<P> extractingType) {1897 @SuppressWarnings("unchecked")1898 P[] values = (P[]) FieldsOrPropertiesExtractor.extract(array, byName(fieldOrProperty));1899 String extractedDescription = extractedDescriptionOf(fieldOrProperty);1900 String description = mostRelevantDescription(info.description(), extractedDescription);1901 return new ObjectArrayAssert<>(values).as(description);1902 }1903 /**1904 * Extract the values of given fields/properties from the array's elements under test into a new array composed of1905 * Tuple (a simple data structure), this new array becoming the array under test.1906 * <p>1907 * It allows you to test fields/properties of the the array's elements instead of testing the elements themselves, it1908 * can be sometimes much less work !1909 * <p>1910 * The Tuple data corresponds to the extracted values of the given fields/properties, for instance if you ask to1911 * extract "id", "name" and "email" then each Tuple data will be composed of id, name and email extracted from the1912 * element of the initial array (the Tuple's data order is the same as the given fields/properties order).1913 * <p>1914 * Let's take an example to make things clearer :1915 * <pre><code class='java'> // Build an array of TolkienCharacter, a TolkienCharacter has a name (String) and a Race (a class)1916 * // they can be public field or properties, both works when extracting their values.1917 * AtomicReferenceArray&lt;TolkienCharacter&gt; fellowshipOfTheRing = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[]{1918 * new TolkienCharacter(&quot;Frodo&quot;, 33, HOBBIT),1919 * new TolkienCharacter(&quot;Sam&quot;, 38, HOBBIT),1920 * new TolkienCharacter(&quot;Gandalf&quot;, 2020, MAIA),1921 * new TolkienCharacter(&quot;Legolas&quot;, 1000, ELF),1922 * new TolkienCharacter(&quot;Pippin&quot;, 28, HOBBIT),1923 * new TolkienCharacter(&quot;Gimli&quot;, 139, DWARF),1924 * new TolkienCharacter(&quot;Aragorn&quot;, 87, MAN,1925 * new TolkienCharacter(&quot;Boromir&quot;, 37, MAN)1926 * };1927 *1928 * // let's verify 'name' and 'age' of some TolkienCharacter in fellowshipOfTheRing :1929 *1930 * assertThat(fellowshipOfTheRing).extracting(&quot;name&quot;, &quot;age&quot;)1931 * .contains(tuple(&quot;Boromir&quot;, 37),1932 * tuple(&quot;Sam&quot;, 38),1933 * tuple(&quot;Legolas&quot;, 1000));1934 *1935 *1936 * // extract 'name', 'age' and Race name values.1937 *1938 * assertThat(fellowshipOfTheRing).extracting(&quot;name&quot;, &quot;age&quot;, &quot;race.name&quot;)1939 * .contains(tuple(&quot;Boromir&quot;, 37, &quot;Man&quot;),1940 * tuple(&quot;Sam&quot;, 38, &quot;Hobbit&quot;),1941 * tuple(&quot;Legolas&quot;, 1000, &quot;Elf&quot;));</code></pre>1942 *1943 * A property with the given name is looked for first, if it does not exist the a field with the given name is1944 * looked for.1945 * <p>1946 * Note that the order of extracted property/field values is consistent with the iteration order of the array under1947 * test.1948 *1949 * @param propertiesOrFields the properties/fields to extract from the initial array under test1950 * @return a new assertion object whose object under test is the list of Tuple with extracted properties/fields values1951 * as data.1952 * @throws IntrospectionError if one of the given name does not match a field or property in one of the initial1953 * Iterable's element.1954 */1955 @CheckReturnValue1956 public ObjectArrayAssert<Tuple> extracting(String... propertiesOrFields) {1957 Object[] values = FieldsOrPropertiesExtractor.extract(array, byName(propertiesOrFields));1958 Tuple[] result = Arrays.copyOf(values, values.length, Tuple[].class);1959 String extractedDescription = extractedDescriptionOf(propertiesOrFields);1960 String description = mostRelevantDescription(info.description(), extractedDescription);1961 return new ObjectArrayAssert<>(result).as(description);1962 }1963 /**1964 * Extract the values from the array's elements by applying an extracting function on them. The returned1965 * array becomes a new object under test.1966 * <p>1967 * It allows to test values from the elements in safer way than by using {@link #extracting(String)}, as it1968 * doesn't utilize introspection.1969 * <p>1970 * Let's take a look an example:1971 * <pre><code class='java'> // Build a list of TolkienCharacter, a TolkienCharacter has a name, and age and a Race (a specific class)1972 * // they can be public field or properties, both can be extracted.1973 * AtomicReferenceArray&lt;TolkienCharacter&gt; fellowshipOfTheRing = new AtomicReferenceArray&lt;&gt;(new TolkienCharacter[]{1974 * new TolkienCharacter(&quot;Frodo&quot;, 33, HOBBIT),1975 * new TolkienCharacter(&quot;Sam&quot;, 38, HOBBIT),1976 * new TolkienCharacter(&quot;Gandalf&quot;, 2020, MAIA),1977 * new TolkienCharacter(&quot;Legolas&quot;, 1000, ELF),1978 * new TolkienCharacter(&quot;Pippin&quot;, 28, HOBBIT),1979 * new TolkienCharacter(&quot;Gimli&quot;, 139, DWARF),1980 * new TolkienCharacter(&quot;Aragorn&quot;, 87, MAN,1981 * new TolkienCharacter(&quot;Boromir&quot;, 37, MAN)1982 * };1983 *1984 *1985 * // this extracts the race1986 * Extractor&lt;TolkienCharacter, Race&gt; race = new Extractor&lt;TolkienCharacter, Race&gt;() {1987 * {@literal @}Override1988 * public Race extract(TolkienCharacter input) {1989 * return input.getRace();1990 * }1991 * }1992 *1993 * // fellowship has hobbits, right, my presioussss?1994 * assertThat(fellowshipOfTheRing).extracting(race).contains(HOBBIT);</code></pre>1995 *1996 * Note that the order of extracted property/field values is consistent with the iteration order of the Iterable under1997 * test, for example if it's a {@link HashSet}, you won't be able to make any assumptions on the extracted values1998 * order.1999 *2000 * @param extractor the object transforming input object to desired one2001 * @return a new assertion object whose object under test is the list of values extracted2002 * @since 2.7.0 / 3.7.02003 */2004 @CheckReturnValue2005 public <U> ObjectArrayAssert<U> extracting(Extractor<? super T, U> extractor) {2006 U[] extracted = FieldsOrPropertiesExtractor.extract(array, extractor);2007 return new ObjectArrayAssert<>(extracted);2008 }2009 /**2010 * Extract the Iterable values from the array's elements by applying an Iterable extracting function on them2011 * and concatenating the result lists into an array which becomes the new object under test.2012 * <p>2013 * It allows testing the results of extracting values that are represented by Iterables.2014 * <p>2015 * For example:2016 * <pre><code class='java'> CartoonCharacter bart = new CartoonCharacter("Bart Simpson");2017 * CartoonCharacter lisa = new CartoonCharacter("Lisa Simpson");2018 * CartoonCharacter maggie = new CartoonCharacter("Maggie Simpson");2019 * CartoonCharacter homer = new CartoonCharacter("Homer Simpson");2020 * homer.addChildren(bart, lisa, maggie);2021 *2022 * CartoonCharacter pebbles = new CartoonCharacter("Pebbles Flintstone");2023 * CartoonCharacter fred = new CartoonCharacter("Fred Flintstone");2024 * fred.getChildren().add(pebbles);2025 *2026 * Extractor&lt;CartoonCharacter, List&lt;CartoonCharacter&gt;&gt; childrenOf = new Extractor&lt;CartoonCharacter, List&lt;CartoonCharacter&gt;&gt;() {2027 * {@literal @}Override2028 * public List&lt;CartoonChildren&gt; extract(CartoonCharacter input) {2029 * return input.getChildren();2030 * }2031 * }2032 *2033 * AtomicReferenceArray&lt;CartoonCharacter&gt; parents = new AtomicReferenceArray&lt;&gt;(new CartoonCharacter[]{ homer, fred });2034 * // check children2035 * assertThat(parents).flatExtracting(childrenOf)2036 * .containsOnly(bart, lisa, maggie, pebbles);</code></pre>2037 *2038 * The order of extracted values is consisted with both the order of the collection itself, as well as the extracted2039 * collections.2040 *2041 * @param extractor the object transforming input object to an Iterable of desired ones2042 * @return a new assertion object whose object under test is the list of values extracted2043 * @since 2.7.0 / 3.7.02044 */2045 @CheckReturnValue2046 public <U, C extends Collection<U>> ObjectArrayAssert<U> flatExtracting(Extractor<? super T, C> extractor) {2047 final List<C> extractedValues = FieldsOrPropertiesExtractor.extract(Arrays.asList(array), extractor);2048 final List<U> result = newArrayList();2049 for (C e : extractedValues) {2050 result.addAll(e);2051 }2052 return new ObjectArrayAssert<>(IterableUtil.toArray(result));2053 }2054 /**2055 * Extract from array's elements the Iterable/Array values corresponding to the given property/field name and2056 * concatenate them into a single array becoming the new object under test.2057 * <p>2058 * It allows testing the elements of extracting values that are represented by iterables or arrays.2059 * <p>2060 * For example:2061 * <pre><code class='java'> CartoonCharacter bart = new CartoonCharacter("Bart Simpson");2062 * CartoonCharacter lisa = new CartoonCharacter("Lisa Simpson");2063 * CartoonCharacter maggie = new CartoonCharacter("Maggie Simpson");2064 * CartoonCharacter homer = new CartoonCharacter("Homer Simpson");2065 * homer.addChildren(bart, lisa, maggie);2066 *2067 * CartoonCharacter pebbles = new CartoonCharacter("Pebbles Flintstone");2068 * CartoonCharacter fred = new CartoonCharacter("Fred Flintstone");2069 * fred.getChildren().add(pebbles);2070 *2071 * AtomicReferenceArray&lt;CartoonCharacter&gt; parents = new AtomicReferenceArray&lt;&gt;(new CartoonCharacter[]{ homer, fred });2072 * // check children2073 * assertThat(parents).flatExtracting("children")2074 * .containsOnly(bart, lisa, maggie, pebbles);</code></pre>2075 *2076 * The order of extracted values is consisted with both the order of the collection itself, as well as the extracted2077 * collections.2078 *2079 * @param propertyName the object transforming input object to an Iterable of desired ones2080 * @return a new assertion object whose object under test is the list of values extracted2081 * @throws IllegalArgumentException if one of the extracted property value was not an array or an iterable.2082 * @since 2.7.0 / 3.7.02083 */2084 @CheckReturnValue2085 public ObjectArrayAssert<Object> flatExtracting(String propertyName) {2086 List<Object> extractedValues = newArrayList();2087 List<?> extractedGroups = FieldsOrPropertiesExtractor.extract(Arrays.asList(array), byName(propertyName));2088 for (Object group : extractedGroups) {2089 // expecting AtomicReferenceArray to be an iterable or an array2090 if (isArray(group)) {2091 int size = Array.getLength(group);2092 for (int i = 0; i < size; i++) {2093 extractedValues.add(Array.get(group, i));2094 }2095 } else if (group instanceof Iterable) {2096 Iterable<?> iterable = (Iterable<?>) group;2097 for (Object value : iterable) {2098 extractedValues.add(value);2099 }2100 } else {2101 CommonErrors.wrongElementTypeForFlatExtracting(group);2102 }2103 }2104 return new ObjectArrayAssert<>(extractedValues.toArray());2105 }2106 /**2107 * Extract the result of given method invocation from the array's elements under test into a new array, this new array2108 * becoming the array under test.2109 * <p>2110 * It allows you to test a method results of the array's elements instead of testing the elements themselves, which can be2111 * much less work!2112 * <p>2113 * It is especially useful for classes that does not conform to the Java Bean's getter specification (i.e. public String2114 * toString() or public String status() instead of public String getStatus()).2115 * <p>2116 * Let's take an example to make things clearer :2117 * <pre><code class='java'> // Build a array of WesterosHouse, a WesterosHouse has a method: public String sayTheWords()2118 * AtomicReferenceArray&lt;WesterosHouse&gt; greatHousesOfWesteros = new AtomicReferenceArray&lt;&gt;(new WesterosHouse[]{ 2119 * new WesterosHouse(&quot;Stark&quot;, &quot;Winter is Coming&quot;),2120 * new WesterosHouse(&quot;Lannister&quot;, &quot;Hear Me Roar!&quot;), 2121 * new WesterosHouse(&quot;Greyjoy&quot;, &quot;We Do Not Sow&quot;),2122 * new WesterosHouse(&quot;Baratheon&quot;, &quot;Our is the Fury&quot;), 2123 * new WesterosHouse(&quot;Martell&quot;, &quot;Unbowed, Unbent, Unbroken&quot;),2124 * new WesterosHouse(&quot;Tyrell&quot;, &quot;Growing Strong&quot;) });2125 *2126 * // let's verify the words of the great houses of Westeros:2127 * assertThat(greatHousesOfWesteros).extractingResultOf(&quot;sayTheWords&quot;)2128 * .contains(&quot;Winter is Coming&quot;, &quot;We Do Not Sow&quot;, &quot;Hear Me Roar&quot;)2129 * .doesNotContain(&quot;Lannisters always pay their debts&quot;);</code></pre>2130 *2131 * <p>2132 * Following requirements have to be met to extract method results:2133 * <ul>2134 * <li>method has to be public,</li>2135 * <li>method cannot accept any arguments,</li>2136 * <li>method cannot return void.</li>2137 * </ul>2138 * <p>2139 * Note that the order of extracted values is consistent with the order of the array under test.2140 *2141 * @param method the name of the method which result is to be extracted from the array under test2142 * @return a new assertion object whose object under test is the array of extracted values.2143 * @throws IllegalArgumentException if no method exists with the given name, or method is not public, or method does2144 * return void, or method accepts arguments.2145 * @since 2.7.0 / 3.7.02146 */2147 @CheckReturnValue2148 public ObjectArrayAssert<Object> extractingResultOf(String method) {2149 Object[] values = FieldsOrPropertiesExtractor.extract(array, resultOf(method));2150 String extractedDescription = extractedDescriptionOfMethod(method);2151 String description = mostRelevantDescription(info.description(), extractedDescription);2152 return new ObjectArrayAssert<>(values).as(description);2153 }2154 /**2155 * Extract the result of given method invocation from the array's elements under test into a new array, this new array2156 * becoming the array under test.2157 * <p>2158 * It allows you to test a method results of the array's elements instead of testing the elements themselves, which can be2159 * much less work!2160 * <p>2161 * It is especially useful for classes that do not conform to the Java Bean's getter specification (i.e. public String2162 * toString() or public String status() instead of public String getStatus()).2163 * <p>2164 * Let's take an example to make things clearer :2165 * <pre><code class='java'> // Build a array of WesterosHouse, a WesterosHouse has a method: public String sayTheWords()2166 * AtomicReferenceArray&lt;WesterosHouse&gt; greatHousesOfWesteros = new AtomicReferenceArray&lt;&gt;(new WesterosHouse[]{ 2167 * new WesterosHouse(&quot;Stark&quot;, &quot;Winter is Coming&quot;),2168 * new WesterosHouse(&quot;Lannister&quot;, &quot;Hear Me Roar!&quot;), 2169 * new WesterosHouse(&quot;Greyjoy&quot;, &quot;We Do Not Sow&quot;),2170 * new WesterosHouse(&quot;Baratheon&quot;, &quot;Our is the Fury&quot;), 2171 * new WesterosHouse(&quot;Martell&quot;, &quot;Unbowed, Unbent, Unbroken&quot;),2172 * new WesterosHouse(&quot;Tyrell&quot;, &quot;Growing Strong&quot;) });2173 *2174 * // let's verify the words of the great houses of Westeros:2175 * assertThat(greatHousesOfWesteros).extractingResultOf(&quot;sayTheWords&quot;, String.class)2176 * .contains(&quot;Winter is Coming&quot;, &quot;We Do Not Sow&quot;, &quot;Hear Me Roar&quot;)2177 * .doesNotContain(&quot;Lannisters always pay their debts&quot;);</code></pre>2178 *2179 * <p>2180 * Following requirements have to be met to extract method results:2181 * <ul>2182 * <li>method has to be public,</li>2183 * <li>method can not accept any arguments,</li>2184 * <li>method can not return void.</li>2185 * </ul>2186 * <p>2187 * Note that the order of extracted values is consistent with the order of the array under test.2188 *2189 * @param method the name of the method which result is to be extracted from the array under test2190 * @param extractingType type to return2191 * @return a new assertion object whose object under test is the array of extracted values.2192 * @throws IllegalArgumentException if no method exists with the given name, or method is not public, or method does2193 * return void, or method accepts arguments.2194 * @since 2.7.0 / 3.7.02195 */2196 @CheckReturnValue2197 public <P> ObjectArrayAssert<P> extractingResultOf(String method, Class<P> extractingType) {2198 @SuppressWarnings("unchecked")2199 P[] values = (P[]) FieldsOrPropertiesExtractor.extract(array, resultOf(method));2200 String extractedDescription = extractedDescriptionOfMethod(method);2201 String description = mostRelevantDescription(info.description(), extractedDescription);2202 return new ObjectArrayAssert<>(values).as(description);2203 }2204 /**2205 * Enable hexadecimal object representation of Iterable elements instead of standard java representation in error2206 * messages.2207 * <p>2208 * It can be useful to better understand what the error was with a more meaningful error message.2209 * <p>2210 * Example2211 * <pre><code class='java'> 2212 * AtomicReferenceArray&lt;Byte&gt; bytes = new AtomicReferenceArray&lt;&gt;(new Byte[]{ 0x10, 0x20 });2213 * assertThat(bytes).inHexadecimal().contains(new Byte[] { 0x30 });</code></pre>2214 *2215 * With standard error message:2216 * <pre><code class='java'> Expecting:2217 * &lt;[16, 32]&gt;2218 * to contain:2219 * &lt;[48]&gt;2220 * but could not find:2221 * &lt;[48]&gt;</code></pre>2222 *2223 * With Hexadecimal error message:2224 * <pre><code class='java'> Expecting:2225 * &lt;[0x10, 0x20]&gt;2226 * to contain:2227 * &lt;[0x30]&gt;2228 * but could not find:2229 * &lt;[0x30]&gt;</code></pre>2230 *2231 * @return {@code this} assertion object.2232 * @since 2.7.0 / 3.7.02233 */2234 @Override2235 @CheckReturnValue2236 public AtomicReferenceArrayAssert<T> inHexadecimal() {2237 return super.inHexadecimal();2238 }2239 @Override2240 @CheckReturnValue2241 public AtomicReferenceArrayAssert<T> inBinary() {2242 return super.inBinary();2243 }2244 /**2245 * Filter the array under test keeping only elements having a property or field equal to {@code expectedValue}, the2246 * property/field is specified by {@code propertyOrFieldName} parameter.2247 * <p>2248 * The filter first tries to get the value from a property (named {@code propertyOrFieldName}), if no such property2249 * exists it tries to read the value from a field. Reading private fields is supported by default, this can be2250 * globally disabled by calling {@link Assertions#setAllowExtractingPrivateFields(boolean)2251 * Assertions.setAllowExtractingPrivateFields(false)}.2252 * <p>2253 * When reading <b>nested</b> property/field, if an intermediate value is null the whole nested property/field is2254 * considered to be null, thus reading "address.street.name" value will return null if "street" value is null.2255 * <p>2256 *2257 * As an example, let's check all employees 800 years old (yes, special employees):2258 * <pre><code class='java'> Employee yoda = new Employee(1L, new Name("Yoda"), 800);2259 * Employee obiwan = new Employee(2L, new Name("Obiwan"), 800);2260 * Employee luke = new Employee(3L, new Name("Luke", "Skywalker"), 26);2261 * Employee noname = new Employee(4L, null, 50);2262 *2263 * AtomicReferenceArray&lt;Employee&gt; employees = new AtomicReferenceArray&lt;&gt;(new Employee[]{ yoda, luke, obiwan, noname });2264 *2265 * assertThat(employees).filteredOn("age", 800)2266 * .containsOnly(yoda, obiwan);</code></pre>2267 *2268 * Nested properties/fields are supported:2269 * <pre><code class='java'> // Name is bean class with 'first' and 'last' String properties2270 *2271 * // name is null for noname =&gt; it does not match the filter on "name.first"2272 * assertThat(employees).filteredOn("name.first", "Luke")2273 * .containsOnly(luke);2274 *2275 * assertThat(employees).filteredOn("name.last", "Vader")2276 * .isEmpty();</code></pre>2277 * <p>2278 * If you want to filter on null value, use {@link #filteredOnNull(String)} as Java will resolve the call to2279 * {@link #filteredOn(String, FilterOperator)} instead of this method.2280 * <p>2281 * An {@link IntrospectionError} is thrown if the given propertyOrFieldName can't be found in one of the array2282 * elements.2283 * <p>2284 * You can chain filters:2285 * <pre><code class='java'> // fellowshipOfTheRing is an array of TolkienCharacter having race and name fields2286 * // 'not' filter is statically imported from Assertions.not2287 *2288 * assertThat(fellowshipOfTheRing).filteredOn("race.name", "Man")2289 * .filteredOn("name", not("Boromir"))2290 * .containsOnly(aragorn);</code></pre>2291 * If you need more complex filter, use {@link #filteredOn(Condition)} and provide a {@link Condition} to specify the2292 * filter to apply.2293 *2294 * @param propertyOrFieldName the name of the property or field to read2295 * @param expectedValue the value to compare element's property or field with2296 * @return a new assertion object with the filtered array under test2297 * @throws IllegalArgumentException if the given propertyOrFieldName is {@code null} or empty.2298 * @throws IntrospectionError if the given propertyOrFieldName can't be found in one of the array elements.2299 * @since 2.7.0 / 3.7.02300 */2301 @CheckReturnValue2302 public AtomicReferenceArrayAssert<T> filteredOn(String propertyOrFieldName, Object expectedValue) {2303 Iterable<? extends T> filteredIterable = filter(array).with(propertyOrFieldName, expectedValue).get();2304 return new AtomicReferenceArrayAssert<>(new AtomicReferenceArray<>(toArray(filteredIterable)));2305 }2306 /**2307 * Filter the array under test keeping only elements whose property or field specified by {@code propertyOrFieldName}2308 * is null.2309 * <p>...

Full Screen

Full Screen

Source:AtomicReferenceArrayAssert_usingRecursiveFieldByFieldElementComparatorOnFields_Test.java Github

copy

Full Screen

...47 then(getArrays(assertions).getComparator()).isEqualTo(expectedComparator);48 then(getObjects(assertions).getComparisonStrategy()).extracting("elementComparator").isEqualTo(expectedComparator);49 }50 @Test51 void should_compare_given_fields_recursively_and_none_other() {52 // GIVEN53 Player rose = new Player(new Name("Derrick", "Rose"), "Chicago Bulls");54 rose.nickname = new Name("Crazy", "Dunks");55 Player jalen = new Player(new Name("Jalen", "Rose"), "Chicago Bulls");56 jalen.nickname = new Name("Crazy", "Defense");57 // WHEN/THEN58 then(array(rose)).usingRecursiveFieldByFieldElementComparatorOnFields("name.last", "team", "nickname.first")59 .contains(jalen);60 }61}...

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import static org.assertj.core.api.Assertions.assertThat;2import java.util.concurrent.atomic.AtomicReferenceArray;3import org.junit.Test;4public class AtomicReferenceArrayAssert_compare_Test {5 public void testCompare() {6 AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<>(new String[]{"a", "b", "c"});7 assertThat(atomicReferenceArray).compare().isEqualTo(new String[]{"a", "b", "c"});8 }9}10import static org.assertj.core.api.Assertions.assertThat;11import java.util.concurrent.atomic.AtomicReferenceArray;12import org.junit.Test;13public class AtomicReferenceArrayAssert_containsExactly_Test {14 public void testContainsExactly() {15 AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<>(new String[]{"a", "b", "c"});16 assertThat(atomicReferenceArray).containsExactly("a", "b", "c");17 }18}19import static org.assertj.core.api.Assertions.assertThat;20import java.util.concurrent.atomic.AtomicReferenceArray;21import org.junit.Test;22public class AtomicReferenceArrayAssert_containsExactlyInAnyOrder_Test {23 public void testContainsExactlyInAnyOrder() {24 AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<>(new String[]{"a", "b", "c"});25 assertThat(atomicReferenceArray).containsExactlyInAnyOrder("c", "b", "a");26 }27}28import static org.assertj.core.api.Assertions.assertThat;29import java.util.Arrays;30import java.util.concurrent.atomic.AtomicReferenceArray;31import org.junit.Test;32public class AtomicReferenceArrayAssert_containsExactlyInAnyOrderElementsOf_Test {33 public void testContainsExactlyInAnyOrderElementsOf() {34 AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<>(new String[]{"a", "b", "c"});35 assertThat(atomicReferenceArray).containsExactlyInAnyOrderElementsOf(Arrays.asList("c", "b", "a"));36 }37}38import static org.assertj.core.api.Assertions.assertThat;39import java.util.concurrent.atomic.AtomicReference

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.Assertions;2import java.util.concurrent.atomic.AtomicReferenceArray;3public class AssertJAtomicReferenceArrayCompare {4 public static void main(String[] args) {5 AtomicReferenceArray<String> array1 = new AtomicReferenceArray<>(new String[]{"a", "b"});6 AtomicReferenceArray<String> array2 = new AtomicReferenceArray<>(new String[]{"a", "b"});7 Assertions.assertThat(array1).isEqualTo(array2);8 }9}10Recommended Posts: AssertJ | AssertJ AtomicReferenceArrayAssert hasSameSizeAs() Method11AssertJ | AssertJ AtomicReferenceArrayAssert contains() Method12AssertJ | AssertJ AtomicReferenceArrayAssert containsExactly() Method13AssertJ | AssertJ AtomicReferenceArrayAssert containsExactlyInAnyOrder() Method14AssertJ | AssertJ AtomicReferenceArrayAssert containsExactlyInAnyOrderElementsOf() Method15AssertJ | AssertJ AtomicReferenceArrayAssert containsExactlyElementsOf() Method16AssertJ | AssertJ AtomicReferenceArrayAssert containsNull() Method17AssertJ | AssertJ AtomicReferenceArrayAssert containsSequence() Method18AssertJ | AssertJ AtomicReferenceArrayAssert containsSubsequence() Method19AssertJ | AssertJ AtomicReferenceArrayAssert containsOnly() Method20AssertJ | AssertJ AtomicReferenceArrayAssert containsOnlyOnce() Method21AssertJ | AssertJ AtomicReferenceArrayAssert doesNotContain() Method22AssertJ | AssertJ AtomicReferenceArrayAssert doesNotContainNull() Method23AssertJ | AssertJ AtomicReferenceArrayAssert doesNotHaveDuplicates() Method24AssertJ | AssertJ AtomicReferenceArrayAssert isSubsetOf() Method25AssertJ | AssertJ AtomicReferenceArrayAssert isSubsetOf() Method26AssertJ | AssertJ AtomicReferenceArrayAssert isSorted() Method27AssertJ | AssertJ AtomicReferenceArrayAssert isSortedAccordingTo() Method

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1package org.example;2import java.util.concurrent.atomic.AtomicReferenceArray;3import java.util.concurrent.atomic.AtomicInteger;4import org.assertj.core.api.Assertions;5public class Example {6 public static void main(String[] args) {7 AtomicReferenceArray<AtomicInteger> array1 = new AtomicReferenceArray<>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2)});8 AtomicReferenceArray<AtomicInteger> array2 = new AtomicReferenceArray<>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2)});9 Assertions.assertThat(array1).usingRecursiveComparison().isEqualTo(array2);10 }11}12org.example.Example > main() PASSED13package org.example;14import java.util.concurrent.atomic.AtomicReferenceArray;15import java.util.concurrent.atomic.AtomicInteger;16import org.assertj.core.api.Assertions;17public class Example {18 public static void main(String[] args) {19 AtomicReferenceArray<AtomicInteger> array1 = new AtomicReferenceArray<>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2)});20 AtomicReferenceArray<AtomicInteger> array2 = new AtomicReferenceArray<>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(3)});21 Assertions.assertThat(array1).usingRecursiveComparison().isEqualTo(array2);22 }23}24org.example.Example > main() FAILED25 when recursively comparing field by field, but found the following 1 difference(s):26package org.example;27import java.util.concurrent.atomic.AtomicReferenceArray;28import java.util.concurrent.atomic.AtomicInteger;29import org.assertj.core.api.Assertions;30public class Example {31 public static void main(String[] args) {32 AtomicReferenceArray<AtomicInteger> array1 = new AtomicReferenceArray<>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2)});33 AtomicReferenceArray<AtomicInteger> array2 = new AtomicReferenceArray<>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2)});34 Assertions.assertThat(array1).usingRecursiveComparison().isNotEqualTo(array2);

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import static org.assertj.core.api.Assertions.assertThat;2import java.util.concurrent.atomic.AtomicReferenceArray;3public class Demo {4 public static void main(String[] args) {5 AtomicReferenceArray<Integer> array1 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3, 4, 5});6 AtomicReferenceArray<Integer> array2 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3, 4, 5});7 assertThat(array1).compare(array2);8 }9}10import static org.assertj.core.api.Assertions.assertThat;11import java.util.concurrent.atomic.AtomicReferenceArray;12public class Demo {13 public static void main(String[] args) {14 AtomicReferenceArray<Integer> array1 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3, 4, 5});15 AtomicReferenceArray<Integer> array2 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3, 4, 5});16 assertThat(array1).isNotEqualTo(array2);17 }18}19import static org.assertj.core.api.Assertions.assertThat;20import java.util.concurrent.atomic.AtomicReferenceArray;21public class Demo {22 public static void main(String[] args) {23 AtomicReferenceArray<Integer> array1 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3, 4, 5});

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.Assertions;2import java.util.concurrent.atomic.AtomicReferenceArray;3import java.util.concurrent.atomic.AtomicInteger;4public class 1 {5public static void main(String[] args) {6AtomicReferenceArray<AtomicInteger> actual = new AtomicReferenceArray<AtomicInteger>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2), new AtomicInteger(3)});7AtomicReferenceArray<AtomicInteger> expected = new AtomicReferenceArray<AtomicInteger>(new AtomicInteger[]{new AtomicInteger(1), new AtomicInteger(2), new AtomicInteger(3)});8Assertions.assertThat(actual).usingElementComparator(new AtomicIntegerComparator()).containsExactly(expected);9}10}11AtomicReferenceArrayAssert<AtomicInteger> usingElementComparator(Comparator<? super AtomicInteger> customComparator)12AtomicReferenceArrayAssert<AtomicInteger> usingDefaultElementComparator()13AtomicReferenceArrayAssert<AtomicInteger> usingElementComparatorOnFields(String... fields)14AtomicReferenceArrayAssert<AtomicInteger> usingElementComparatorOnFields(Comparator<?> comparator, String... fields)15AtomicReferenceArrayAssert<AtomicInteger> usingElementComparatorOnFields(Comparator<?> comparator, Iterable<String> fields)16AtomicReferenceArrayAssert<AtomicInteger> usingRecursiveFieldByFieldElementComparator()17AtomicReferenceArrayAssert<AtomicInteger> usingElementComparatorIgnoringFields(String... fieldsToIgnore)18AtomicReferenceArrayAssert<AtomicInteger> usingElementComparatorIgnoringFields(Iterable<String> fieldsToIgnore)19AtomicReferenceArrayAssert<AtomicInteger> usingElementComparatorOnFields(Iterable<String> fields)20AtomicReferenceArrayAssert<AtomicInteger> usingFieldByFieldElementComparator()21AtomicReferenceArrayAssert<AtomicInteger> usingDefaultComparator()22AtomicReferenceArrayAssert<AtomicInteger> usingComparator(Comparator<? super AtomicInteger> customComparator)23AtomicReferenceArrayAssert<AtomicInteger> usingComparatorForElementFieldsWithNames(Comparator<?> comparator, String... fieldNames)24AtomicReferenceArrayAssert<AtomicInteger> usingComparatorForElementFieldsWithNames(Comparator<?> comparator, Iterable<String> fieldNames)25AtomicReferenceArrayAssert<AtomicInteger> usingRecursiveComparison()26AtomicReferenceArrayAssert<AtomicInteger> usingComparatorForElementFieldsWithType(Comparator<?> comparator, Class<?> type)27AtomicReferenceArrayAssert<AtomicInteger> usingComparatorForElementFieldsWithType(Comparator<?> comparator, Class<?>... types)28AtomicReferenceArrayAssert<AtomicInteger> usingComparatorForElementFields(Comparator<?> comparator)29AtomicReferenceArrayAssert<AtomicInteger> usingComparatorForType(Comparator<?> comparator, Class<?> type)

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.Assertions;2import org.junit.Test;3import java.util.concurrent.atomic.AtomicReferenceArray;4public class CompareTest {5 public void test() {6 AtomicReferenceArray<String> array1 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});7 AtomicReferenceArray<String> array2 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});8 Assertions.assertThat(array1).isEqualToComparingFieldByFieldRecursively(array2);9 }10}11import org.assertj.core.api.Assertions;12import org.junit.Test;13import java.util.concurrent.atomic.AtomicReferenceArray;14public class CompareTest {15 public void test() {16 AtomicReferenceArray<String> array1 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});17 AtomicReferenceArray<String> array2 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});18 Assertions.assertThat(array1).usingRecursiveComparison().isEqualTo(array2);19 }20}21import org.assertj.core.api.Assertions;22import org.junit.Test;23import java.util.concurrent.atomic.AtomicReferenceArray;24public class CompareTest {25 public void test() {26 AtomicReferenceArray<String> array1 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});27 AtomicReferenceArray<String> array2 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});28 Assertions.assertThat(array1).usingRecursiveComparison().isEqualTo(array2);29 }30}31import org.assertj.core.api.Assertions;32import org.junit.Test;33import java.util.concurrent.atomic.AtomicReferenceArray;34public class CompareTest {35 public void test() {36 AtomicReferenceArray<String> array1 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});37 AtomicReferenceArray<String> array2 = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});38 Assertions.assertThat(array1).usingRecursiveComparison().isEqualTo(array2);39 }40}

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.Assertions;2import java.util.Arrays;3import java.util.concurrent.atomic.AtomicReferenceArray;4import java.util.List;5import java.util.ArrayList;6public class Test {7 public static void main(String[] args) {8 AtomicReferenceArray<String> expected = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});9 AtomicReferenceArray<String> actual = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});10 Assertions.assertThat(actual).as("Test").usingRecursiveComparison().isEqualTo(expected);11 }12}13import org.assertj.core.api.Assertions;14import java.util.Arrays;15import java.util.concurrent.atomic.AtomicReferenceArray;16import java.util.List;17import java.util.ArrayList;18public class Test {19 public static void main(String[] args) {20 AtomicReferenceArray<String> expected = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});21 AtomicReferenceArray<String> actual = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});22 Assertions.assertThat(actual).as("Test").usingRecursiveComparison().isEqualTo(expected);23 }24}25import org.assertj.core.api.Assertions;26import java.util.Arrays;27import java.util.concurrent.atomic.AtomicReferenceArray;28import java.util.List;29import java.util.ArrayList;30public class Test {31 public static void main(String[] args) {32 AtomicReferenceArray<String> expected = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});33 AtomicReferenceArray<String> actual = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});34 Assertions.assertThat(actual).as("Test").usingRecursiveComparison().isEqualTo(expected);35 }36}37import org.assertj.core.api.Assertions;38import java.util.Arrays;39import java.util.concurrent.atomic.AtomicReferenceArray;40import java.util.List;41import java.util.ArrayList;42public class Test {43 public static void main(String[] args) {44 AtomicReferenceArray<String> expected = new AtomicReferenceArray<String>(new String[]{"a", "b", "c"});45 AtomicReferenceArray<String> actual = new AtomicReferenceArray<String>(new String[]{"a

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1package org.assertj.core.api;2import static org.assertj.core.api.Assertions.assertThat;3import java.util.concurrent.atomic.AtomicReferenceArray;4public class AtomicReferenceArrayAssert_compare_Test {5 public void test_compare() {6 AtomicReferenceArray<String> atomicReferenceArray1 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });7 AtomicReferenceArray<String> atomicReferenceArray2 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });8 AtomicReferenceArray<String> atomicReferenceArray3 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });9 AtomicReferenceArray<String> atomicReferenceArray4 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });10 AtomicReferenceArray<String> atomicReferenceArray5 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });11 AtomicReferenceArray<String> atomicReferenceArray6 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });12 AtomicReferenceArray<String> atomicReferenceArray7 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });13 AtomicReferenceArray<String> atomicReferenceArray8 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });14 AtomicReferenceArray<String> atomicReferenceArray9 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });15 AtomicReferenceArray<String> atomicReferenceArray10 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });16 AtomicReferenceArray<String> atomicReferenceArray11 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });17 AtomicReferenceArray<String> atomicReferenceArray12 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });18 AtomicReferenceArray<String> atomicReferenceArray13 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });19 AtomicReferenceArray<String> atomicReferenceArray14 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });20 AtomicReferenceArray<String> atomicReferenceArray15 = new AtomicReferenceArray<>(new String[] { "a", "b", "c" });

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.*;2public class AssertJAtomicReferenceArrayAssertCompareMethod {3 public static void main(String[] args) {4 AtomicReferenceArray<Integer> array1 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3});5 AtomicReferenceArray<Integer> array2 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3});6 AtomicReferenceArray<Integer> array3 = new AtomicReferenceArray<>(new Integer[]{2, 3, 4});7 AtomicReferenceArray<Integer> array4 = new AtomicReferenceArray<>(new Integer[]{1, 2, 3, 4});8 Assertions.assertThat(array1).usingComparatorForElementFieldsWithType((i1, i2) -> i1 - i2, Integer.class).containsExactly(array2);9 Assertions.assertThat(array1).usingComparatorForElementFieldsWithType((i1, i2) -> i1 - i2, Integer.class).doesNotContain(array3);10 Assertions.assertThat(array1).usingComparatorForElementFieldsWithType((i1, i2) -> i1 - i2, Integer.class).doesNotContain(array4);11 }12}

Full Screen

Full Screen

compare

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.Assertions;2AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<String>(new String[] {"a", "b", "c"});3Assertions.assertThat(atomicReferenceArray).hasSameSizeAs(new String[] {"a", "b", "c"});4Assertions.assertThat(atomicReferenceArray).hasSameSizeAs(new String[] {"a", "b", "c", "d"});5import org.assertj.core.api.Assertions;6AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<String>(new String[] {"a", "b", "c"});7Assertions.assertThat(atomicReferenceArray).hasSameSizeAs(new String[] {"a", "b", "c"});8Assertions.assertThat(atomicReferenceArray).hasSameSizeAs(new String[] {"a", "b", "c", "d"});9org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.lang.String[] other)10org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.lang.Object[] other)11org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.util.Collection<?> other)12org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.lang.Iterable<?> other)13org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.util.List<?> other)14org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.util.Map<?, ?> other)15org.assertj.core.api.AtomicReferenceArrayAssert<java.lang.String> hasSameSizeAs(java.util.Set<?> other)16AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<String>(new String[] {"a", "b", "c"});17assertThat(atomicReferenceArray).hasSameSizeAs(new String[] {"a", "b", "c"});18assertThat(atomicReferenceArray).hasSameSizeAs(new String[] {"a", "b", "c", "d"});19AtomicReferenceArray<String> atomicReferenceArray = new AtomicReferenceArray<String>(new String[] {"a", "b", "c"});20assertThat(atomicReferenceArray).hasSameSizeAs(new Object[] {"a", "b", "c"});21assertThat(atomicReference

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Assertj automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in AtomicReferenceArrayAssert

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful