/** * Verifies that the actual group contains the given values only once. * <p> * Examples : * <pre><code class='java'> // array is a factory method to create arrays. * * // assertions will pass * assertThat(array("winter", "is", "coming")).containsOnlyOnce("winter"); * assertThat(array("winter", "is", "coming")).containsOnlyOnce("coming", "winter"); * * // assertions will fail * assertThat(array("winter", "is", "coming")).containsOnlyOnce("Lannister"); * assertThat(array("Arya", "Stark", "daughter", "of", "Ned", "Stark")).containsOnlyOnce("Stark"); * assertThat(array("Arya", "Stark", "daughter", "of", "Ned", "Stark")).containsOnlyOnce("Stark", "Lannister", "Arya");</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, i.e. the actual group contains some * or none of the given values, or the actual group contains more than once these values. */ @Override public SELF containsOnlyOnce(@SuppressWarnings("unchecked") ELEMENT... values) { arrays.assertContainsOnlyOnce(info, actual, values); return myself; }
/** * Verifies that the actual AtomicReferenceArray contains the given values only once. * <p> * Examples : * <pre><code class='java'> // array is a factory method to create arrays. * AtomicReferenceArray<String> got = new AtomicReferenceArray<>(new String[]{"winter", "is", "coming"}); * * // assertions will pass * assertThat(got).containsOnlyOnce("winter") * .containsOnlyOnce("coming", "winter"); * * // assertions will fail * AtomicReferenceArray<String> stark= new AtomicReferenceArray<>(new String[]{"Arya", "Stark", "daughter", "of", "Ned", "Stark")}); * assertThat(got).containsOnlyOnce("Lannister"); * assertThat(stark).containsOnlyOnce("Stark");</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 than once these values. * @since 2.7.0 / 3.7.0 */ @Override public AtomicReferenceArrayAssert<T> containsOnlyOnce(@SuppressWarnings("unchecked") T... values) { arrays.assertContainsOnlyOnce(info, array, values); return myself; }
/** * Verifies that the actual array contains the given values only once. * <p> * Examples : * <pre><code class='java'> // array is a factory method to create arrays. * * // assertions will pass * assertThat(array("winter", "is", "coming")).containsOnlyOnce("winter"); * assertThat(array("winter", "is", "coming")).containsOnlyOnce("coming", "winter"); * * // assertions will fail * assertThat(array("winter", "is", "coming")).containsOnlyOnce("Lannister"); * assertThat(array("Arya", "Stark", "daughter", "of", "Ned", "Stark")).containsOnlyOnce("Stark"); * assertThat(array("Arya", "Stark", "daughter", "of", "Ned", "Stark")).containsOnlyOnce("Stark", "Lannister", "Arya");</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 array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some * or none of the given values, or the actual array contains more than once these values. */ @Override public SELF containsOnlyOnce(@SuppressWarnings("unchecked") ELEMENT... values) { arrays.assertContainsOnlyOnce(info, actual, values); return myself; }
/** * Verifies that the actual AtomicReferenceArray contains the given values only once. * <p> * Examples : * <pre><code class='java'> // array is a factory method to create arrays. * AtomicReferenceArray<String> got = new AtomicReferenceArray<>(new String[]{"winter", "is", "coming"}); * * // assertions will pass * assertThat(got).containsOnlyOnce("winter") * .containsOnlyOnce("coming", "winter"); * * // assertions will fail * AtomicReferenceArray<String> stark= new AtomicReferenceArray<>(new String[]{"Arya", "Stark", "daughter", "of", "Ned", "Stark")}); * assertThat(got).containsOnlyOnce("Lannister"); * assertThat(stark).containsOnlyOnce("Stark");</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 than once these values. * @since 2.7.0 / 3.7.0 */ @Override public AtomicReferenceArrayAssert<T> containsOnlyOnce(@SuppressWarnings("unchecked") T... values) { arrays.assertContainsOnlyOnce(info, array, values); return myself; }
/** {@inheritDoc} */ @Override public S containsOnlyOnce(@SuppressWarnings("unchecked")T... values) { arrays.assertContainsOnlyOnce(info, actual, values); return myself; }