Class Java6AbstractStandardSoftAssertions

    • Constructor Detail

      • Java6AbstractStandardSoftAssertions

        public Java6AbstractStandardSoftAssertions()
    • Method Detail

      • assertThat

        public BigDecimalAssert assertThat​(java.math.BigDecimal actual)
        Creates a new instance of BigDecimalAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public BigIntegerAssert assertThat​(java.math.BigInteger actual)
        Creates a new instance of BigInteger.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
        Since:
        2.7.0 / 3.7.0
      • assertThat

        public BooleanAssert assertThat​(boolean actual)
        Creates a new instance of BooleanAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public BooleanAssert assertThat​(java.lang.Boolean actual)
        Creates a new instance of BooleanAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public BooleanArrayAssert assertThat​(boolean[] actual)
        Creates a new instance of BooleanArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ByteAssert assertThat​(byte actual)
        Creates a new instance of ByteAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ByteAssert assertThat​(java.lang.Byte actual)
        Creates a new instance of ByteAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ByteArrayAssert assertThat​(byte[] actual)
        Creates a new instance of ByteArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public CharacterAssert assertThat​(char actual)
        Creates a new instance of CharacterAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public CharArrayAssert assertThat​(char[] actual)
        Creates a new instance of CharArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public CharacterAssert assertThat​(java.lang.Character actual)
        Creates a new instance of CharacterAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public SoftAssertionClassAssert assertThat​(java.lang.Class<?> actual)
        Creates a new instance of ClassAssert

        We don't return ClassAssert as it has overridden methods to annotated with SafeVarargs.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <T extends java.lang.Comparable<? super T>> AbstractComparableAssert<?,​T> assertThat​(T actual)
        Creates a new instance of GenericComparableAssert with standard comparison semantics.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <T> SoftAssertionIterableAssert<T> assertThat​(java.lang.Iterable<? extends T> actual)
        Creates a new instance of IterableAssert.

        We don't return IterableAssert as it has overridden methods to annotated with SafeVarargs.

        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <T> SoftAssertionIterableAssert<T> assertThat​(java.util.Iterator<T> actual)
        Creates a new instance of IterableAssert. The Iterator is first converted into an Iterable

        We don't return IterableAssert as it has overridden methods to annotated with SafeVarargs.

        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public DoubleAssert assertThat​(double actual)
        Creates a new instance of DoubleAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public DoubleAssert assertThat​(java.lang.Double actual)
        Creates a new instance of DoubleAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public DoubleArrayAssert assertThat​(double[] actual)
        Creates a new instance of DoubleArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public FileAssert assertThat​(java.io.File actual)
        Creates a new instance of FileAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <RESULT> FutureAssert<RESULT> assertThat​(java.util.concurrent.Future<? extends RESULT> actual)
        Creates a new instance of FutureAssert.
        Parameters:
        actual - the actual value
        Returns:
        the created assertion object
      • assertThat

        public InputStreamAssert assertThat​(java.io.InputStream actual)
        Creates a new instance of InputStreamAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public FloatAssert assertThat​(float actual)
        Creates a new instance of FloatAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public FloatAssert assertThat​(java.lang.Float actual)
        Creates a new instance of FloatAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public FloatArrayAssert assertThat​(float[] actual)
        Creates a new instance of FloatArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public IntegerAssert assertThat​(int actual)
        Creates a new instance of IntegerAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public IntArrayAssert assertThat​(int[] actual)
        Creates a new instance of IntArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public IntegerAssert assertThat​(java.lang.Integer actual)
        Creates a new instance of IntegerAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <T> SoftAssertionListAssert<T> assertThat​(java.util.List<? extends T> actual)
        Creates a new instance of ListAssert.

        We don't return IterableAssert as it has overridden methods to annotated with SafeVarargs.

        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public LongAssert assertThat​(long actual)
        Creates a new instance of LongAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public LongAssert assertThat​(java.lang.Long actual)
        Creates a new instance of LongAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public LongArrayAssert assertThat​(long[] actual)
        Creates a new instance of LongArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <T> ObjectAssert<T> assertThat​(T actual)
        Creates a new instance of ObjectAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <T> ObjectArrayAssert<T> assertThat​(T[] actual)
        Creates a new instance of ObjectArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <K,​V> SoftAssertionMapAssert<K,​V> assertThat​(java.util.Map<K,​V> actual)
        Creates a new instance of MapAssert.

        We don't return MapAssert as it has overridden methods to annotated with SafeVarargs.

        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ShortAssert assertThat​(short actual)
        Creates a new instance of ShortAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ShortAssert assertThat​(java.lang.Short actual)
        Creates a new instance of ShortAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ShortArrayAssert assertThat​(short[] actual)
        Creates a new instance of ShortArrayAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public CharSequenceAssert assertThat​(java.lang.CharSequence actual)
        Creates a new instance of CharSequenceAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public StringAssert assertThat​(java.lang.String actual)
        Creates a new instance of StringAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public DateAssert assertThat​(java.util.Date actual)
        Creates a new instance of DateAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public AtomicBooleanAssert assertThat​(java.util.concurrent.atomic.AtomicBoolean actual)
        Create assertion for AtomicBoolean.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public AtomicIntegerAssert assertThat​(java.util.concurrent.atomic.AtomicInteger actual)
        Create assertion for AtomicInteger.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public AtomicIntegerArrayAssert assertThat​(java.util.concurrent.atomic.AtomicIntegerArray actual)
        Create assertion for AtomicIntegerArray.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assertThat​(java.util.concurrent.atomic.AtomicIntegerFieldUpdater<OBJECT> actual)
        Create assertion for AtomicIntegerFieldUpdater.
        Type Parameters:
        OBJECT - the type of the object holding the updatable field.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public AtomicLongAssert assertThat​(java.util.concurrent.atomic.AtomicLong actual)
        Create assertion for AtomicLong.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public AtomicLongArrayAssert assertThat​(java.util.concurrent.atomic.AtomicLongArray actual)
        Create assertion for AtomicLongArray.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assertThat​(java.util.concurrent.atomic.AtomicLongFieldUpdater<OBJECT> actual)
        Create assertion for AtomicLongFieldUpdater.
        Type Parameters:
        OBJECT - the type of the object holding the updatable field.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <VALUE> AtomicReferenceAssert<VALUE> assertThat​(java.util.concurrent.atomic.AtomicReference<VALUE> actual)
        Create assertion for AtomicReference.
        Type Parameters:
        VALUE - the type of object referred to by the AtomicReference.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assertThat​(java.util.concurrent.atomic.AtomicReferenceArray<ELEMENT> actual)
        Create assertion for AtomicReferenceArray.
        Type Parameters:
        ELEMENT - the type of object referred to by the AtomicReferenceArray.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <FIELD,​OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,​OBJECT> assertThat​(java.util.concurrent.atomic.AtomicReferenceFieldUpdater<OBJECT,​FIELD> actual)
        Create assertion for AtomicReferenceFieldUpdater.
        Type Parameters:
        FIELD - the type of the field which gets updated by the AtomicReferenceFieldUpdater.
        OBJECT - the type of the object holding the updatable field.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <VALUE> AtomicMarkableReferenceAssert<VALUE> assertThat​(java.util.concurrent.atomic.AtomicMarkableReference<VALUE> actual)
        Create assertion for AtomicMarkableReference.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public <VALUE> AtomicStampedReferenceAssert<VALUE> assertThat​(java.util.concurrent.atomic.AtomicStampedReference<VALUE> actual)
        Create assertion for AtomicStampedReference.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public ThrowableAssert assertThat​(java.lang.Throwable actual)
        Creates a new instance of ThrowableAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion Throwable.
      • assertThatThrownBy

        public AbstractThrowableAssert<?,​? extends java.lang.Throwable> assertThatThrownBy​(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
        Allows to capture and then assert on a Throwable more easily when used with Java 8 lambdas. Java 8 example :
          @Test
          public void testException() {
            SoftAssertions softly = new SoftAssertions();
            softly.assertThatThrownBy(() -> { throw new Exception("boom!"); }).isInstanceOf(Exception.class)
                                                                             .hasMessageContaining("boom");
          }
        Java 7 example :
         SoftAssertions softly = new SoftAssertions();
         softly.assertThatThrownBy(new ThrowingCallable() {
        
           @Override
           public Void call() throws Exception {
             throw new Exception("boom!");
           }
        
         }).isInstanceOf(Exception.class)
           .hasMessageContaining("boom");
        Parameters:
        shouldRaiseThrowable - The ThrowableAssert.ThrowingCallable or lambda with the code that should raise the throwable.
        Returns:
        The captured exception or null if none was raised by the callable.
      • assertThatCode

        public AbstractThrowableAssert<?,​? extends java.lang.Throwable> assertThatCode​(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
        Allows to capture and then assert on a Throwable more easily when used with Java 8 lambdas.

        Example :

         ThrowingCallable callable = () -> {
           throw new Exception("boom!");
         };
         
         // assertion succeeds
         assertThatCode(callable).isInstanceOf(Exception.class)
                                 .hasMessageContaining("boom");
                                                              
         // assertion fails
         assertThatCode(callable).doesNotThrowAnyException();
        If the provided ThrowableAssert.ThrowingCallable does not validate against next assertions, an error is immediately raised, in that case the test description provided with as(String, Object...) is not honored.
        To use a test description, use assertThatCode(ThrowableAssert.ThrowingCallable) as shown below.
         ThrowingCallable doNothing = () -> {
           // do nothing 
         }; 
         
         // assertion fails and "display me" appears in the assertion error
         assertThatCode(doNothing).as("display me")
                                  .isInstanceOf(Exception.class);
        
         // assertion will fail AND "display me" will appear in the error
         Throwable thrown = catchThrowable(doNothing);
         assertThatCode(thrown).as("display me")
                               .isInstanceOf(Exception.class); 

        This method was not named assertThat because the java compiler reported it ambiguous when used directly with a lambda :(

        Parameters:
        shouldRaiseOrNotThrowable - The ThrowableAssert.ThrowingCallable or lambda with the code that should raise the throwable.
        Returns:
        The captured exception or null if none was raised by the callable.
        Since:
        3.7.0
      • assertThat

        public UriAssert assertThat​(java.net.URI actual)
        Creates a new instance of UriAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.
      • assertThat

        public AbstractUrlAssert<?> assertThat​(java.net.URL actual)
        Creates a new instance of UrlAssert.
        Parameters:
        actual - the actual value.
        Returns:
        the created assertion object.