Class RangeAssert<T extends Comparable<T>>

java.lang.Object
org.assertj.core.api.AbstractAssert<RangeAssert<T>,Range<T>>
org.assertj.guava.api.RangeAssert<T>
Type Parameters:
T - the type of elements of the tested Range value
All Implemented Interfaces:
Assert<RangeAssert<T>,Range<T>>, Descriptable<RangeAssert<T>>, ExtensionPoints<RangeAssert<T>,Range<T>>

public class RangeAssert<T extends Comparable<T>> extends AbstractAssert<RangeAssert<T>,Range<T>>
Assertions for guava Range.

To create an instance of this class, invoke Assertions.assertThat(com.google.common.collect.Range)

Author:
Marcin KwaczyƄski
  • Constructor Details

    • RangeAssert

      protected RangeAssert(Range<T> actual)
  • Method Details

    • contains

      public RangeAssert<T> contains(T... values)
      Verifies that the actual Range contains the given values.

      Example :

       Range<Integer> range = Range.closed(10, 12);
      
       assertThat(range).contains(10, 11, 12);
      Parameters:
      values - the values to look for in actual Range.
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range does not contain the given values.
    • doesNotContain

      public RangeAssert<T> doesNotContain(T... values)
      Verifies that the actual Range does not contain the given values.

      Example :

       Range<Integer> range = Range.closed(10, 12);
      
       assertThat(range).doesNotContain(13);
      Parameters:
      values - the values that should not be present in actual Range.
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range contains the given values.
    • hasClosedLowerBound

      public RangeAssert<T> hasClosedLowerBound() throws AssertionError
      Verifies that the actual Range lower bound is closed.

      Example :

       Range<Integer> range = Range.closed(10, 12);
      
       assertThat(range).hasClosedLowerBound();
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range lower bound is opened.
    • hasClosedUpperBound

      public RangeAssert<T> hasClosedUpperBound() throws AssertionError
      Verifies that the actual Range upper bound is closed.

      Example :

       Range<Integer> range = Range.closed(10, 12);
      
       assertThat(range).hasClosedUpperBound();
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range upper bound is opened.
    • hasLowerEndpointEqualTo

      public RangeAssert<T> hasLowerEndpointEqualTo(T value) throws AssertionError
      Verifies that the actual Range lower endpoint is equal to the given value.

      Example :

       Range<Integer> range = Range.closed(10, 12);
      
       assertThat(range).hasLowerEndpointEqualTo(10);
      Parameters:
      value - Range expected lower bound value.
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range does not have lower endpoint equal to the given values.
    • hasOpenedLowerBound

      public RangeAssert<T> hasOpenedLowerBound() throws AssertionError
      Verifies that the actual Range lower bound is opened.

      Example :

       Range<Integer> range = Range.open(1, 2);
      
       assertThat(range).hasOpenedLowerBound();
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range lower bound is closed.
    • hasOpenedUpperBound

      public RangeAssert<T> hasOpenedUpperBound() throws AssertionError
      Verifies that the actual Range upper bound is opened.

      Example :

       Range<Integer> range = Range.open(10, 12);
      
       assertThat(range).hasOpenedUpperBound();
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range upper bound is closed.
    • hasUpperEndpointEqualTo

      public RangeAssert<T> hasUpperEndpointEqualTo(T value) throws AssertionError
      Verifies that the actual Range upper endpoint is equal to the given value.

      Example :

       Range<Integer> range = Range.open(10, 12);
      
       assertThat(range).hasUpperEndpointEqualTo(12);
      Parameters:
      value - Range expected upper bound value.
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range does not have upper endpoint equal to the given values.
    • isEmpty

      public RangeAssert<T> isEmpty() throws AssertionError
      Verifies that the actual Range is empty.

      Example :

       Range<Integer> range = Range.closedOpen(0, 0);
      
       assertThat(range).isEmpty();
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range is not empty.
    • isNotEmpty

      public RangeAssert<T> isNotEmpty() throws AssertionError
      Verifies that the actual Range is not empty.

      Example :

       Range<Integer> range = Range.closed(0, 0);
      
       assertThat(range).isNotEmpty();
      Returns:
      this RangeAssert for assertions chaining.
      Throws:
      AssertionError - if the actual Range is null.
      AssertionError - if the actual Range is empty.