Java Examples for org.assertj.guava.util.ExceptionUtils.throwIllegalArgumentExceptionIfTrue

The following java examples will help you to understand the usage of org.assertj.guava.util.ExceptionUtils.throwIllegalArgumentExceptionIfTrue. These source code samples are taken from different open source projects.

Example 1
Project: assertj-guava-master  File: RangeAssert.java View source code
/**
   * Verifies that the actual {@link com.google.common.collect.Range} contains the given values.<br>
   * <p>
   * Example :
   *
   * <pre><code class='java'> Range<Integer> range = Range.closed(10, 12);
   *
   * assertThat(range).contains(10, 11, 12);</code></pre>
   *
   * @param values the values to look for in actual {@link com.google.common.collect.Range}.
   * @return this {@link OptionalAssert} for assertions chaining.
   * @throws AssertionError if the actual {@link com.google.common.collect.Range} is {@code null}.
   * @throws AssertionError if the actual {@link com.google.common.collect.Range} does not contain the given values.
   */
public RangeAssert<T> contains(@SuppressWarnings("unchecked") final T... values) {
    Objects.instance().assertNotNull(info, actual);
    throwIllegalArgumentExceptionIfTrue(values == null, "The values to look for should not be null");
    // if both actual and values are empty, then assertion passes.
    if (values.length == 0 && actual.isEmpty())
        return this;
    throwIllegalArgumentExceptionIfTrue(values.length == 0, "The values to look for should not be empty");
    final List<T> valuesNotFound = newArrayList();
    for (final T value : values) {
        if (!actual.contains(value)) {
            valuesNotFound.add(value);
        }
    }
    if (!valuesNotFound.isEmpty()) {
        throw failures.failure(info, shouldContain(actual, values, valuesNotFound));
    }
    return this;
}