/** * Verifies that each element value satisfies the given condition * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<String> abc = new AtomicReferenceArray<>(new String[]{"a", "b", "c"}); * AtomicReferenceArray<String> abcc = new AtomicReferenceArray<>(new String[]{"a", "b", "cc"}); * * Condition<String> singleCharacterString * = new Condition<>(s -> s.length() == 1, "single character String"); * * // assertion will pass * assertThat(abc).are(singleCharacterString); * * // assertion will fail * assertThat(abcc).are(singleCharacterString);</code></pre> * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element cannot be cast to T. * @throws AssertionError if one or more elements don't satisfy the given condition. */ @Override public AtomicReferenceArrayAssert<T> are(Condition<? super T> condition) { arrays.assertAre(info, array, condition); return myself; }
/** * Verifies that there are <b>at least</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<Integer> oneThwoThree = new AtomicReferenceArray<>(new Integer[]{1, 2, 3}); * * Condition<Integer> oddNumber = new Condition<>(value % 2 == 1, "odd number"); * * // assertion will pass * oneThwoThree.areAtLeast(2, oddNumber); * * // assertion will fail * oneThwoThree.areAtLeast(3, oddNumber);</code></pre> * * @param times the minimum number of times the condition should be verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element can not be cast to T. * @throws AssertionError if the number of elements satisfying the given condition is < n. */ @Override public AtomicReferenceArrayAssert<T> areAtLeast(int times, Condition<? super T> condition) { arrays.assertAreAtLeast(info, array, times, condition); return myself; }
/** * Verifies that there are <b>at most</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<Integer> oneThwoThree = new AtomicReferenceArray<>(new Integer[]{1, 2, 3}); * * Condition<Integer> oddNumber = new Condition<>(value % 2 == 1, "odd number"); * * // assertions will pass * oneThwoThree.areAtMost(2, oddNumber); * oneThwoThree.areAtMost(3, oddNumber); * * // assertion will fail * oneThwoThree.areAtMost(1, oddNumber);</code></pre> * * @param times the number of times the condition should be at most verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element cannot be cast to T. * @throws AssertionError if the number of elements satisfying the given condition is > n. */ @Override public AtomicReferenceArrayAssert<T> areAtMost(int times, Condition<? super T> condition) { arrays.assertAreAtMost(info, array, times, condition); return myself; }
/** * Verifies that the actual group contains the given values, in any order. * <p> * Example : * <pre><code class='java'> String[] abc = {"a", "b", "c"}; * * // assertions will pass * assertThat(abc).contains("b", "a"); * assertThat(abc).contains("b", "a", "b"); * * // assertions will fail * assertThat(abc).contains("d"); * assertThat(abc).contains("c", "d");</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain the given values. */ @Override public SELF contains(@SuppressWarnings("unchecked") ELEMENT... values) { arrays.assertContains(info, actual, values); return myself; }
/** * Verifies that the actual array contains at least a null element. * <p> * Example : * <pre><code class='java'> String[] abc = {"a", "b", "c"}; * String[] abNull = {"a", "b", null}; * * // assertion will pass * assertThat(abNull).containsNull(); * * // assertion will fail * assertThat(abc).containsNull();</code></pre> * * @return {@code this} assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain a null element. */ @Override public SELF containsNull() { arrays.assertContainsNull(info, actual); return myself; }
/** * Verifies that the actual array contains all the elements of given {@code Iterable}, in any order. * <p> * Example : * <pre><code class='java'> String[] abc = {"a", "b", "c"}; * * // assertion will pass * assertThat(abc).containsAll(Arrays.asList("b", "c")); * * // assertions will fail * assertThat(abc).containsAll(Arrays.asList("d")); * assertThat(abc).containsAll(Arrays.asList("a", "b", "c", "d"));</code></pre> * * @param iterable the given {@code Iterable} we will get elements from. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain all the elements of given {@code Iterable}. */ @Override public SELF containsAll(Iterable<? extends ELEMENT> iterable) { arrays.assertContainsAll(info, actual, iterable); return myself; }
/** * Verifies that each element value does not satisfy the given condition * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<String> abc = new AtomicReferenceArray<>(new String[]{"a", "b", "c"}); * AtomicReferenceArray<String> abcc = new AtomicReferenceArray<>(new String[]{"a", "b", "cc"}); * * Condition<String> moreThanOneCharacter = * = new Condition<>(s -> s.length() > 1, "more than one character"); * * // assertion will pass * assertThat(abc).areNot(moreThanOneCharacter); * * // assertion will fail * assertThat(abcc).areNot(moreThanOneCharacter);</code></pre> * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element cannot be cast to T. * @throws AssertionError if one or more elements satisfy the given condition. */ @Override public AtomicReferenceArrayAssert<T> areNot(Condition<? super T> condition) { arrays.assertAreNot(info, array, condition); return myself; }
/** * Verifies that there are <b>exactly</b> <i>n</i> elements in the actual AtomicReferenceArray satisfying the given condition. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<Integer> oneThwoThree = new AtomicReferenceArray<>(new Integer[]{1, 2, 3}); * * Condition<Integer> oddNumber = new Condition<>(value % 2 == 1, "odd number"); * * // assertion will pass * oneThwoThree.areExactly(2, oddNumber); * * // assertions will fail * oneThwoThree.areExactly(1, oddNumber); * oneThwoThree.areExactly(3, oddNumber);</code></pre> * * @param times the exact number of times the condition should be verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element cannot be cast to T. * @throws AssertionError if the number of elements satisfying the given condition is ≠ n. */ @Override public AtomicReferenceArrayAssert<T> areExactly(int times, Condition<? super T> condition) { arrays.assertAreExactly(info, array, times, condition); return myself; }
/** * Verifies that the actual AtomicReferenceArray contains only the given values and nothing else, <b>in any order</b> and ignoring duplicates (i.e. once a value is found, its duplicates are also considered found).. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<String> abc = new AtomicReferenceArray<>(new String[]{"a", "b", "c"}); * * // assertions will pass * assertThat(abc).containsOnly("c", "b", "a") * .containsOnly("a", "a", "b", "c", "c"); * * // assertion will fail because "c" is missing from the given values * assertThat(abc).containsOnly("a", "b"); * // assertion will fail because abc does not contain "d" * assertThat(abc).containsOnly("a", "b", "c", "d");</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual AtomicReferenceArray is {@code null}. * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values, i.e. the actual AtomicReferenceArray contains some * or none of the given values, or the actual AtomicReferenceArray contains more values than the given ones. * @since 2.7.0 / 3.7.0 */ @Override public AtomicReferenceArrayAssert<T> containsOnly(@SuppressWarnings("unchecked") T... values) { arrays.assertContainsOnly(info, array, values); return myself; }
@CheckReturnValue public AtomicReferenceArrayAssert<T> usingElementComparator(Comparator<? super T> elementComparator) { this.arrays = new ObjectArrays(new ComparatorBasedComparisonStrategy(elementComparator)); objects = new Objects(new AtomicReferenceArrayElementComparisonStrategy<>(elementComparator)); return myself;
/** * Verifies that the actual AtomicReferenceArray contains the given values, in any order. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<String> abc = new AtomicReferenceArray<>(new String[]{"a", "b", "c"}); * * // assertions will pass * assertThat(abc).contains("b", "a") * .contains("b", "a", "b"); * * // assertions will fail * assertThat(abc).contains("d"); * assertThat(abc).contains("c", "d");</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual AtomicReferenceArray is {@code null}. * @throws AssertionError if the actual AtomicReferenceArray does not contain the given values. * @since 2.7.0 / 3.7.0 */ @Override public AtomicReferenceArrayAssert<T> contains(@SuppressWarnings("unchecked") T... values) { arrays.assertContains(info, array, values); return myself; }
/** * Verifies that the actual AtomicReferenceArray contains at least a null element. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<String> abc = new AtomicReferenceArray<>(new String[]{"a", "b", "c"}); * AtomicReferenceArray<String> abNull = new AtomicReferenceArray<>(new String[]{"a", "b", null}); * * // assertion will pass * assertThat(abNull).containsNull(); * * // assertion will fail * assertThat(abc).containsNull();</code></pre> * * @return {@code this} assertion object. * @throws AssertionError if the actual AtomicReferenceArray is {@code null}. * @throws AssertionError if the actual AtomicReferenceArray does not contain a null element. */ @Override public AtomicReferenceArrayAssert<T> containsNull() { arrays.assertContainsNull(info, array); return myself; }
/** * Verifies that the actual AtomicReferenceArray contains all the elements of given {@code Iterable}, in any order. * <p> * Example : * <pre><code class='java'> AtomicReferenceArray<String> abc = new AtomicReferenceArray<>(new String[]{"a", "b", "c"}); * * // assertion will pass * assertThat(abc).containsAll(Arrays.asList("b", "c")); * * // assertions will fail * assertThat(abc).containsAll(Arrays.asList("d")); * assertThat(abc).containsAll(Arrays.asList("a", "b", "c", "d"));</code></pre> * * @param iterable the given {@code Iterable} we will get elements from. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual AtomicReferenceArray is {@code null}. * @throws AssertionError if the actual AtomicReferenceArray does not contain all the elements of given {@code Iterable}. */ @Override public AtomicReferenceArrayAssert<T> containsAll(Iterable<? extends T> iterable) { arrays.assertContainsAll(info, array, iterable); return myself; }
/** * Verifies that each element value does not satisfy the given condition * <p> * Example : * <pre><code class='java'> String[] abc = {"a", "b", "c"}; * String[] abcc = {"a", "b", "cc"}; * * Condition<String> moreThanOneCharacter = * = new Condition<>(s -> s.length() > 1, "more than one character"); * * // assertion will pass * assertThat(abc).areNot(moreThanOneCharacter); * * // assertion will fail * assertThat(abcc).areNot(moreThanOneCharacter);</code></pre> * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element cannot be cast to ELEMENT. * @throws AssertionError if one or more elements satisfy the given condition. */ @Override public SELF areNot(Condition<? super ELEMENT> condition) { arrays.assertAreNot(info, actual, condition); return myself; }
/** * Verifies that there are <b>exactly</b> <i>n</i> elements in the actual group satisfying the given condition. * <p> * Example : * <pre><code class='java'> int[] oneTwoThree = {1, 2, 3}; * * Condition<Integer> oddNumber = new Condition<>(value % 2 == 1, "odd number"); * * // assertion will pass * oneTwoThree.areExactly(2, oddNumber); * * // assertions will fail * oneTwoThree.areExactly(1, oddNumber); * oneTwoThree.areExactly(3, oddNumber);</code></pre> * * @param times the exact number of times the condition should be verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element cannot be cast to ELEMENT. * @throws AssertionError if the number of elements satisfying the given condition is ≠ n. */ @Override public SELF areExactly(int times, Condition<? super ELEMENT> condition) { arrays.assertAreExactly(info, actual, times, condition); return myself; }
arrays.assertContainsOnly(info, actual, values); return myself;
@CheckReturnValue public AtomicReferenceArrayAssert<T> usingElementComparator(Comparator<? super T> elementComparator) { this.arrays = new ObjectArrays(new ComparatorBasedComparisonStrategy(elementComparator)); objects = new Objects(new AtomicReferenceArrayElementComparisonStrategy<>(elementComparator)); return myself;
/** * Verifies that the actual AtomicReferenceArray contains the given object at the given index. * <p> * Example: * <pre><code class='java'> AtomicReferenceArray<Ring> elvesRings = new AtomicReferenceArray<>(new Ring[]{vilya, nenya, narya}); * * // assertions will pass * assertThat(elvesRings).contains(vilya, atIndex(0)) * .contains(nenya, atIndex(1)) * .contains(narya, atIndex(2)); * * // assertions will fail * assertThat(elvesRings).contains(vilya, atIndex(1)); * assertThat(elvesRings).contains(nenya, atIndex(2)); * assertThat(elvesRings).contains(narya, atIndex(0));</code></pre> * * @param value the object to look for. * @param index the index where the object should be stored in the actual AtomicReferenceArray. * @return this assertion object. * @throws AssertionError if the actual AtomicReferenceArray is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * AtomicReferenceArray. * @throws AssertionError if the actual AtomicReferenceArray does not contain the given object at the given index. */ @Override public AtomicReferenceArrayAssert<T> contains(T value, Index index) { arrays.assertContains(info, array, value, index); return myself; }
/** * Verifies that the actual array contains at least a null element. * <p> * Example : * <pre><code class='java'> String[] abc = {"a", "b", "c"}; * String[] abNull = {"a", "b", null}; * * // assertion will pass * assertThat(abNull).containsNull(); * * // assertion will fail * assertThat(abc).containsNull();</code></pre> * * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain a null element. */ @Override public SELF containsNull() { arrays.assertContainsNull(info, actual); return myself; }
/** * Verifies that the actual array contains all the elements of given {@code Iterable}, in any order. * <p> * Example : * <pre><code class='java'> String[] abc = {"a", "b", "c"}; * * // assertion will pass * assertThat(abc).containsAll(Arrays.asList("b", "c")); * * // assertions will fail * assertThat(abc).containsAll(Arrays.asList("d")); * assertThat(abc).containsAll(Arrays.asList("a", "b", "c", "d"));</code></pre> * * @param iterable the given {@code Iterable} we will get elements from. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain all the elements of given {@code Iterable}. */ @Override public SELF containsAll(Iterable<? extends ELEMENT> iterable) { arrays.assertContainsAll(info, actual, iterable); return myself; }