Class BDDAssumptions
- java.lang.Object
-
- org.assertj.core.api.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 namedgiven
instead ofassumeThat
.BDDAssumptions
andBDDAssertions
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 Summary
Constructors Modifier Constructor Description private
BDDAssumptions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AbstractBooleanAssert<?>
given(boolean actual)
Creates a new assumption's instance for aboolean
value.static AbstractBooleanArrayAssert<?>
given(boolean[] actual)
Creates a new assumption's instance for aboolean
s' array.static Boolean2DArrayAssert
given(boolean[][] actual)
Creates a new assumption's instance for aboolean
s' two-dimensional array.static AbstractByteAssert<?>
given(byte actual)
Creates a new assumption's instance for abyte
value.static AbstractByteArrayAssert<?>
given(byte[] actual)
Creates a new assumption's instance for abyte
s' array.static Byte2DArrayAssert
given(byte[][] actual)
Creates a new assumption's instance for abyte
s' two-dimensional array.static AbstractCharacterAssert<?>
given(char actual)
Creates a new assumption's instance for achar
value.static AbstractCharArrayAssert<?>
given(char[] actual)
Creates a new assumption's instance for anchar
s' array.static Char2DArrayAssert
given(char[][] actual)
Creates a new assumption's instance for anchar
s' two-dimensional array.static AbstractDoubleAssert<?>
given(double actual)
Creates a new assumption's instance for adouble
value.static AbstractDoubleArrayAssert<?>
given(double[] actual)
Creates a new assumption's instance for andouble
s' array.static Double2DArrayAssert
given(double[][] actual)
Creates a new assumption's instance for andouble
s' two-dimensional array.static AbstractFloatAssert<?>
given(float actual)
Creates a new assumption's instance for afloat
value.static AbstractFloatArrayAssert<?>
given(float[] actual)
Creates a new assumption's instance for afloat
s' array.static Float2DArrayAssert
given(float[][] actual)
Creates a new assumption's instance for afloat
s' two-dimensional array.static AbstractIntegerAssert<?>
given(int actual)
Creates a new assumption's instance for anint
value.static AbstractIntArrayAssert<?>
given(int[] actual)
Creates a new assumption's instance for anint
s' array.static Int2DArrayAssert
given(int[][] actual)
Creates a new assumption's instance for anint
s' two-dimensional array.static AbstractLongAssert<?>
given(long actual)
Creates a new assumption's instance for along
value.static AbstractLongArrayAssert<?>
given(long[] actual)
Creates a new assumption's instance for along
s' array.static Long2DArrayAssert
given(long[][] actual)
Creates a new assumption's instance for along
s' two-dimensional array.static AbstractShortAssert<?>
given(short actual)
Creates a new assumption's instance for ashort
value.static AbstractShortArrayAssert<?>
given(short[] actual)
Creates a new assumption's instance for ashort
s' array.static Short2DArrayAssert
given(short[][] actual)
Creates a new assumption's instance for ashort
s' two-dimensional array.static AbstractFileAssert<?>
given(File actual)
Creates a new assumption's instance for aFile
value.static AbstractInputStreamAssert<?,? extends InputStream>
given(InputStream actual)
Creates a new assumption's instance for anInputStream
value.static AbstractBooleanAssert<?>
given(Boolean actual)
Creates a new assumption's instance for aBoolean
value.static AbstractByteAssert<?>
given(Byte actual)
Creates a new assumption's instance for aByte
value.static AbstractCharacterAssert<?>
given(Character actual)
Creates a new assumption's instance for aCharacter
value.static AbstractCharSequenceAssert<?,? extends CharSequence>
given(CharSequence actual)
Creates a new assumption's instance for aCharSequence
value.static AbstractClassAssert<?>
given(Class<?> actual)
Creates a new assumption's instance for aClass
value.static <T extends Comparable<? super T>>
AbstractComparableAssert<?,T>given(Comparable<? super T> actual)
Creates a new assumption's instance for aComparable
value.static AbstractDoubleAssert<?>
given(Double actual)
Creates a new assumption's instance for aDouble
value.static AbstractFloatAssert<?>
given(Float actual)
Creates a new assumption's instance for aFloat
value.static AbstractIntegerAssert<?>
given(Integer actual)
Creates a new assumption's instance for anInteger
value.static <ELEMENT> ProxyableIterableAssert<ELEMENT>
given(Iterable<? extends ELEMENT> actual)
Creates a new assumption's instance for anIterable
value.static AbstractLongAssert<?>
given(Long actual)
Creates a new assumption's instance for aLong
value.static AbstractShortAssert<?>
given(Short actual)
Creates a new assumption's instance for aShort
value.static AbstractStringAssert<?>
given(String actual)
Creates a new assumption's instance for aString
value.static AbstractCharSequenceAssert<?,? extends CharSequence>
given(StringBuffer actual)
Creates a new assumption's instance for aStringBuffer
value.static AbstractCharSequenceAssert<?,? extends CharSequence>
given(StringBuilder actual)
Creates a new assumption's instance for aStringBuilder
value.static AbstractThrowableAssert<?,? extends Throwable>
given(Throwable actual)
Creates a new assumption's instance for aThrowable
value.static AbstractBigDecimalAssert<?>
given(BigDecimal actual)
Creates a new assumption's instance for aBigDecimal
value.static AbstractBigIntegerAssert<?>
given(BigInteger actual)
Creates a new assumption's instance for aBigInteger
value.static AbstractUriAssert<?>
given(URI actual)
Creates a new assumption's instance for anURI
value.static AbstractUrlAssert<?>
given(URL actual)
Creates a new assumption's instance for anURL
value.static AbstractPathAssert<?>
given(Path actual)
Creates a new assumption's instance for aPath
value.static AbstractDurationAssert<?>
given(Duration actual)
Creates a new assumption's instance for aInstant
value.static AbstractInstantAssert<?>
given(Instant actual)
Creates a new assumption's instance for anInstant
value.static AbstractLocalDateAssert<?>
given(LocalDate actual)
Creates a new assumption's instance for aLocalDate
value.static AbstractLocalDateTimeAssert<?>
given(LocalDateTime actual)
Creates a new assumption's instance for aLocalDateTime
value.static AbstractLocalTimeAssert<?>
given(LocalTime actual)
Creates a new assumption's instance for aLocalTime
value.static AbstractOffsetDateTimeAssert<?>
given(OffsetDateTime actual)
Creates a new assumption's instance for anOffsetDateTime
value.static AbstractOffsetTimeAssert<?>
given(OffsetTime actual)
Creates a new assumption's instance for anOffsetTime
value.static AbstractPeriodAssert<?>
given(Period actual)
Creates a new assumption's instance for aPeriod
value.static AbstractZonedDateTimeAssert<?>
given(ZonedDateTime actual)
Creates a new assumption's instance for aZonedDateTime
value.static AtomicBooleanAssert
given(AtomicBoolean actual)
Creates a new assumption's instance for anAtomicBoolean
value.static AtomicIntegerAssert
given(AtomicInteger actual)
Creates a new assumption's instance for anAtomicInteger
value.static AtomicIntegerArrayAssert
given(AtomicIntegerArray actual)
Creates a new assumption's instance for anAtomicIntegerArray
value.static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT>
given(AtomicIntegerFieldUpdater<OBJECT> actual)
Creates a new assumption's instance for anAtomicIntegerFieldUpdater
value.static AtomicLongAssert
given(AtomicLong actual)
Creates a new assumption's instance for anAtomicLong
value.static AtomicLongArrayAssert
given(AtomicLongArray actual)
Creates a new assumption's instance for anAtomicLongArray
value.static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT>
given(AtomicLongFieldUpdater<OBJECT> actual)
Creates a new assumption's instance for anAtomicLongFieldUpdater
value.static <VALUE> AtomicMarkableReferenceAssert<VALUE>
given(AtomicMarkableReference<VALUE> actual)
Creates a new assumption's instance for anAtomicMarkableReference
value.static <VALUE> AtomicReferenceAssert<VALUE>
given(AtomicReference<VALUE> actual)
Creates a new assumption's instance for anAtomicReference
value.static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT>
given(AtomicReferenceArray<ELEMENT> actual)
Creates a new assumption's instance for anAtomicReferenceArray
value.static <FIELD,OBJECT>
AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT>given(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
Creates a new assumption's instance for anAtomicReferenceFieldUpdater
value.static <VALUE> AtomicStampedReferenceAssert<VALUE>
given(AtomicStampedReference<VALUE> actual)
Creates a new assumption's instance for anAtomicStampedReference
value.static LongAdderAssert
given(LongAdder actual)
Creates a new assumption's instance for aLongAdder
value.static <RESULT> CompletableFutureAssert<RESULT>
given(CompletableFuture<RESULT> future)
Creates a new assumption's instance for aCompletableFuture
value.static <RESULT> CompletableFutureAssert<RESULT>
given(CompletionStage<RESULT> stage)
Creates a new assumption's instance for aCompletionStage
value.static <RESULT> AbstractFutureAssert<?,? extends Future<? extends RESULT>,RESULT>
given(Future<RESULT> future)
Creates a new assumption's instance for aFuture
value.static AbstractDateAssert<?>
given(Date actual)
Creates a new assumption's instance for aDate
value.static DoublePredicateAssert
given(DoublePredicate actual)
Creates a new assumption's instance for aDoublePredicate
value.static IntPredicateAssert
given(IntPredicate actual)
Creates a new assumption's instance for anIntPredicate
value.static LongPredicateAssert
given(LongPredicate actual)
Creates a new assumption's instance for aLongPredicate
value.static <T> ProxyablePredicateAssert<T>
given(Predicate<T> actual)
Creates a new assumption's instance for aPredicate
value.static <ELEMENT> IteratorAssert<ELEMENT>
given(Iterator<? extends ELEMENT> actual)
Creates a new assumption's instance for anIterator
value.static <ELEMENT> FactoryBasedNavigableListAssert<ProxyableListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
given(List<? extends ELEMENT> actual)
Creates a new assumption's instance for aList
value.static <K,V>
AbstractMapAssert<?,?,K,V>given(Map<K,V> actual)
Creates a new assumption's instance for aMap
value.static <VALUE> OptionalAssert<VALUE>
given(Optional<VALUE> actual)
Creates a new assumption's instance for anOptional
value.static OptionalDoubleAssert
given(OptionalDouble actual)
Creates a new assumption's instance for anOptionalDouble
value.static OptionalIntAssert
given(OptionalInt actual)
Creates a new assumption's instance for anOptionalInt
value.static OptionalLongAssert
given(OptionalLong actual)
Creates a new assumption's instance for anOptionalLong
value.static <ELEMENT> AbstractSpliteratorAssert<?,ELEMENT>
given(Spliterator<ELEMENT> actual)
Creates a new assumption's instance for aSpliterator
value.static AbstractListAssert<?,List<? extends Double>,Double,ObjectAssert<Double>>
given(DoubleStream actual)
Creates a new assumption's instance for aDoubleStream
value.static AbstractListAssert<?,List<? extends Integer>,Integer,ObjectAssert<Integer>>
given(IntStream actual)
Creates a new assumption's instance for anIntStream
value.static AbstractListAssert<?,List<? extends Long>,Long,ObjectAssert<Long>>
given(LongStream actual)
Creates a new assumption's instance for aLongStream
value.static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
given(Stream<? extends ELEMENT> actual)
Creates a new assumption's instance for aStream
value.static <T> ProxyableObjectAssert<T>
given(T actual)
Creates a new assumption's instance for an object value.static <T> ProxyableObjectArrayAssert<T>
given(T[] actual)
Creates a new assumption's instance for an objects' array.static <T> Object2DArrayAssert<T>
given(T[][] actual)
Creates a new assumption's instance for an objects' two-dimensional array.static AbstractThrowableAssert<?,? extends Throwable>
givenCode(ThrowableAssert.ThrowingCallable lambda)
Creates a new assumption's instance from a no parameters lambda expression,() -> { /* some code */ }
.static <T> ProxyableObjectAssert<T>
givenObject(T actual)
Creates a new assumption's instance for an object value.
-
-
-
Method Detail
-
given
public static AbstractBooleanAssert<?> given(boolean actual)
Creates a new assumption's instance for aboolean
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 actualboolean
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 aBoolean
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 actualBoolean
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 aboolean
s' 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 actualboolean
s' array to be validated.- Returns:
- the
AbstractBooleanArrayAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Boolean2DArrayAssert given(boolean[][] actual)
Creates a new assumption's instance for aboolean
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new boolean[][] {{true, true}, {false, false}}).contains(new boolean[] {true, true}, atIndex(0)); // 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}, {false, false}}).contains(new boolean[] {true, true}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualboolean
s' two-dimensional array to be validated.- Returns:
- the
Boolean2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractByteAssert<?> given(byte actual)
Creates a new assumption's instance for abyte
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 actualbyte
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 aByte
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 actualByte
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 abyte
s' 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 Byte2DArrayAssert given(byte[][] actual)
Creates a new assumption's instance for abyte
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new byte[][] {{1, 2}, {3, 4}}).contains(new byte[] {1, 2)}, atIndex(0)); // 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}, {3, 4}}).contains(new byte[] {1, 2)}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actual bytes' two-dimensional array to be validated.- Returns:
- the
Byte2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractShortAssert<?> given(short actual)
Creates a new assumption's instance for ashort
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 actualshort
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 aShort
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 actualShort
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 ashort
s' 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 actualshort
s' array to be validated.- Returns:
- the
AbstractShortArrayAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Short2DArrayAssert given(short[][] actual)
Creates a new assumption's instance for ashort
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new short[][] {{1, 2}, {3, 4}}).contains(new short[] {1, 2}, atIndex(0)); // 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}, {3, 4}}).contains(new short[] {1, 2}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualshort
s' two-dimensional array to be validated.- Returns:
- the
Short2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractIntegerAssert<?> given(int actual)
Creates a new assumption's instance for anint
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 actualint
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 anInteger
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 actualInteger
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 anint
s' 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 actualint
s' array to be validated.- Returns:
- the
AbstractIntArrayAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Int2DArrayAssert given(int[][] actual)
Creates a new assumption's instance for anint
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new int[][] {{1, 2}, {3, 4}}).contains(new int[] {1, 2}, atIndex(0)); // 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}, {3, 4}}).contains(new int[] {1, 2}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualint
s' two-dimensional array to be validated.- Returns:
- the
Int2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractBigIntegerAssert<?> given(BigInteger actual)
Creates a new assumption's instance for aBigInteger
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 actualBigInteger
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 along
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 actuallong
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 aLong
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 actualLong
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 along
s' 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 actuallong
s' array to be validated.- Returns:
- the
AbstractLongArrayAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Long2DArrayAssert given(long[][] actual)
Creates a new assumption's instance for along
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new long[][] {{1, 2}, {3, 4}}).contains(new long[] {1, 2}, atIndex(0)); // 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}, {3, 4}}).contains(new long[] {1, 2}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actuallong
s' two-dimensional array to be validated.- Returns:
- the
Long2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractFloatAssert<?> given(float actual)
Creates a new assumption's instance for afloat
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 actualfloat
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 aFloat
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 actualFloat
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 afloat
s' 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 actualfloat
s' array to be validated.- Returns:
- the
AbstractFloatArrayAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Float2DArrayAssert given(float[][] actual)
Creates a new assumption's instance for afloat
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}}).contains(new float[] {1.0f, 2.0f}, atIndex(0)); // 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}, {3.0f, 4.0f}}).contains(new float[] {1.0f, 2.0f}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualfloat
s' two-dimensional array to be validated.- Returns:
- the
Float2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractDoubleAssert<?> given(double actual)
Creates a new assumption's instance for adouble
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 actualdouble
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 aDouble
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 actualDouble
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 andouble
s' 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 actualdouble
s' array to be validated.- Returns:
- the
AbstractDoubleArrayAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Double2DArrayAssert given(double[][] actual)
Creates a new assumption's instance for andouble
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new double[][] {{1.0, 2.0}, {3.0, 4.0}}).contains(new double[] {1.0, 2.0}, atIndex(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}, {3.0, 4.0}}).contains(new double[] {1.0, 2.0}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualdouble
s' two-dimensional array to be validated.- Returns:
- the
Double2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractBigDecimalAssert<?> given(BigDecimal actual)
Creates a new assumption's instance for aBigDecimal
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 actualBigDecimal
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 achar
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 actualchar
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 aCharacter
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 actualCharacter
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 anchar
s' 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 actualchar
s' array to be validated.- Returns:
- the
AbstractCharacterAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static Char2DArrayAssert given(char[][] actual)
Creates a new assumption's instance for anchar
s' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new char[][] {{'A', 'B'}, {'C', 'D'}}).contains(new char[] {'A', 'B'}, atIndex(0)); // 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'}, {'C', 'D'}}).contains(new char[] {'A', 'B'}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualchar
s' two-dimensional array to be validated.- Returns:
- the
Char2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.0
-
given
public static AbstractCharSequenceAssert<?,? extends CharSequence> given(CharSequence actual)
Creates a new assumption's instance for aCharSequence
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 actualCharSequence
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 aString
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 actualString
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 aStringBuilder
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 actualStringBuilder
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 aStringBuffer
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 actualStringBuffer
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 aClass
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 actualClass
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
-
given
public static <T> Object2DArrayAssert<T> given(T[][] actual)
Creates a new assumption's instance for an objects' two-dimensional array.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new String[][] {{"A", "B"}, {"C", "D"}}).contains(new String[] {"A", "B"}, atIndex(0)); // 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"}, {"C", "D"}}).contains(new String[] {"A", "B"}, atIndex(1)); // the remaining code is NOT executed. // ... }
- Type Parameters:
T
- the type of elements of the actual objects' two-dimensional array.- Parameters:
actual
- the actual objects' two-dimensional array to be validated..- Returns:
- the
Object2DArrayAssert
assertion object to be used for validation. - Since:
- 3.17.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 genericgiven(T)
then when using some base general assert methods, e.g.
AbstractAssert.matches(Predicate)
, cast is necessary becausegiven(List)
"forgets" actual type:
withgiven(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc"));
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 aComparable
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 actualComparable
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 aThrowable
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 actualThrowable
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
- theThrowableAssert.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 anIterable
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 actualIterable
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 anIterator
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 actualIterator
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 aList
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 actualList
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 aMap
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 actualMap
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 aPredicate
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 actualPredicate
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 anIntPredicate
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 actualIntPredicate
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 aLongPredicate
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 actualLongPredicate
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 aDoublePredicate
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 actualDoublePredicate
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 anOptional
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 actualOptional
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 anOptionalInt
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 actualOptionalInt
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 anOptionalLong
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 actualOptionalLong
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 anOptionalDouble
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 actualOptionalDouble
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 aStream
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 actualStream
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 anIntStream
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 actualIntStream
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 aSpliterator
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 actualSpliterator
value to be validated.- Returns:
- the
AbstractSpliteratorAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static AbstractListAssert<?,List<? extends Long>,Long,ObjectAssert<Long>> given(LongStream actual)
Creates a new assumption's instance for aLongStream
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 actualLongStream
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 aDoubleStream
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 actualDoubleStream
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 aFuture
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
- theFuture
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 aCompletableFuture
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
- theCompletableFuture
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 aCompletionStage
value.Converts the
CompletionStage
into aCompletableFuture
. If the givenCompletionStage
is null, the associatedCompletableFuture
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
- theCompletionStage
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 anAtomicBoolean
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 actualAtomicBoolean
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 anAtomicInteger
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 actualAtomicInteger
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 anAtomicIntegerArray
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 actualAtomicIntegerArray
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 anAtomicIntegerFieldUpdater
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 actualAtomicIntegerFieldUpdater
value to be validated.- Returns:
- the
AtomicIntegerFieldUpdaterAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static LongAdderAssert given(LongAdder actual)
Creates a new assumption's instance for aLongAdder
value.Examples:
Executed test:
@Test public void given_the_assumption_is_met_the_test_is_executed() { given(new LongAdder()).isNotNegative(); // the remaining code is executed // ... }
Skipped test:
@Test public void given_the_assumption_is_not_met_the_test_is_skipped() { given(new LongAdder()).isNegative(); // the remaining code is NOT executed. // ... }
- Parameters:
actual
- the actualLongAdder
value to be validated.- Returns:
- the
LongAdderAssert
assertion object to be used for validation. - Since:
- 3.16.0
-
given
public static AtomicLongAssert given(AtomicLong actual)
Creates a new assumption's instance for anAtomicLong
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 actualAtomicLong
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 anAtomicLongArray
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 actualAtomicLongArray
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 anAtomicLongFieldUpdater
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 actualAtomicLongFieldUpdater
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 anAtomicReference
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 actualAtomicReference
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 anAtomicReferenceArray
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 actualAtomicReferenceArray
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 anAtomicReferenceFieldUpdater
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 actualAtomicReferenceFieldUpdater
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 anAtomicMarkableReference
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 actualAtomicMarkableReference
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 anAtomicStampedReference
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 actualAtomicStampedReference
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 aDate
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 actualDate
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 aLocalDate
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 actualLocalDate
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 aLocalTime
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 actualLocalTime
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 anOffsetTime
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 actualOffsetTime
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 aLocalDateTime
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 actualLocalDateTime
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 anInstant
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 actualInstant
value to be validated.- Returns:
- the
AbstractInstantAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
given
public static AbstractDurationAssert<?> given(Duration actual)
Creates a new assumption's instance for aInstant
value.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.15.0
-
given
public static AbstractPeriodAssert<?> given(Period actual)
Creates a new assumption's instance for aPeriod
value.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
given
public static AbstractOffsetDateTimeAssert<?> given(OffsetDateTime actual)
Creates a new assumption's instance for anOffsetDateTime
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 actualOffsetDateTime
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 aZonedDateTime
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 actualZonedDateTime
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 anInputStream
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 actualInputStream
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 aFile
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 actualFile
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 aPath
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 actualPath
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 anURI
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 actualURI
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 anURL
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 actualURL
value to be validated.- Returns:
- the
AbstractUrlAssert
assertion object to be used for validation. - Since:
- 3.14.0
-
-