Class BDDAssumptions


  • public final class BDDAssumptions
    extends Object
    Behavior-driven development style entry point for assumption methods for different types, which allow to skip test execution when assumptions are not met.

    The difference with the Assumptions class is that entry point methods are named given instead of assumeThat.

    BDDAssumptions and BDDAssertions complement each other to allow a fluent Behavior-driven development.

    Examples:

     String hobbit = "HOBBIT";
     List<String> fellowshipOfTheRing = list("Aragorn", "Gandalf", "Frodo", "Legolas"); // and more
    
     @Test
     public void given_the_assumption_is_not_met_the_test_is_skipped() {
       given(hobbit).isEqualTo("ORC");
       // ... following code is not executed
       then(fellowshipOfTheRing).contains("Sauron");
     }
    
     @Test
     public void given_the_assumption_is_met_the_test_is_executed() {
       given(hobbit).isEqualTo("HOBBIT");
       // ... following code is executed
       then(fellowshipOfTheRing).doesNotContain("Sauron");
     }
    Since:
    3.14.0
    Author:
    Gonzalo Müller
    • Constructor Detail

      • BDDAssumptions

        private BDDAssumptions()
    • Method Detail

      • given

        public static AbstractBooleanAssert<?> given​(boolean actual)
        Creates a new assumption's instance for a boolean value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(true).isTrue();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(true).isFalse();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual boolean value to be validated.
        Returns:
        the AbstractBooleanAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractBooleanAssert<?> given​(Boolean actual)
        Creates a new assumption's instance for a Boolean value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Boolean.valueOf(true)).isTrue();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Boolean.valueOf(true)).isFalse();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Boolean value to be validated.
        Returns:
        the AbstractBooleanAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractBooleanArrayAssert<?> given​(boolean[] actual)
        Creates a new assumption's instance for a booleans' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new boolean[] { true, true }).contains(true);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new boolean[] { true, true }).contains(false);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual booleans' array to be validated.
        Returns:
        the AbstractBooleanArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractByteAssert<?> given​(byte actual)
        Creates a new assumption's instance for a byte value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((byte) 1).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((byte) 1).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual byte value to be validated.
        Returns:
        the AbstractByteAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractByteAssert<?> given​(Byte actual)
        Creates a new assumption's instance for a Byte value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Byte.valueOf("1")).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Byte.valueOf("1")).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Byte value to be validated.
        Returns:
        the AbstractByteAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractByteArrayAssert<?> given​(byte[] actual)
        Creates a new assumption's instance for a bytes' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new byte[] { 1, 2 }).contains((byte) 1);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new byte[] { 1, 2 }).contains((byte) 0);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual bytes' array to be validated.
        Returns:
        the AbstractByteArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractShortAssert<?> given​(short actual)
        Creates a new assumption's instance for a short value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((short) 1).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((short) 1).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual short value to be validated.
        Returns:
        the AbstractShortAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractShortAssert<?> given​(Short actual)
        Creates a new assumption's instance for a Short value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Short.valueOf("1")).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Short.valueOf("1")).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Short value to be validated.
        Returns:
        the AbstractShortAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractShortArrayAssert<?> given​(short[] actual)
        Creates a new assumption's instance for a shorts' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new short[] { 1, 2 }).contains((short) 1);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new short[] { 1, 2 }).contains((short) 0);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual shorts' array to be validated.
        Returns:
        the AbstractShortArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractIntegerAssert<?> given​(int actual)
        Creates a new assumption's instance for an int value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(1).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(1).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual int value to be validated.
        Returns:
        the AbstractIntegerAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractIntegerAssert<?> given​(Integer actual)
        Creates a new assumption's instance for an Integer value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Integer.valueOf("1")).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Integer.valueOf("1")).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Integer value to be validated.
        Returns:
        the AbstractIntegerAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractIntArrayAssert<?> given​(int[] actual)
        Creates a new assumption's instance for an ints' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new int[] { 1, 2 }).contains((short) 1);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new int[] { 1, 2 }).contains((short) 0);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual ints' array to be validated.
        Returns:
        the AbstractIntArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractBigIntegerAssert<?> given​(BigInteger actual)
        Creates a new assumption's instance for a BigInteger value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(BigInteger.valueOf(1L)).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(BigInteger.valueOf(1L)).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual BigInteger value to be validated.
        Returns:
        the AbstractBigIntegerAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractLongAssert<?> given​(long actual)
        Creates a new assumption's instance for a long value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(1L).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(1L).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual long value to be validated.
        Returns:
        the AbstractLongAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractLongAssert<?> given​(Long actual)
        Creates a new assumption's instance for a Long value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Long.valueOf(1L)).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Long.valueOf(1L)).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Long value to be validated.
        Returns:
        the AbstractLongAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractLongArrayAssert<?> given​(long[] actual)
        Creates a new assumption's instance for a longs' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new long[] { 1, 2 }).contains(1L);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new long[] { 1, 2 }).contains(0L);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual longs' array to be validated.
        Returns:
        the AbstractLongArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractFloatAssert<?> given​(float actual)
        Creates a new assumption's instance for a float value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(1.0f).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(1.0f).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual float value to be validated.
        Returns:
        the AbstractFloatAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractFloatAssert<?> given​(Float actual)
        Creates a new assumption's instance for a Float value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Float.valueOf(1.0f)).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Float.valueOf(1.0f)).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Float value to be validated.
        Returns:
        the AbstractFloatAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractFloatArrayAssert<?> given​(float[] actual)
        Creates a new assumption's instance for a floats' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new float[] { 1.0f, 2.0f }).contains(1.0f);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new float[] { 1.0f, 2.0f }).contains(0.0f);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual floats' array to be validated.
        Returns:
        the AbstractFloatArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractDoubleAssert<?> given​(double actual)
        Creates a new assumption's instance for a double value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(1.0).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(1.0).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual double value to be validated.
        Returns:
        the AbstractDoubleAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractDoubleAssert<?> given​(Double actual)
        Creates a new assumption's instance for a Double value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Double.valueOf(1.0f)).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Double.valueOf(1.0f)).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Double value to be validated.
        Returns:
        the AbstractDoubleAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractDoubleArrayAssert<?> given​(double[] actual)
        Creates a new assumption's instance for an doubles' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new double[] { 1.0, 2.0 }).contains(1.0);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new double[] { 1.0, 2.0 }).contains(0.0);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual doubles' array to be validated.
        Returns:
        the AbstractDoubleArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractBigDecimalAssert<?> given​(BigDecimal actual)
        Creates a new assumption's instance for a BigDecimal value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(BigDecimal.valueOf(1.0)).isOne();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(BigDecimal.valueOf(1.0)).isZero();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual BigDecimal value to be validated.
        Returns:
        the AbstractBigDecimalAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractCharacterAssert<?> given​(char actual)
        Creates a new assumption's instance for a char value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given('A').isUpperCase();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given('A').isLowerCase();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual char value to be validated.
        Returns:
        the AbstractCharacterAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractCharacterAssert<?> given​(Character actual)
        Creates a new assumption's instance for a Character value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Character.valueOf('A')).isUpperCase();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Character.valueOf('A')).isLowerCase();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Character value to be validated.
        Returns:
        the AbstractCharacterAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractCharArrayAssert<?> given​(char[] actual)
        Creates a new assumption's instance for an chars' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new char[] { 'A', 'B' }).contains('A');
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new char[] { 'A', 'B' }).contains('C');
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual chars' array to be validated.
        Returns:
        the AbstractCharacterAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractCharSequenceAssert<?,​? extends CharSequence> given​(CharSequence actual)
        Creates a new assumption's instance for a CharSequence value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((CharSequence) "Yoda").isNotEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((CharSequence) "Yoda").isNullOrEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual CharSequence value to be validated.
        Returns:
        the AbstractCharSequenceAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractStringAssert<?> given​(String actual)
        Creates a new assumption's instance for a String value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given("Yoda").isNotEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given("Yoda").isNullOrEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual String value to be validated.
        Returns:
        the AbstractStringAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractCharSequenceAssert<?,​? extends CharSequence> given​(StringBuilder actual)
        Creates a new assumption's instance for a StringBuilder value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new StringBuilder("Yoda")).isNotEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new StringBuilder("Yoda")).isNullOrEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual StringBuilder value to be validated.
        Returns:
        the AbstractCharSequenceAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractCharSequenceAssert<?,​? extends CharSequence> given​(StringBuffer actual)
        Creates a new assumption's instance for a StringBuffer value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new StringBuffer("Yoda")).isNotEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new StringBuffer("Yoda")).isNullOrEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual StringBuffer value to be validated.
        Returns:
        the AbstractCharSequenceAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractClassAssert<?> given​(Class<?> actual)
        Creates a new assumption's instance for a Class value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Number.class).isAssignableFrom(Long.class);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Number.class).isInterface();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Class value to be validated.
        Returns:
        the AbstractClassAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <T> ProxyableObjectAssert<T> given​(T actual)
        Creates a new assumption's instance for an object value.

        Examples:

        
         TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);
         TolkienCharacter mysteriousHobbit = new TolkienCharacter(null, 33, HOBBIT);
         

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(frodo).hasNoNullFieldsOrProperties();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(mysteriousHobbit).hasNoNullFieldsOrProperties();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        T - the type of the actual object.
        Parameters:
        actual - the actual object to be validated.
        Returns:
        the AbstractObjectAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <T> ProxyableObjectArrayAssert<T> given​(T[] actual)
        Creates a new assumption's instance for an objects' array.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new String[] { "A", "B" }).hasSizeGreaterThan(1);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new String[] { "A", "B" }).hasSizeGreaterThan(2);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        T - the type of elements of the actual objects' array.
        Parameters:
        actual - the actual objects' array to be validated..
        Returns:
        the AbstractObjectArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • givenObject

        public static <T> ProxyableObjectAssert<T> givenObject​(T actual)
        Creates a new assumption's instance for an object value.

        This overload is useful, when an overloaded method of given(...) takes precedence over the generic given(T), and the assumption requires to access some general assertion methods.

        Example:

        given(List) takes precedence over the generic given(T)

        then when using some base general assert methods, e.g. AbstractAssert.matches(Predicate), cast is necessary because given(List) "forgets" actual type:

        given(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc")); 
        with givenObject no cast is needed:
        givenObject(new LinkedList<>(asList("abc"))).matches(list -> list.getFirst().equals("abc")); 
        Type Parameters:
        T - the type of the actual object.
        Parameters:
        actual - the actual object to be validated.
        Returns:
        the AbstractObjectAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <T extends Comparable<? super T>> AbstractComparableAssert<?,​T> given​(Comparable<? super T> actual)
        Creates a new assumption's instance for a Comparable value.

        Examples:

        
          class Yoda implements Comparable<Yoda> {
            public int compareTo(Yoda to) {
              return 0;
            }
          }
         

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new Yoda()).isEqualByComparingTo(new Yoda());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new Yoda()).isNotEqualByComparingTo(new Yoda());
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        T - the type of the actual comparable value.
        Parameters:
        actual - the actual Comparable value to be validated.
        Returns:
        the AbstractComparableAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractThrowableAssert<?,​? extends Throwable> given​(Throwable actual)
        Creates a new assumption's instance for a Throwable value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new Exception("Yoda time")).hasMessage("Yoda time");
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new Exception("Yoda time")).hasMessage("");
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Throwable value to be validated.
        Returns:
        the AbstractThrowableAssert assertion object to be used for validation.
        Since:
        3.14.0
      • givenCode

        public static AbstractThrowableAssert<?,​? extends Throwable> givenCode​(ThrowableAssert.ThrowingCallable lambda)
        Creates a new assumption's instance from a no parameters lambda expression, () -> { /* some code */ }.

        Examples:

        No Exception required:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           givenCode(() -> {/* some code */ }).doesNotThrowAnyException();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           givenCode(() -> {/* some code */ }).hasMessage("Yoda time");
           // the remaining code is NOT executed.
           // ...
        }

        Exception required:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           givenCode(() -> {throw new Exception("Yoda time");}).hasMessage("Yoda time");
           // the remaining code is executed
           // ...
         

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           givenCode(() -> {throw new Exception("Yoda time");}).doesNotThrowAnyException();
           // the remaining code is NOT executed.
           // ...
        
        Parameters:
        lambda - the ThrowableAssert.ThrowingCallable or lambda with the code that may raise a throwable to be validated.
        Returns:
        the AbstractThrowableAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <ELEMENT> ProxyableIterableAssert<ELEMENT> given​(Iterable<? extends ELEMENT> actual)
        Creates a new assumption's instance for an Iterable value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
          given((Iterable<Integer>)(Arrays.asList(1, 2))).contains(2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
          given((Iterable<Integer>)(Arrays.asList(1, 2))).containsOnly(2);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        ELEMENT - the type of elements of actual iterable value.
        Parameters:
        actual - the actual Iterable value to be validated.
        Returns:
        the AbstractIterableAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <ELEMENT> IteratorAssert<ELEMENT> given​(Iterator<? extends ELEMENT> actual)
        Creates a new assumption's instance for an Iterator value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Arrays.asList(1, 2).iterator()).hasNext();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Arrays.asList(1, 2).iterator()).isExhausted();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        ELEMENT - the type of elements of actual iterator value.
        Parameters:
        actual - the actual Iterator value to be validated.
        Returns:
        the AbstractIteratorAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <ELEMENT> FactoryBasedNavigableListAssert<ProxyableListAssert<ELEMENT>,​List<? extends ELEMENT>,​ELEMENT,​ObjectAssert<ELEMENT>> given​(List<? extends ELEMENT> actual)
        Creates a new assumption's instance for a List value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Arrays.asList(1, 2)).contains(2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Arrays.asList(1, 2)).containsOnly(2);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        ELEMENT - the type of elements of actual list value.
        Parameters:
        actual - the actual List value to be validated.
        Returns:
        the AbstractListAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <K,​V> AbstractMapAssert<?,​?,​K,​V> given​(Map<K,​V> actual)
        Creates a new assumption's instance for a Map value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Collections.singletonMap(1, 2)).containsEntry(1, 2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Collections.singletonMap(1, 2)).containsEntry(2, 1);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        K - the type of keys in the actual map value.
        V - the type of values in the actual map value.
        Parameters:
        actual - the actual Map value to be validated.
        Returns:
        the AbstractMapAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <T> ProxyablePredicateAssert<T> given​(Predicate<T> actual)
        Creates a new assumption's instance for a Predicate value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((Predicate<Integer>)(value -> value > 0)).accepts(1, 2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((Predicate<Integer>)(value -> value > 0)).accepts(-2, -1);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        T - the type of the value contained in the actual predicate value.
        Parameters:
        actual - the actual Predicate value to be validated.
        Returns:
        the AbstractPredicateAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static IntPredicateAssert given​(IntPredicate actual)
        Creates a new assumption's instance for an IntPredicate value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((IntPredicate)(value -> value > 0)).accepts(1, 2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((IntPredicate)(value -> value > 0)).accepts(-2, -1);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual IntPredicate value to be validated.
        Returns:
        the IntPredicateAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static LongPredicateAssert given​(LongPredicate actual)
        Creates a new assumption's instance for a LongPredicate value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((LongPredicate)(value -> value > 0)).accepts(1, 2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((LongPredicate)(value -> value > 0)).accepts(-2, -1);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual LongPredicate value to be validated.
        Returns:
        the LongPredicateAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static DoublePredicateAssert given​(DoublePredicate actual)
        Creates a new assumption's instance for a DoublePredicate value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((DoublePredicate)(value -> value > 0)).accepts(1.0, 2.0);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((DoublePredicate)(value -> value > 0)).accepts(-2.0, -1.0);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual DoublePredicate value to be validated.
        Returns:
        the DoublePredicateAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <VALUE> OptionalAssert<VALUE> given​(Optional<VALUE> actual)
        Creates a new assumption's instance for an Optional value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Optional.empty()).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Optional.empty()).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        VALUE - the type of the value contained in the actual optional value.
        Parameters:
        actual - the actual Optional value to be validated.
        Returns:
        the OptionalAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static OptionalIntAssert given​(OptionalInt actual)
        Creates a new assumption's instance for an OptionalInt value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(OptionalInt.empty()).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(OptionalInt.empty()).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual OptionalInt value to be validated.
        Returns:
        the OptionalIntAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static OptionalLongAssert given​(OptionalLong actual)
        Creates a new assumption's instance for an OptionalLong value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(OptionalLong.empty()).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(OptionalLong.empty()).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual OptionalLong value to be validated.
        Returns:
        the OptionalLongAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static OptionalDoubleAssert given​(OptionalDouble actual)
        Creates a new assumption's instance for an OptionalDouble value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(OptionalDouble.empty()).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(OptionalDouble.empty()).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual OptionalDouble value to be validated.
        Returns:
        the OptionalDoubleAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <ELEMENT> AbstractListAssert<?,​List<? extends ELEMENT>,​ELEMENT,​ObjectAssert<ELEMENT>> given​(Stream<? extends ELEMENT> actual)
        Creates a new assumption's instance for a Stream value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Stream.of(1, 2)).contains(2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Stream.of(1, 2)).containsOnly(2);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        ELEMENT - the type of the value contained in the actual stream value.
        Parameters:
        actual - the actual Stream value to be validated.
        Returns:
        the AbstractListAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractListAssert<?,​List<? extends Integer>,​Integer,​ObjectAssert<Integer>> given​(IntStream actual)
        Creates a new assumption's instance for an IntStream value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(IntStream.of(1, 2)).contains(2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(IntStream.of(1, 2)).containsOnly(2);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual IntStream value to be validated.
        Returns:
        the AbstractListAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <ELEMENT> AbstractSpliteratorAssert<?,​ELEMENT> given​(Spliterator<ELEMENT> actual)
        Creates a new assumption's instance for a Spliterator value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Stream.of(1, 2).spliterator()).hasCharacteristics(Spliterator.SIZED)
           // the remaining code is executed
           ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Stream.of(1, 2).spliterator()).hasCharacteristics(Spliterator.DISTINCT)
           // the remaining code is NOT executed.
         }
        Type Parameters:
        ELEMENT - the type of the elements
        Parameters:
        actual - the actual Spliterator value to be validated.
        Returns:
        the AbstractSpliteratorAssert assertion object to be used for validation.
      • given

        public static AbstractListAssert<?,​List<? extends Long>,​Long,​ObjectAssert<Long>> given​(LongStream actual)
        Creates a new assumption's instance for a LongStream value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(LongStream.of(1, 2)).contains(2);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(LongStream.of(1, 2)).containsOnly(2);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual LongStream value to be validated.
        Returns:
        the AbstractListAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractListAssert<?,​List<? extends Double>,​Double,​ObjectAssert<Double>> given​(DoubleStream actual)
        Creates a new assumption's instance for a DoubleStream value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(DoubleStream.of(1.0, 2.0)).contains(2.0);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(DoubleStream.of(1.0, 2.0)).containsOnly(2.0);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual DoubleStream value to be validated.
        Returns:
        the AbstractListAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <RESULT> AbstractFutureAssert<?,​? extends Future<? extends RESULT>,​RESULT> given​(Future<RESULT> future)
        Creates a new assumption's instance for a Future value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Executors.newSingleThreadExecutor().submit(() -> {})).isNotCancelled();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Executors.newSingleThreadExecutor().submit(() -> {})).isCancelled();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        RESULT - the type of the value contained in the actual future value.
        Parameters:
        future - the Future value to be validated.
        Returns:
        the AbstractFutureAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <RESULT> CompletableFutureAssert<RESULT> given​(CompletableFuture<RESULT> future)
        Creates a new assumption's instance for a CompletableFuture value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(CompletableFuture.completedFuture​(1)).isDone();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(CompletableFuture.completedFuture​(1)).isNotDone();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        RESULT - the type of the value contained in the actual future value.
        Parameters:
        future - the CompletableFuture value to be validated.
        Returns:
        the AbstractCompletableFutureAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <RESULT> CompletableFutureAssert<RESULT> given​(CompletionStage<RESULT> stage)
        Creates a new assumption's instance for a CompletionStage value.

        Converts the CompletionStage into a CompletableFuture. If the given CompletionStage is null, the associated CompletableFuture will also be null.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given((CompletionStage<Integer>) CompletableFuture.completedFuture​(1)).isDone();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given((CompletionStage<Integer>) CompletableFuture.completedFuture​(1)).isNotDone();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        RESULT - the type of the value contained in the actual future value.
        Parameters:
        stage - the CompletionStage value to be validated.
        Returns:
        the AbstractCompletableFutureAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AtomicBooleanAssert given​(AtomicBoolean actual)
        Creates a new assumption's instance for an AtomicBoolean value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicBoolean(true)).isTrue();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicBoolean(true)).isFalse();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual AtomicBoolean value to be validated.
        Returns:
        the AtomicBooleanAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AtomicIntegerAssert given​(AtomicInteger actual)
        Creates a new assumption's instance for an AtomicInteger value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicInteger(1)).hasNonNegativeValue();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicInteger(1)).hasNegativeValue();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual AtomicInteger value to be validated.
        Returns:
        the AtomicIntegerAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AtomicIntegerArrayAssert given​(AtomicIntegerArray actual)
        Creates a new assumption's instance for an AtomicIntegerArray value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicIntegerArray(0)).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicIntegerArray(0)).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual AtomicIntegerArray value to be validated.
        Returns:
        the AtomicIntegerArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> given​(AtomicIntegerFieldUpdater<OBJECT> actual)
        Creates a new assumption's instance for an AtomicIntegerFieldUpdater value.

        Examples:

        
         class Yoda {
           public volatile int field = 0;
         }
         
        
         AtomicIntegerFieldUpdater actual = AtomicIntegerFieldUpdater.newUpdater​(Yoda.class, "field");
         Yoda value = new Yoda();
         actual.set(value, 1);
         

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(actual).hasValue(1, value);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(actual).hasValue(2, value));
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        OBJECT - the type of the object holding the updatable field which gets updated by the the actual value.
        Parameters:
        actual - the actual AtomicIntegerFieldUpdater value to be validated.
        Returns:
        the AtomicIntegerFieldUpdaterAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AtomicLongAssert given​(AtomicLong actual)
        Creates a new assumption's instance for an AtomicLong value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicLong(1L)).hasNonNegativeValue();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicLong(1L)).hasNegativeValue();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual AtomicLong value to be validated.
        Returns:
        the AtomicLongAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AtomicLongArrayAssert given​(AtomicLongArray actual)
        Creates a new assumption's instance for an AtomicLongArray value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicLongArray(0)).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicLongArray(0)).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual AtomicLongArray value to be validated.
        Returns:
        the AtomicLongArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> given​(AtomicLongFieldUpdater<OBJECT> actual)
        Creates a new assumption's instance for an AtomicLongFieldUpdater value.

        Examples:

        
         class Yoda {
           public volatile long field = 0L;
         }
         
        
         AtomicLongFieldUpdater actual = AtomicLongFieldUpdater.newUpdater​(Yoda.class, "field");
         Yoda value = new Yoda();
         actual.set(value, 1L);
         

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(actual).hasValue(1L, value);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(actual).hasValue(2L, value));
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        OBJECT - the type of the object holding the updatable field which gets updated by the the actual value.
        Parameters:
        actual - the actual AtomicLongFieldUpdater value to be validated.
        Returns:
        the AtomicLongFieldUpdaterAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <VALUE> AtomicReferenceAssert<VALUE> given​(AtomicReference<VALUE> actual)
        Creates a new assumption's instance for an AtomicReference value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicReference("Yoda")).hasValue("Yoda");
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicReference("Yoda")).doesNotHaveValue("Yoda");
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        VALUE - the type of the value contained by the actual reference.
        Parameters:
        actual - the actual AtomicReference to be validated.
        Returns:
        the AtomicReferenceAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> given​(AtomicReferenceArray<ELEMENT> actual)
        Creates a new assumption's instance for an AtomicReferenceArray value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicReferenceArray(0)).isEmpty();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicReferenceArray(0)).isNotEmpty();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        ELEMENT - the type of the value contained in the actual references' array.
        Parameters:
        actual - the actual AtomicReferenceArray to be validated.
        Returns:
        the AtomicReferenceArrayAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <FIELD,​OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,​OBJECT> given​(AtomicReferenceFieldUpdater<OBJECT,​FIELD> actual)
        Creates a new assumption's instance for an AtomicReferenceFieldUpdater value.

        Examples:

        
         class Yoda {
           public volatile String field = "";
         }
         
        
         AtomicReferenceFieldUpdater actual = AtomicReferenceFieldUpdater.newUpdater​(Yoda.class, String.class, "field");
         Yoda value = new Yoda();
         actual.set(value, "Yoda");
         

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(actual).hasValue("Yoda", value));
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(actual).hasValue("", value));
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        FIELD - the type of the field which gets updated by the the actual updater.
        OBJECT - the type of the object holding the updatable field which gets updated by the the actual updater.
        Parameters:
        actual - the actual AtomicReferenceFieldUpdater value to be validated.
        Returns:
        the AtomicReferenceFieldUpdaterAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <VALUE> AtomicMarkableReferenceAssert<VALUE> given​(AtomicMarkableReference<VALUE> actual)
        Creates a new assumption's instance for an AtomicMarkableReference value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicMarkableReference("Yoda", true)).isMarked();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicMarkableReference("Yoda", true)).isNotMarked();
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        VALUE - the type of the value contained by the actual reference.
        Parameters:
        actual - the actual AtomicMarkableReference to be validated.
        Returns:
        the AtomicMarkableReferenceAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static <VALUE> AtomicStampedReferenceAssert<VALUE> given​(AtomicStampedReference<VALUE> actual)
        Creates a new assumption's instance for an AtomicStampedReference value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new AtomicStampedReference("Yoda", 1)).hasStamp(1);
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new AtomicStampedReference("Yoda", 1)).hasStamp(0);
           // the remaining code is NOT executed.
           // ...
        }
        Type Parameters:
        VALUE - the type of the value contained by the actual reference.
        Parameters:
        actual - the actual AtomicStampedReference to be validated.
        Returns:
        the AtomicStampedReferenceAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractDateAssert<?> given​(Date actual)
        Creates a new assumption's instance for a Date value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Date.from(Instant.parse("2014-12-03T10:15:30Z"))).isBefore("2016-12-03T10:15:30Z");
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Date.from(Instant.parse("2014-12-03T10:15:30Z"))).isAfter("2016-12-03T10:15:30Z");
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Date value to be validated.
        Returns:
        the AbstractDateAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractLocalDateAssert<?> given​(LocalDate actual)
        Creates a new assumption's instance for a LocalDate value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(LocalDate.now()).isBeforeOrEqualTo(LocalDate.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(LocalDate.now()).isAfter(LocalDate.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual LocalDate value to be validated.
        Returns:
        the AbstractLocalDateAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractLocalTimeAssert<?> given​(LocalTime actual)
        Creates a new assumption's instance for a LocalTime value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(LocalTime.now()).isBeforeOrEqualTo(LocalTime.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(LocalTime.now()).isAfter(LocalTime.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual LocalTime value to be validated.
        Returns:
        the AbstractLocalTimeAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractOffsetTimeAssert<?> given​(OffsetTime actual)
        Creates a new assumption's instance for an OffsetTime value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(OffsetTime.now()).isBeforeOrEqualTo(OffsetTime.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(OffsetTime.now()).isAfter(OffsetTime.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual OffsetTime value to be validated.
        Returns:
        the AbstractOffsetTimeAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractLocalDateTimeAssert<?> given​(LocalDateTime actual)
        Creates a new assumption's instance for a LocalDateTime value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(LocalDateTime.now()).isBeforeOrEqualTo(LocalDateTime.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(LocalDateTime.now()).isAfter(LocalDateTime.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual LocalDateTime value to be validated.
        Returns:
        the AbstractLocalDateTimeAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractInstantAssert<?> given​(Instant actual)
        Creates a new assumption's instance for an Instant value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(Instant.now()).isBeforeOrEqualTo(Instant.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(Instant.now()).isAfter(Instant.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Instant value to be validated.
        Returns:
        the AbstractInstantAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractOffsetDateTimeAssert<?> given​(OffsetDateTime actual)
        Creates a new assumption's instance for an OffsetDateTime value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(OffsetDateTime.now()).isBeforeOrEqualTo(OffsetDateTime.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(OffsetDateTime.now()).isAfter(OffsetDateTime.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual OffsetDateTime value to be validated.
        Returns:
        the AbstractOffsetDateTimeAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractZonedDateTimeAssert<?> given​(ZonedDateTime actual)
        Creates a new assumption's instance for a ZonedDateTime value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(ZonedDateTime.now()).isBeforeOrEqualTo(ZonedDateTime.now());
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(ZonedDateTime.now()).isAfter(ZonedDateTime.now());
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual ZonedDateTime value to be validated.
        Returns:
        the AbstractZonedDateTimeAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractInputStreamAssert<?,​? extends InputStream> given​(InputStream actual)
        Creates a new assumption's instance for an InputStream value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new ByteArrayInputStream​("A".getBytes())).hasContent("A");
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new ByteArrayInputStream​("A".getBytes())).hasContent("B");
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual InputStream value to be validated.
        Returns:
        the AbstractInputStreamAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractFileAssert<?> given​(File actual)
        Creates a new assumption's instance for a File value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new File("file.ext")).isRelative();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new File("file.ext")).isAbsolute();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual File value to be validated.
        Returns:
        the AbstractFileAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractPathAssert<?> given​(Path actual)
        Creates a new assumption's instance for a Path value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new File("file.ext").toPath()).isRelative();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new File("file.ext").toPath()).isAbsolute();
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual Path value to be validated.
        Returns:
        the AbstractPathAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractUriAssert<?> given​(URI actual)
        Creates a new assumption's instance for an URI value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new URI("http://assertj.org")).hasNoPort();
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new URI("http://assertj.org")).hasPort(80);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual URI value to be validated.
        Returns:
        the AbstractUriAssert assertion object to be used for validation.
        Since:
        3.14.0
      • given

        public static AbstractUrlAssert<?> given​(URL actual)
        Creates a new assumption's instance for an URL value.

        Examples:

        Executed test:

         @Test
         public void given_the_assumption_is_met_the_test_is_executed() {
           given(new URL("http://assertj.org")).hasProtocol("http");
           // the remaining code is executed
           // ...
         }

        Skipped test:

         @Test
         public void given_the_assumption_is_not_met_the_test_is_skipped() {
           given(new URL("http://assertj.org")).hasPort(80);
           // the remaining code is NOT executed.
           // ...
        }
        Parameters:
        actual - the actual URL value to be validated.
        Returns:
        the AbstractUrlAssert assertion object to be used for validation.
        Since:
        3.14.0