How to use asAssumption method of org.assertj.core.api.Assumptions class

Best Assertj code snippet using org.assertj.core.api.Assumptions.asAssumption

Source:Assumptions.java Github

copy

Full Screen

...108 public static Object intercept(@This AbstractAssert<?, ?> assertion, @SuperCall Callable<Object> proxy) throws Exception {109 try {110 Object result = proxy.call();111 if (result != assertion && result instanceof AbstractAssert) {112 return asAssumption((AbstractAssert<?, ?>) result).withAssertionState(assertion);113 }114 return result;115 } catch (AssertionError e) {116 throw assumptionNotMet(e);117 }118 }119 }120 /**121 * Creates a new instance of <code>{@link ObjectAssert}</code> assumption.122 *123 * @param actual the actual value.124 * @param <T> the type of the actual value.125 * @return the created assumption for assertion object.126 * @since 2.9.0 / 3.9.0127 */128 @SuppressWarnings("unchecked")129 public static <T> ObjectAssert<T> assumeThat(T actual) {130 return asAssumption(ObjectAssert.class, Object.class, actual);131 }132 /**133 * Creates a new instance of <code>{@link StringAssert}</code> assumption.134 *135 * @param actual the actual value.136 * @return the created assumption for assertion object.137 * @since 2.9.0 / 3.9.0138 */139 public static AbstractStringAssert<?> assumeThat(String actual) {140 return asAssumption(StringAssert.class, String.class, actual);141 }142 /**143 * Creates a new instance of <code>{@link BigDecimalAssert}</code> assumption.144 *145 * @param actual the actual value.146 * @return the created assumption for assertion object.147 * @since 2.9.0 / 3.9.0148 */149 public static AbstractBigDecimalAssert<?> assumeThat(BigDecimal actual) {150 return asAssumption(BigDecimalAssert.class, BigDecimal.class, actual);151 }152 /**153 * Creates a new instance of <code>{@link BigIntegerAssert}</code> assumption.154 *155 * @param actual the actual value.156 * @return the created assumption for assertion object.157 * @since 2.9.0 / 3.9.0158 */159 public static AbstractBigIntegerAssert<?> assumeThat(BigInteger actual) {160 return asAssumption(BigIntegerAssert.class, BigInteger.class, actual);161 }162 /**163 * Creates a new instance of <code>{@link UriAssert}</code> assumption.164 *165 * @param actual the actual value.166 * @return the created assumption for assertion object.167 * @since 2.9.0 / 3.9.0168 */169 public static AbstractUriAssert<?> assumeThat(URI actual) {170 return asAssumption(UriAssert.class, URI.class, actual);171 }172 /**173 * Creates a new instance of <code>{@link UrlAssert}</code> assumption.174 *175 * @param actual the actual value.176 * @return the created assumption for assertion object.177 * @since 2.9.0 / 3.9.0178 */179 public static AbstractUrlAssert<?> assumeThat(URL actual) {180 return asAssumption(UrlAssert.class, URL.class, actual);181 }182 /**183 * Creates a new instance of <code>{@link BooleanAssert}</code> assumption.184 *185 * @param actual the actual value.186 * @return the created assumption for assertion object.187 * @since 2.9.0 / 3.9.0188 */189 public static AbstractBooleanAssert<?> assumeThat(boolean actual) {190 return asAssumption(BooleanAssert.class, Boolean.class, actual);191 }192 /**193 * Creates a new instance of <code>{@link BooleanAssert}</code> assumption.194 *195 * @param actual the actual value.196 * @return the created assumption for assertion object.197 * @since 2.9.0 / 3.9.0198 */199 public static AbstractBooleanAssert<?> assumeThat(Boolean actual) {200 return asAssumption(BooleanAssert.class, Boolean.class, actual);201 }202 /**203 * Creates a new instance of <code>{@link BooleanArrayAssert}</code> assumption.204 *205 * @param actual the actual value.206 * @return the created assumption for assertion object.207 * @since 2.9.0 / 3.9.0208 */209 public static AbstractBooleanArrayAssert<?> assumeThat(boolean[] actual) {210 return asAssumption(BooleanArrayAssert.class, boolean[].class, actual);211 }212 /**213 * Creates a new instance of <code>{@link Boolean2DArrayAssert}</code> assumption.214 *215 * @param actual the actual value.216 * @return the created assumption for assertion object.217 * @since 3.17.0218 */219 public static Boolean2DArrayAssert assumeThat(boolean[][] actual) {220 return asAssumption(Boolean2DArrayAssert.class, boolean[][].class, actual);221 }222 /**223 * Creates a new instance of <code>{@link ByteAssert}</code> assumption.224 *225 * @param actual the actual value.226 * @return the created assumption for assertion object.227 * @since 2.9.0 / 3.9.0228 */229 public static AbstractByteAssert<?> assumeThat(byte actual) {230 return asAssumption(ByteAssert.class, Byte.class, actual);231 }232 /**233 * Creates a new instance of <code>{@link ByteAssert}</code> assumption.234 *235 * @param actual the actual value.236 * @return the created assumption for assertion object.237 * @since 2.9.0 / 3.9.0238 */239 public static AbstractByteAssert<?> assumeThat(Byte actual) {240 return asAssumption(ByteAssert.class, Byte.class, actual);241 }242 /**243 * Creates a new instance of <code>{@link ByteArrayAssert}</code> assumption.244 *245 * @param actual the actual value.246 * @return the created assumption for assertion object.247 * @since 2.9.0 / 3.9.0248 */249 public static AbstractByteArrayAssert<?> assumeThat(byte[] actual) {250 return asAssumption(ByteArrayAssert.class, byte[].class, actual);251 }252 /**253 * Creates a new instance of <code>{@link Byte2DArrayAssert}</code> assumption.254 *255 * @param actual the actual value.256 * @return the created assumption for assertion object.257 * @since 3.17.0258 */259 public static Byte2DArrayAssert assumeThat(byte[][] actual) {260 return asAssumption(Byte2DArrayAssert.class, byte[][].class, actual);261 }262 /**263 * Creates a new instance of <code>{@link CharacterAssert}</code> assumption.264 *265 * @param actual the actual value.266 * @return the created assumption for assertion object.267 * @since 2.9.0 / 3.9.0268 */269 public static AbstractCharacterAssert<?> assumeThat(char actual) {270 return asAssumption(CharacterAssert.class, Character.class, actual);271 }272 /**273 * Creates a new instance of <code>{@link CharacterAssert}</code> assumption.274 *275 * @param actual the actual value.276 * @return the created assumption for assertion object.277 * @since 2.9.0 / 3.9.0278 */279 public static AbstractCharacterAssert<?> assumeThat(Character actual) {280 return asAssumption(CharacterAssert.class, Character.class, actual);281 }282 /**283 * Creates a new instance of <code>{@link CharArrayAssert}</code> assumption.284 *285 * @param actual the actual value.286 * @return the created assumption for assertion object.287 * @since 2.9.0 / 3.9.0288 */289 public static AbstractCharArrayAssert<?> assumeThat(char[] actual) {290 return asAssumption(CharArrayAssert.class, char[].class, actual);291 }292 /**293 * Creates a new instance of <code>{@link Char2DArrayAssert}</code> assumption.294 *295 * @param actual the actual value.296 * @return the created assumption for assertion object.297 * @since 3.17.0298 */299 public static Char2DArrayAssert assumeThat(char[][] actual) {300 return asAssumption(Char2DArrayAssert.class, char[][].class, actual);301 }302 /**303 * Creates a new instance of <code>{@link CharSequenceAssert}</code> assumption.304 *305 * @param actual the actual value.306 * @return the created assumption for assertion object.307 * @since 2.9.0 / 3.9.0308 */309 public static AbstractCharSequenceAssert<?, ? extends CharSequence> assumeThat(CharSequence actual) {310 return asAssumption(CharSequenceAssert.class, CharSequence.class, actual);311 }312 /**313 * Creates a new instance of <code>{@link CharSequenceAssert}</code> assumption from a {@link StringBuilder}.314 *315 * @param actual the actual value.316 * @return the created assumption for assertion object.317 * @since 3.11.0318 */319 public static AbstractCharSequenceAssert<?, ? extends CharSequence> assumeThat(StringBuilder actual) {320 return asAssumption(CharSequenceAssert.class, CharSequence.class, actual);321 }322 /**323 * Creates a new instance of <code>{@link CharSequenceAssert}</code> assumption from a {@link StringBuffer}.324 *325 * @param actual the actual value.326 * @return the created assumption for assertion object.327 * @since 3.11.0328 */329 public static AbstractCharSequenceAssert<?, ? extends CharSequence> assumeThat(StringBuffer actual) {330 return asAssumption(CharSequenceAssert.class, CharSequence.class, actual);331 }332 /**333 * Creates a new instance of <code>{@link ShortAssert}</code> assumption.334 *335 * @param actual the actual value.336 * @return the created assumption for assertion object.337 * @since 2.9.0 / 3.9.0338 */339 public static AbstractShortAssert<?> assumeThat(short actual) {340 return asAssumption(ShortAssert.class, Short.class, actual);341 }342 /**343 * Creates a new instance of <code>{@link ShortAssert}</code> assumption.344 *345 * @param actual the actual value.346 * @return the created assumption for assertion object.347 * @since 2.9.0 / 3.9.0348 */349 public static AbstractShortAssert<?> assumeThat(Short actual) {350 return asAssumption(ShortAssert.class, Short.class, actual);351 }352 /**353 * Creates a new instance of <code>{@link ShortArrayAssert}</code> assumption.354 *355 * @param actual the actual value.356 * @return the created assumption for assertion object.357 * @since 2.9.0 / 3.9.0358 */359 public static AbstractShortArrayAssert<?> assumeThat(short[] actual) {360 return asAssumption(ShortArrayAssert.class, short[].class, actual);361 }362 /**363 * Creates a new instance of <code>{@link Short2DArrayAssert}</code> assumption.364 *365 * @param actual the actual value.366 * @return the created assumption for assertion object.367 * @since 3.17.0368 */369 public static Short2DArrayAssert assumeThat(short[][] actual) {370 return asAssumption(Short2DArrayAssert.class, short[][].class, actual);371 }372 /**373 * Creates a new instance of <code>{@link IntegerAssert}</code> assumption.374 *375 * @param actual the actual value.376 * @return the created assumption for assertion object.377 * @since 2.9.0 / 3.9.0378 */379 public static AbstractIntegerAssert<?> assumeThat(int actual) {380 return asAssumption(IntegerAssert.class, Integer.class, actual);381 }382 /**383 * Creates a new instance of <code>{@link IntegerAssert}</code> assumption.384 *385 * @param actual the actual value.386 * @return the created assumption for assertion object.387 * @since 2.9.0 / 3.9.0388 */389 public static AbstractIntegerAssert<?> assumeThat(Integer actual) {390 return asAssumption(IntegerAssert.class, Integer.class, actual);391 }392 /**393 * Creates a new instance of <code>{@link IntArrayAssert}</code> assumption.394 *395 * @param actual the actual value.396 * @return the created assumption for assertion object.397 * @since 2.9.0 / 3.9.0398 */399 public static AbstractIntArrayAssert<?> assumeThat(int[] actual) {400 return asAssumption(IntArrayAssert.class, int[].class, actual);401 }402 /**403 * Creates a new instance of <code>{@link Int2DArrayAssert}</code> assumption.404 *405 * @param actual the actual value.406 * @return the created assumption for assertion object.407 * @since 3.17.0408 */409 public static Int2DArrayAssert assumeThat(int[][] actual) {410 return asAssumption(Int2DArrayAssert.class, int[][].class, actual);411 }412 /**413 * Creates a new instance of <code>{@link LongAssert}</code> assumption.414 *415 * @param actual the actual value.416 * @return the created assumption for assertion object.417 * @since 2.9.0 / 3.9.0418 */419 public static AbstractLongAssert<?> assumeThat(long actual) {420 return asAssumption(LongAssert.class, Long.class, actual);421 }422 /**423 * Creates a new instance of <code>{@link LongAssert}</code> assumption.424 *425 * @param actual the actual value.426 * @return the created assumption for assertion object.427 * @since 2.9.0 / 3.9.0428 */429 public static AbstractLongAssert<?> assumeThat(Long actual) {430 return asAssumption(LongAssert.class, Long.class, actual);431 }432 /**433 * Creates a new instance of <code>{@link LongArrayAssert}</code> assumption.434 *435 * @param actual the actual value.436 * @return the created assumption for assertion object.437 * @since 2.9.0 / 3.9.0438 */439 public static AbstractLongArrayAssert<?> assumeThat(long[] actual) {440 return asAssumption(LongArrayAssert.class, long[].class, actual);441 }442 /**443 * Creates a new instance of <code>{@link Long2DArrayAssert}</code> assumption.444 *445 * @param actual the actual value.446 * @return the created assumption for assertion object.447 * @since 3.17.0448 */449 public static Long2DArrayAssert assumeThat(long[][] actual) {450 return asAssumption(Long2DArrayAssert.class, long[][].class, actual);451 }452 /**453 * Creates a new instance of <code>{@link FloatAssert}</code> assumption.454 *455 * @param actual the actual value.456 * @return the created assumption for assertion object.457 * @since 2.9.0 / 3.9.0458 */459 public static AbstractFloatAssert<?> assumeThat(float actual) {460 return asAssumption(FloatAssert.class, Float.class, actual);461 }462 /**463 * Creates a new instance of <code>{@link FloatAssert}</code> assumption.464 *465 * @param actual the actual value.466 * @return the created assumption for assertion object.467 * @since 2.9.0 / 3.9.0468 */469 public static AbstractFloatAssert<?> assumeThat(Float actual) {470 return asAssumption(FloatAssert.class, Float.class, actual);471 }472 /**473 * Creates a new instance of <code>{@link FloatArrayAssert}</code> assumption.474 *475 * @param actual the actual value.476 * @return the created assumption for assertion object.477 * @since 2.9.0 / 3.9.0478 */479 public static AbstractFloatArrayAssert<?> assumeThat(float[] actual) {480 return asAssumption(FloatArrayAssert.class, float[].class, actual);481 }482 /**483 * Creates a new instance of <code>{@link Float2DArrayAssert}</code> assumption.484 *485 * @param actual the actual value.486 * @return the created assumption for assertion object.487 * @since 3.17.0488 */489 public static Float2DArrayAssert assumeThat(float[][] actual) {490 return asAssumption(Float2DArrayAssert.class, float[][].class, actual);491 }492 /**493 * Creates a new instance of <code>{@link DoubleAssert}</code> assumption.494 *495 * @param actual the actual value.496 * @return the created assumption for assertion object.497 * @since 2.9.0 / 3.9.0498 */499 public static AbstractDoubleAssert<?> assumeThat(double actual) {500 return asAssumption(DoubleAssert.class, Double.class, actual);501 }502 /**503 * Creates a new instance of <code>{@link DoubleAssert}</code> assumption.504 *505 * @param actual the actual value.506 * @return the created assumption for assertion object.507 * @since 2.9.0 / 3.9.0508 */509 public static AbstractDoubleAssert<?> assumeThat(Double actual) {510 return asAssumption(DoubleAssert.class, Double.class, actual);511 }512 /**513 * Creates a new instance of <code>{@link DoubleArrayAssert}</code> assumption.514 *515 * @param actual the actual value.516 * @return the created assumption for assertion object.517 * @since 2.9.0 / 3.9.0518 */519 public static AbstractDoubleArrayAssert<?> assumeThat(double[] actual) {520 return asAssumption(DoubleArrayAssert.class, double[].class, actual);521 }522 /**523 * Creates a new instance of <code>{@link Double2DArrayAssert}</code> assumption.524 *525 * @param actual the actual value.526 * @return the created assumption for assertion object.527 * @since 3.17.0528 */529 public static Double2DArrayAssert assumeThat(double[][] actual) {530 return asAssumption(Double2DArrayAssert.class, double[][].class, actual);531 }532 /**533 * Create assumption for {@link AtomicBoolean}.534 *535 * @param actual the actual value.536 * @return the created assumption for assertion object.537 * @since 2.9.0 / 3.9.0538 */539 public static AtomicBooleanAssert assumeThat(AtomicBoolean actual) {540 return asAssumption(AtomicBooleanAssert.class, AtomicBoolean.class, actual);541 }542 /**543 * Create assumption for {@link AtomicInteger}.544 *545 * @param actual the actual value.546 * @return the created assumption for assertion object.547 * @since 2.9.0 / 3.9.0548 */549 public static AtomicIntegerAssert assumeThat(AtomicInteger actual) {550 return asAssumption(AtomicIntegerAssert.class, AtomicInteger.class, actual);551 }552 /**553 * Creates int[] assumption for {@link AtomicIntegerArray}.554 *555 * @param actual the actual value.556 * @return the created assumption for assertion object.557 * @since 2.9.0 / 3.9.0558 */559 public static AtomicIntegerArrayAssert assumeThat(AtomicIntegerArray actual) {560 return asAssumption(AtomicIntegerArrayAssert.class, AtomicIntegerArray.class, actual);561 }562 /**563 * Create assumption for {@link AtomicIntegerFieldUpdater}.564 *565 * @param actual the actual value.566 * @param <OBJECT> the type of the object holding the updatable field.567 * @return the created assumption for assertion object.568 * @since 2.9.0 / 3.9.0569 */570 @SuppressWarnings("unchecked")571 public static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assumeThat(AtomicIntegerFieldUpdater<OBJECT> actual) {572 return asAssumption(AtomicIntegerFieldUpdaterAssert.class, AtomicIntegerFieldUpdater.class, actual);573 }574 /**575 * Create assumption for {@link LongAdder}.576 *577 * @param actual the actual value.578 * @return the created assumption for assertion object.579 * @since 3.16.0580 */581 public static LongAdderAssert assumeThat(LongAdder actual) {582 return asAssumption(LongAdderAssert.class, LongAdder.class, actual);583 }584 /**585 * Create assumption for {@link AtomicLong}.586 *587 * @param actual the actual value.588 * @return the created assumption for assertion object.589 * @since 2.9.0 / 3.9.0590 */591 public static AtomicLongAssert assumeThat(AtomicLong actual) {592 return asAssumption(AtomicLongAssert.class, AtomicLong.class, actual);593 }594 /**595 * Create assumption for {@link AtomicLongArray}.596 *597 * @param actual the actual value.598 * @return the created assumption for assertion object.599 * @since 2.9.0 / 3.9.0600 */601 public static AtomicLongArrayAssert assumeThat(AtomicLongArray actual) {602 return asAssumption(AtomicLongArrayAssert.class, AtomicLongArray.class, actual);603 }604 /**605 * Create assumption for {@link AtomicLongFieldUpdater}.606 *607 * @param actual the actual value.608 * @param <OBJECT> the type of the object holding the updatable field.609 * @return the created assumption for assertion object.610 * @since 2.9.0 / 3.9.0611 */612 @SuppressWarnings("unchecked")613 public static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assumeThat(AtomicLongFieldUpdater<OBJECT> actual) {614 return asAssumption(AtomicLongFieldUpdaterAssert.class, AtomicLongFieldUpdater.class, actual);615 }616 /**617 * Create assumption for {@link AtomicReference}.618 *619 * @param actual the actual value.620 * @param <VALUE> the type of the value contained in the {@link AtomicReference}.621 * @return the created assumption for assertion object.622 * @since 2.9.0 / 3.9.0623 */624 @SuppressWarnings("unchecked")625 public static <VALUE> AtomicReferenceAssert<VALUE> assumeThat(AtomicReference<VALUE> actual) {626 return asAssumption(AtomicReferenceAssert.class, AtomicReference.class, actual);627 }628 /**629 * Create assumption for {@link AtomicReferenceArray}.630 *631 * @param actual the actual value.632 * @param <ELEMENT> the type of the value contained in the {@link AtomicReferenceArray}.633 * @return the created assumption for assertion object.634 * @since 2.9.0 / 3.9.0635 */636 @SuppressWarnings("unchecked")637 public static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assumeThat(AtomicReferenceArray<ELEMENT> actual) {638 return asAssumption(AtomicReferenceArrayAssert.class, AtomicReferenceArray.class, actual);639 }640 /**641 * Create assumption for {@link AtomicReferenceFieldUpdater}.642 *643 * @param actual the actual value.644 * @param <FIELD> the type of the field which gets updated by the {@link AtomicReferenceFieldUpdater}.645 * @param <OBJECT> the type of the object holding the updatable field.646 * @return the created assumption for assertion object.647 * @since 2.9.0 / 3.9.0648 */649 @SuppressWarnings("unchecked")650 public static <FIELD, OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD, OBJECT> assumeThat(651 AtomicReferenceFieldUpdater<OBJECT, FIELD> actual) {652 return asAssumption(AtomicReferenceFieldUpdaterAssert.class, AtomicReferenceFieldUpdater.class, actual);653 }654 /**655 * Create assumption for {@link AtomicMarkableReference}.656 *657 * @param actual the actual value.658 * @param <VALUE> the type of the value contained in the {@link AtomicMarkableReference}.659 * @return the created assumption for assertion object.660 * @since 2.9.0 / 3.9.0661 */662 @SuppressWarnings("unchecked")663 public static <VALUE> AtomicMarkableReferenceAssert<VALUE> assumeThat(AtomicMarkableReference<VALUE> actual) {664 return asAssumption(AtomicMarkableReferenceAssert.class, AtomicMarkableReference.class, actual);665 }666 /**667 * Create assumption for {@link AtomicStampedReference}.668 *669 * @param actual the actual value.670 * @param <VALUE> the type of the value contained in the {@link AtomicStampedReference}.671 * @return the created assumption for assertion object.672 * @since 2.9.0 / 3.9.0673 */674 @SuppressWarnings("unchecked")675 public static <VALUE> AtomicStampedReferenceAssert<VALUE> assumeThat(AtomicStampedReference<VALUE> actual) {676 return asAssumption(AtomicStampedReferenceAssert.class, AtomicStampedReference.class, actual);677 }678 /**679 * Creates a new instance of <code>{@link ClassAssert}</code> assumption.680 *681 * @param actual the actual value.682 * @return the created assumption for assertion object.683 * @since 2.9.0 / 3.9.0684 */685 public static ClassAssert assumeThat(Class<?> actual) {686 return asAssumption(ClassAssert.class, Class.class, actual);687 }688 /**689 * Creates a new instance of <code>{@link DateAssert}</code> assumption.690 *691 * @param actual the actual value.692 * @return the created assumption for assertion object.693 * @since 2.9.0 / 3.9.0694 */695 public static AbstractDateAssert<?> assumeThat(Date actual) {696 return asAssumption(DateAssert.class, Date.class, actual);697 }698 /**699 * Creates a new instance of <code>{@link FileAssert}</code> assumption.700 *701 * @param actual the actual value.702 * @return the created assumption for assertion object.703 * @since 2.9.0 / 3.9.0704 */705 public static AbstractFileAssert<?> assumeThat(File actual) {706 return asAssumption(FileAssert.class, File.class, actual);707 }708 /**709 * Creates a new instance of {@link PathAssert} assumption.710 *711 * @param actual the path to test712 * @return the created assumption for assertion object.713 * @since 2.9.0 / 3.9.0714 */715 public static AbstractPathAssert<?> assumeThat(Path actual) {716 return asAssumption(PathAssert.class, Path.class, actual);717 }718 /**719 * Creates a new instance of <code>{@link PathAssert}</code> assumption.720 * <p>721 * Use this over {@link #assumeThat(Path)} in case of ambiguous method resolution when the object under test722 * implements several interfaces Assertj provides <code>assumeThat</code> for.723 *724 * @param actual the actual value.725 * @return the created assumption for assertion object.726 * @since 3.23.0727 */728 public static AbstractPathAssert<?> assumeThatPath(Path actual) {729 return assumeThat(actual);730 }731 /**732 * Creates a new instance of <code>{@link InputStreamAssert}</code> assumption.733 *734 * @param actual the actual value.735 * @return the created assumption for assertion object.736 * @since 2.9.0 / 3.9.0737 */738 public static AbstractInputStreamAssert<?, ? extends InputStream> assumeThat(InputStream actual) {739 return asAssumption(InputStreamAssert.class, InputStream.class, actual);740 }741 /**742 * Create assertion for {@link FutureAssert} assumption.743 *744 * @param future the actual value.745 * @param <RESULT> the type of the value contained in the {@link java.util.concurrent.Future}.746 *747 * @return the created assumption for assertion object.748 * @since 2.9.0 / 3.9.0749 */750 @SuppressWarnings("unchecked")751 public static <RESULT> AbstractFutureAssert<?, ? extends Future<? extends RESULT>, RESULT> assumeThat(Future<RESULT> future) {752 return asAssumption(FutureAssert.class, Future.class, future);753 }754 /**755 * Creates a new instance of <code>{@link IterableAssert}</code> assumption.756 *757 * @param <ELEMENT> the type of elements.758 * @param actual the actual value.759 * @return the created assumption for assertion object.760 * @since 2.9.0 / 3.9.0761 */762 @SuppressWarnings("unchecked")763 public static <ELEMENT> IterableAssert<ELEMENT> assumeThat(Iterable<? extends ELEMENT> actual) {764 return asAssumption(IterableAssert.class, Iterable.class, actual);765 }766 /**767 * Creates a new instance of <code>{@link IterableAssert}</code> assumption.768 * <p>769 * Use this over {@link #assumeThat(Iterable)} in case of ambiguous method resolution when the object under test770 * implements several interfaces Assertj provides <code>assumeThat</code> for.771 *772 * @param <ELEMENT> the type of elements.773 * @param actual the actual value.774 * @return the created assumption for assertion object.775 * @since 3.23.0776 */777 public static <ELEMENT> IterableAssert<ELEMENT> assumeThatIterable(Iterable<? extends ELEMENT> actual) {778 return assumeThat(actual);779 }780 /**781 * Creates a new instance of <code>{@link IteratorAssert}</code> assumption.782 *783 * @param <ELEMENT> the type of elements.784 * @param actual the actual value.785 * @return the created assumption for assertion object.786 * @since 2.9.0 / 3.9.0787 */788 @SuppressWarnings("unchecked")789 public static <ELEMENT> IteratorAssert<ELEMENT> assumeThat(Iterator<? extends ELEMENT> actual) {790 return asAssumption(IteratorAssert.class, Iterator.class, actual);791 }792 /**793 * Creates a new instance of <code>{@link IteratorAssert}</code> assumption.794 * <p>795 * Use this over {@link #assumeThat(Iterator)} in case of ambiguous method resolution when the object under test796 * implements several interfaces Assertj provides <code>assumeThat</code> for.797 *798 * @param <ELEMENT> the type of elements.799 * @param actual the actual value.800 * @return the created assumption for assertion object.801 * @since 3.23.0802 */803 public static <ELEMENT> IteratorAssert<ELEMENT> assumeThatIterator(Iterator<? extends ELEMENT> actual) {804 return assumeThat(actual);805 }806 /**807 * Creates a new instance of <code>{@link CollectionAssert}</code> assumption.808 *809 * @param <E> the type of elements.810 * @param actual the actual value.811 * @return the created assumption for assertion object.812 * @since 3.21.0813 */814 @SuppressWarnings("unchecked")815 public static <E> AbstractCollectionAssert<?, Collection<? extends E>, E, ObjectAssert<E>> assumeThat(Collection<? extends E> actual) {816 return asAssumption(CollectionAssert.class, Collection.class, actual);817 }818 /**819 * Creates a new instance of <code>{@link CollectionAssert}</code> assumption.820 * <p>821 * Use this over {@link #assumeThat(Collection)} in case of ambiguous method resolution when the object under test822 * implements several interfaces Assertj provides <code>assumeThat</code> for.823 *824 * @param <E> the type of elements.825 * @param actual the actual value.826 * @return the created assumption for assertion object.827 * @since 3.23.0828 */829 public static <E> AbstractCollectionAssert<?, Collection<? extends E>, E, ObjectAssert<E>> assumeThatCollection(Collection<? extends E> actual) {830 return assumeThat(actual);831 }832 /**833 * Creates a new instance of <code>{@link ListAssert}</code> assumption.834 *835 * @param <ELEMENT> the type of elements.836 * @param actual the actual value.837 * @return the created assumption for assertion object.838 * @since 2.9.0 / 3.9.0839 */840 @SuppressWarnings("unchecked")841 public static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> assumeThat(List<? extends ELEMENT> actual) {842 return asAssumption(ListAssert.class, List.class, actual);843 }844 /**845 * Creates a new instance of <code>{@link ListAssert}</code> assumption.846 * <p>847 * Use this over {@link #assumeThat(List)} in case of ambiguous method resolution when the object under test848 * implements several interfaces Assertj provides <code>assumeThat</code> for.849 *850 * @param <ELEMENT> the type of elements.851 * @param actual the actual value.852 * @return the created assumption for assertion object.853 * @since 3.23.0854 */855 public static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> assumeThatList(List<? extends ELEMENT> actual) {856 return assumeThat(actual);857 }858 /**859 * Creates a new instance of <code>{@link ObjectArrayAssert}</code> assumption.860 *861 * @param <T> the type of elements.862 * @param actual the actual value.863 * @return the created assumption for assertion object.864 * @since 2.9.0 / 3.9.0865 */866 @SuppressWarnings("unchecked")867 public static <T> ObjectArrayAssert<T> assumeThat(T[] actual) {868 return asAssumption(ObjectArrayAssert.class, Object[].class, actual);869 }870 /**871 * Creates a new instance of <code>{@link Object2DArrayAssert}</code> assumption.872 *873 * @param <T> the type of elements.874 * @param actual the actual value.875 * @return the created assumption for assertion object.876 * @since 3.17.0877 */878 @SuppressWarnings("unchecked")879 public static <T> Object2DArrayAssert<T> assumeThat(T[][] actual) {880 return asAssumption(Object2DArrayAssert.class, Object[][].class, actual);881 }882 /**883 * Creates a new instance of <code>{@link MapAssert}</code> assumption.884 *885 * @param <K> the type of keys in the map.886 * @param <V> the type of values in the map.887 * @param actual the actual value.888 * @return the created assumption for assertion object.889 * @since 2.9.0 / 3.9.0890 */891 @SuppressWarnings("unchecked")892 public static <K, V> MapAssert<K, V> assumeThat(Map<K, V> actual) {893 return asAssumption(MapAssert.class, Map.class, actual);894 }895 /**896 * Creates a new instance of <code>{@link GenericComparableAssert}</code> assumption.897 *898 * @param <T> the type of actual.899 * @param actual the actual value.900 * @return the created assumption for assertion object.901 * @since 2.9.0 / 3.9.0902 */903 @SuppressWarnings("unchecked")904 public static <T extends Comparable<? super T>> AbstractComparableAssert<?, T> assumeThat(T actual) {905 return asAssumption(GenericComparableAssert.class, Comparable.class, actual);906 }907 /**908 * Creates a new instance of <code>{@link UniversalComparableAssert}</code> assumption.909 * <p>910 * Use this over {@link #assumeThat(Comparable)} in case of ambiguous method resolution when the object under test911 * implements several interfaces Assertj provides <code>assumeThat</code> for.912 *913 * @param <T> the type of actual.914 * @param actual the actual value.915 * @return the created assumption for assertion object.916 * @since 3.23.0917 */918 @SuppressWarnings("unchecked")919 public static <T> AbstractUniversalComparableAssert<?, T> assumeThatComparable(Comparable<T> actual) {920 return asAssumption(UniversalComparableAssert.class, Comparable.class, actual);921 }922 /**923 * Creates a new instance of <code>{@link ThrowableAssert}</code> assumption.924 *925 * @param <T> the type of the actual throwable.926 * @param actual the actual value.927 * @return the created assumption for assertion object.928 * @since 2.9.0 / 3.9.0929 */930 @SuppressWarnings("unchecked")931 public static <T extends Throwable> AbstractThrowableAssert<?, T> assumeThat(T actual) {932 return asAssumption(ThrowableAssert.class, Throwable.class, actual);933 }934 /**935 * Entry point to check that an exception of type T is thrown by a given {@code throwingCallable}936 * which allows to chain assertions on the thrown exception.937 *938 * @param <T> the exception type.939 * @param exceptionType the exception type class.940 * @return the created {@link ThrowableTypeAssert}.941 * @since 3.23.0942 */943 public static <T extends Throwable> ThrowableTypeAssert<T> assumeThatExceptionOfType(final Class<? extends T> exceptionType) {944 return new ThrowableTypeAssert<>(exceptionType);945 }946 /**947 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link Exception}.948 *949 * @return the created assumption for assertion object.950 * @since 3.23.0951 */952 public static ThrowableTypeAssert<Exception> assumeThatException() {953 return assumeThatExceptionOfType(Exception.class);954 }955 /**956 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link RuntimeException}.957 *958 * @return the created assumption for assertion object.959 * @since 3.23.0960 */961 public static ThrowableTypeAssert<RuntimeException> assumeThatRuntimeException() {962 return assumeThatExceptionOfType(RuntimeException.class);963 }964 /**965 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link NullPointerException}.966 *967 * @return the created assumption for assertion object.968 * @since 3.23.0969 */970 public static ThrowableTypeAssert<NullPointerException> assumeThatNullPointerException() {971 return assumeThatExceptionOfType(NullPointerException.class);972 }973 /**974 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link IllegalArgumentException}.975 *976 * @return the created assumption for assertion object.977 *978 * @since 3.23.0979 */980 public static ThrowableTypeAssert<IllegalArgumentException> assumeThatIllegalArgumentException() {981 return assumeThatExceptionOfType(IllegalArgumentException.class);982 }983 /**984 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link IOException}.985 *986 * @return the created assumption for assertion object.987 * @since 3.23.0988 */989 public static ThrowableTypeAssert<IOException> assumeThatIOException() {990 return assumeThatExceptionOfType(IOException.class);991 }992 /**993 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link IndexOutOfBoundsException}.994 *995 * @return the created assumption for assertion object.996 *997 * @since 3.23.0998 */999 public static ThrowableTypeAssert<IndexOutOfBoundsException> assumeThatIndexOutOfBoundsException() {1000 return assumeThatExceptionOfType(IndexOutOfBoundsException.class);1001 }1002 /**1003 * Alias for {@link #assumeThatExceptionOfType(Class)} for {@link ReflectiveOperationException}.1004 *1005 * @return the created assumption for assertion object.1006 * @since 3.23.01007 */1008 public static ThrowableTypeAssert<ReflectiveOperationException> assumeThatReflectiveOperationException() {1009 return assumeThatExceptionOfType(ReflectiveOperationException.class);1010 }1011 /**1012 * Allows to capture and then assume on a {@link Throwable} (easier done with lambdas).1013 * <p>1014 * Example :1015 * <pre><code class='java'> {@literal @}Test1016 * public void testException() {1017 * assumeThatThrownBy(() -&gt; { throw new Exception("boom!") }).isInstanceOf(Exception.class)1018 * .hasMessageContaining("boom");1019 * }</code></pre>1020 *1021 * @param shouldRaiseThrowable The {@link ThrowingCallable} or lambda with the code that should raise the throwable.1022 * @return the created assumption for assertion object.1023 * @since 2.9.0 / 3.9.01024 */1025 @SuppressWarnings("unchecked")1026 public static AbstractThrowableAssert<?, ? extends Throwable> assumeThatThrownBy(ThrowingCallable shouldRaiseThrowable) {1027 return asAssumption(ThrowableAssert.class, Throwable.class, catchThrowable(shouldRaiseThrowable));1028 }1029 /**1030 * Allows to capture and then assume on a {@link Throwable} (easier done with lambdas).1031 * <p>1032 * The main difference with {@code assumeThatThrownBy(ThrowingCallable)} is that this method does not fail if no exception was thrown.1033 * <p>1034 * Example :1035 * <pre><code class='java'> ThrowingCallable callable = () -&gt; {1036 * throw new Exception("boom!");1037 * };1038 *1039 * // assertion succeeds1040 * assumeThatCode(callable).isInstanceOf(Exception.class)1041 * .hasMessageContaining("boom");1042 *1043 * // assertion fails1044 * assumeThatCode(callable).doesNotThrowAnyException();</code></pre>1045 * <p>1046 * This method was not named {@code assumeThat} because the java compiler reported it ambiguous when used directly with a lambda :(1047 *1048 * @param shouldRaiseOrNotThrowable The {@link ThrowingCallable} or lambda with the code that should raise the throwable.1049 * @return the created {@link ThrowableAssert}.1050 * @since 3.9.01051 */1052 public static AbstractThrowableAssert<?, ? extends Throwable> assumeThatCode(ThrowingCallable shouldRaiseOrNotThrowable) {1053 return assumeThat(catchThrowable(shouldRaiseOrNotThrowable));1054 }1055 /**1056 * Creates a new instance of <code>{@link ObjectAssert}</code> assumption.1057 * <p>1058 * This overload is useful, when an overloaded method of assertThat(...) takes precedence over the generic {@link1059 * #assumeThat(Object)}.1060 * <p>1061 * Example:1062 * <p>1063 * Cast necessary because {@link #assumeThat(List)} "forgets" actual type:1064 * <pre>{@code assumeThat(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc")); }</pre>1065 * No cast needed, but also no additional list assertions:1066 * <pre>{@code assumeThatObject(new LinkedList<>(asList("abc"))).matches(list -> list.getFirst().equals("abc")); }</pre>1067 *1068 * @param <T> the type of the actual value.1069 * @param actual the actual value.1070 * @return the created assertion object.1071 * @since 3.12.01072 */1073 public static <T> ObjectAssert<T> assumeThatObject(T actual) {1074 return assumeThat(actual);1075 }1076 /**1077 * Creates a new instance of {@link PredicateAssert} assumption.1078 *1079 * @param <T> the {@link Predicate} type.1080 * @param actual the Predicate to test1081 * @return the created assumption for assertion object.1082 * @since 3.9.01083 */1084 @SuppressWarnings("unchecked")1085 public static <T> PredicateAssert<T> assumeThat(Predicate<T> actual) {1086 return asAssumption(PredicateAssert.class, Predicate.class, actual);1087 }1088 /**1089 * Creates a new instance of <code>{@link PredicateAssert}</code> assumption.1090 * <p>1091 * Use this over {@link #assumeThat(Predicate)} in case of ambiguous method resolution when the object under test1092 * implements several interfaces Assertj provides <code>assumeThat</code> for.1093 *1094 * @param <T> the type of elements.1095 * @param actual the actual value.1096 * @return the created assumption for assertion object.1097 * @since 3.23.01098 */1099 public static <T> PredicateAssert<T> assumeThatPredicate(Predicate<T> actual) {1100 return assumeThat(actual);1101 }1102 /**1103 * Creates a new instance of {@link IntPredicateAssert} assumption.1104 *1105 * @param actual the IntPredicate to test1106 * @return the created assumption for assertion object.1107 * @since 3.9.01108 */1109 public static IntPredicateAssert assumeThat(IntPredicate actual) {1110 return asAssumption(IntPredicateAssert.class, IntPredicate.class, actual);1111 }1112 /**1113 * Creates a new instance of {@link LongPredicateAssert} assumption.1114 *1115 * @param actual the LongPredicate to test1116 * @return the created assumption for assertion object.1117 * @since 3.9.01118 */1119 public static LongPredicateAssert assumeThat(LongPredicate actual) {1120 return asAssumption(LongPredicateAssert.class, LongPredicate.class, actual);1121 }1122 /**1123 * Creates a new instance of {@link DoublePredicateAssert} assumption.1124 *1125 * @param actual the DoublePredicate to test1126 * @return the created assumption for assertion object.1127 * @since 3.9.01128 */1129 public static DoublePredicateAssert assumeThat(DoublePredicate actual) {1130 return asAssumption(DoublePredicateAssert.class, DoublePredicate.class, actual);1131 }1132 /**1133 * Creates a new instance of {@link CompletableFutureAssert} assumption.1134 *1135 * @param <RESULT> the CompletableFuture wrapped type.1136 * @param actual the CompletableFuture to test1137 * @return the created assumption for assertion object.1138 * @since 3.9.01139 */1140 @SuppressWarnings("unchecked")1141 public static <RESULT> CompletableFutureAssert<RESULT> assumeThat(CompletableFuture<RESULT> actual) {1142 return asAssumption(CompletableFutureAssert.class, CompletableFuture.class, actual);1143 }1144 /**1145 * Creates a new instance of {@link CompletableFutureAssert} assumption for a {@link java.util.concurrent.CompletionStage}1146 * by converting it to a {@link CompletableFuture} and returning a {@link CompletableFutureAssert}.1147 * <p>1148 * If the given {@link java.util.concurrent.CompletionStage} is null, the {@link CompletableFuture} in the returned {@link CompletableFutureAssert} will also be null.1149 *1150 * @param <RESULT> the CompletableFuture wrapped type.1151 * @param actual the CompletableFuture to test1152 * @return the created assumption for assertion object.1153 * @since 3.9.01154 */1155 @SuppressWarnings("unchecked")1156 public static <RESULT> CompletableFutureAssert<RESULT> assumeThat(CompletionStage<RESULT> actual) {1157 return asAssumption(CompletableFutureAssert.class, CompletionStage.class, actual);1158 }1159 /**1160 * Creates a new instance of {@link OptionalAssert} assumption.1161 *1162 * @param <VALUE> the Optional wrapped type.1163 * @param actual the Optional to test1164 * @return the created assumption for assertion object.1165 * @since 3.9.01166 */1167 @SuppressWarnings("unchecked")1168 public static <VALUE> OptionalAssert<VALUE> assumeThat(Optional<VALUE> actual) {1169 return asAssumption(OptionalAssert.class, Optional.class, actual);1170 }1171 /**1172 * Creates a new instance of {@link OptionalDoubleAssert} assumption.1173 *1174 * @param actual the OptionalDouble to test1175 * @return the created assumption for assertion object.1176 * @since 3.9.01177 */1178 public static OptionalDoubleAssert assumeThat(OptionalDouble actual) {1179 return asAssumption(OptionalDoubleAssert.class, OptionalDouble.class, actual);1180 }1181 /**1182 * Creates a new instance of {@link MatcherAssert} assumption.1183 *1184 * @param actual the Matcher to test1185 * @return the created assumption for assertion object.1186 */1187 public static MatcherAssert assumeThat(Matcher actual) {1188 return asAssumption(MatcherAssert.class, Matcher.class, actual);1189 }1190 /**1191 * Creates a new instance of {@link OptionalIntAssert} assumption.1192 *1193 * @param actual the OptionalInt to test1194 * @return the created assumption for assertion object.1195 * @since 3.9.01196 */1197 public static OptionalIntAssert assumeThat(OptionalInt actual) {1198 return asAssumption(OptionalIntAssert.class, OptionalInt.class, actual);1199 }1200 /**1201 * Creates a new instance of {@link OptionalLongAssert} assumption.1202 *1203 * @param actual the OptionalLong to test1204 * @return the created assumption for assertion object.1205 * @since 3.9.01206 */1207 public static OptionalLongAssert assumeThat(OptionalLong actual) {1208 return asAssumption(OptionalLongAssert.class, OptionalLong.class, actual);1209 }1210 /**1211 * Creates a new instance of {@link ZonedDateTimeAssert} assumption.1212 *1213 * @param actual the ZonedDateTime to test1214 * @return the created assumption for assertion object.1215 * @since 3.9.01216 */1217 public static AbstractZonedDateTimeAssert<?> assumeThat(ZonedDateTime actual) {1218 return asAssumption(ZonedDateTimeAssert.class, ZonedDateTime.class, actual);1219 }1220 /**1221 * Creates a new instance of {@link LocalDateTimeAssert} assumption.1222 *1223 * @param actual the LocalDateTime to test1224 * @return the created assumption for assertion object.1225 * @since 3.9.01226 */1227 public static AbstractLocalDateTimeAssert<?> assumeThat(LocalDateTime actual) {1228 return asAssumption(LocalDateTimeAssert.class, LocalDateTime.class, actual);1229 }1230 /**1231 * Creates a new instance of {@link OffsetDateTimeAssert} assumption.1232 *1233 * @param actual the OffsetDateTime to test1234 * @return the created assumption for assertion object.1235 * @since 3.9.01236 */1237 public static AbstractOffsetDateTimeAssert<?> assumeThat(OffsetDateTime actual) {1238 return asAssumption(OffsetDateTimeAssert.class, OffsetDateTime.class, actual);1239 }1240 /**1241 * Creates a new instance of {@link OffsetTimeAssert} assumption.1242 *1243 * @param actual the LocalTime to test1244 * @return the created assumption for assertion object.1245 * @since 3.9.01246 */1247 public static AbstractOffsetTimeAssert<?> assumeThat(OffsetTime actual) {1248 return asAssumption(OffsetTimeAssert.class, OffsetTime.class, actual);1249 }1250 /**1251 * Creates a new instance of {@link LocalTimeAssert} assumption.1252 *1253 * @param actual the LocalTime to test1254 * @return the created assumption for assertion object.1255 * @since 3.9.01256 */1257 public static AbstractLocalTimeAssert<?> assumeThat(LocalTime actual) {1258 return asAssumption(LocalTimeAssert.class, LocalTime.class, actual);1259 }1260 /**1261 * Creates a new instance of {@link LocalDateAssert} assumption.1262 *1263 * @param actual the LocalDate to test1264 * @return the created assumption for assertion object.1265 * @since 3.9.01266 */1267 public static AbstractLocalDateAssert<?> assumeThat(LocalDate actual) {1268 return asAssumption(LocalDateAssert.class, LocalDate.class, actual);1269 }1270 /**1271 * Creates a new instance of {@link InstantAssert} assumption.1272 *1273 * @param actual the Instant to test1274 * @return the created assumption for assertion object.1275 * @since 3.9.01276 */1277 public static AbstractInstantAssert<?> assumeThat(Instant actual) {1278 return asAssumption(InstantAssert.class, Instant.class, actual);1279 }1280 /**1281 * Creates a new instance of {@link DurationAssert} assumption.1282 *1283 * @param actual the Duration to test1284 * @return the created assumption for assertion object.1285 * @since 3.15.01286 */1287 public static AbstractDurationAssert<?> assumeThat(Duration actual) {1288 return asAssumption(DurationAssert.class, Duration.class, actual);1289 }1290 /**1291 * Creates a new instance of {@link PeriodAssert} assumption.1292 *1293 * @param actual the Period to test1294 * @return the created assumption for assertion object.1295 * @since 3.17.01296 */1297 public static AbstractPeriodAssert<?> assumeThat(Period actual) {1298 return asAssumption(PeriodAssert.class, Period.class, actual);1299 }1300 /**1301 * Creates a new instance of <code>{@link ListAssert}</code> assumption from the given {@link Stream}.1302 *1303 * @param <ELEMENT> the type of elements.1304 * @param actual the Stream to test1305 * @return the created assumption for assertion object.1306 * @since 3.9.01307 */1308 @SuppressWarnings("unchecked")1309 public static <ELEMENT> AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> assumeThat(Stream<? extends ELEMENT> actual) {1310 return asAssumption(ListAssert.class, Stream.class, actual);1311 }1312 /**1313 * Creates a new instance of <code>{@link ListAssert}</code> assumption from the given {@link Stream}.1314 * <p>1315 * Use this over {@link #assumeThat(Stream)} in case of ambiguous method resolution when the object under test1316 * implements several interfaces Assertj provides <code>assumeThat</code> for.1317 *1318 * @param <ELEMENT> the type of elements.1319 * @param actual the actual value.1320 * @return the created assumption for assertion object.1321 * @since 3.23.01322 */1323 public static <ELEMENT> AbstractListAssert<?, List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> assumeThatStream(Stream<? extends ELEMENT> actual) {1324 return assumeThat(actual);1325 }1326 /**1327 * Creates a new instance of <code>{@link ListAssert}</code> assumption from the given {@link DoubleStream}.1328 *1329 * @param actual the DoubleStream to test1330 * @return the created assumption for assertion object.1331 * @since 3.9.01332 */1333 @SuppressWarnings("unchecked")1334 public static AbstractListAssert<?, List<? extends Double>, Double, ObjectAssert<Double>> assumeThat(DoubleStream actual) {1335 return asAssumption(ListAssert.class, DoubleStream.class, actual);1336 }1337 /**1338 * Creates a new instance of <code>{@link ListAssert}</code> assumption from the given {@link LongStream}.1339 *1340 * @param actual the LongStream to test1341 * @return the created assumption for assertion object.1342 * @since 3.9.01343 */1344 @SuppressWarnings("unchecked")1345 public static AbstractListAssert<?, List<? extends Long>, Long, ObjectAssert<Long>> assumeThat(LongStream actual) {1346 return asAssumption(ListAssert.class, LongStream.class, actual);1347 }1348 /**1349 * Creates a new instance of <code>{@link ListAssert}</code> assumption from the given {@link IntStream}.1350 *1351 * @param actual the LongStream to test1352 * @return the created assumption for assertion object.1353 * @since 3.9.01354 */1355 @SuppressWarnings("unchecked")1356 public static AbstractListAssert<?, List<? extends Integer>, Integer, ObjectAssert<Integer>> assumeThat(IntStream actual) {1357 return asAssumption(ListAssert.class, IntStream.class, actual);1358 }1359 /**1360 * Creates a new instance of <code>{@link SpliteratorAssert}</code> assumption from the given {@link Spliterator}.1361 *1362 * @param <ELEMENT> the type of the elements1363 * @param actual the Spliterator to test1364 * @return the created assumption for assertion object.1365 */1366 @SuppressWarnings("unchecked")1367 public static <ELEMENT> AbstractSpliteratorAssert<?, ELEMENT> assumeThat(Spliterator<ELEMENT> actual) {1368 return asAssumption(SpliteratorAssert.class, Spliterator.class, actual);1369 }1370 /**1371 * Sets which exception is thrown if an assumption is not met. 1372 * <p>1373 * This method is useful if you are using a testing framework that supports assumptions and expect a specific exception to be thrown when an assumption is not met. 1374 * <p>1375 * You can choose one of:1376 * <ul>1377 * <li>{@link PreferredAssumptionException#TEST_NG} to throw a {@code org.testng.SkipException} if you are using TestNG</li>1378 * <li>{@link PreferredAssumptionException#JUNIT4} to throw a {@code org.junit.AssumptionViolatedException} if you are using JUnit 4</li>1379 * <li>{@link PreferredAssumptionException#JUNIT5} a {@code org.opentest4j.TestAbortedException} if you are using JUnit 5</li>1380 * <li>{@link PreferredAssumptionException#AUTO_DETECT} to get the default behavior where AssertJ tries different exception (explained later on)</li>1381 * </ul>1382 * <p>1383 * Make sure that the exception you choose can be found in the classpath otherwise AssertJ will throw an {@link IllegalStateException}.1384 * <p>1385 * For example JUnit4 expects {@code org.junit.AssumptionViolatedException}, you can tell AssertJ to use it as shown below:1386 * <pre><code class='java'> // after this call, AssertJ will throw an org.junit.AssumptionViolatedException when an assumption is not met 1387 * Assertions.setPreferredAssumptionExceptions(PreferredAssumptionException.JUNIT4);1388 * </code></pre>1389 * <p>1390 * By default, AssertJ uses the {@link PreferredAssumptionException#AUTO_DETECT AUTO_DETECT} mode and tries to throw one of the following exceptions, in this order:1391 * <ol>1392 * <li>{@code org.testng.SkipException} for TestNG (if available in the classpath)</li>1393 * <li>{@code org.junit.AssumptionViolatedException} for JUnit 4 (if available in the classpath)</li>1394 * <li>{@code org.opentest4j.TestAbortedException} for JUnit 5</li>1395 * </ol> 1396 *1397 * @param preferredAssumptionException the preferred exception to use with {@link Assumptions}.1398 * @since 3.21.01399 */1400 public static void setPreferredAssumptionException(PreferredAssumptionException preferredAssumptionException) {1401 AssumptionExceptionFactory.setPreferredAssumptionException(preferredAssumptionException);1402 }1403 // private methods1404 private static <ASSERTION, ACTUAL> ASSERTION asAssumption(Class<ASSERTION> assertionType,1405 Class<ACTUAL> actualType,1406 Object actual) {1407 return asAssumption(assertionType, array(actualType), array(actual));1408 }1409 private static <ASSERTION> ASSERTION asAssumption(Class<ASSERTION> assertionType,1410 Class<?>[] constructorTypes,1411 Object... constructorParams) {1412 try {1413 Class<? extends ASSERTION> type = createAssumptionClass(assertionType);1414 Constructor<? extends ASSERTION> constructor = type.getConstructor(constructorTypes);1415 return constructor.newInstance(constructorParams);1416 } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {1417 throw new RuntimeException(e);1418 }1419 }1420 @SuppressWarnings("unchecked")1421 private static <ASSERTION> Class<? extends ASSERTION> createAssumptionClass(Class<ASSERTION> assertClass) {1422 SimpleKey cacheKey = new SimpleKey(assertClass);1423 return (Class<ASSERTION>) CACHE.findOrInsert(assertClass.getClassLoader(),1424 cacheKey,1425 () -> generateAssumptionClass(assertClass));1426 }1427 protected static <ASSERTION> Class<? extends ASSERTION> generateAssumptionClass(Class<ASSERTION> assertionType) {1428 ClassLoadingStrategyPair strategy = classLoadingStrategy(assertionType);1429 return BYTE_BUDDY.subclass(assertionType)1430 .method(any().and(not(METHODS_NOT_TO_PROXY)))1431 .intercept(ASSUMPTION)1432 .make()1433 .load(strategy.getClassLoader(), strategy.getClassLoadingStrategy())1434 .getLoaded();1435 }1436 // for method that change the object under test (e.g. extracting)1437 private static AbstractAssert<?, ?> asAssumption(AbstractAssert<?, ?> assertion) {1438 // @format:off1439 Object actual = assertion.actual;1440 if (assertion instanceof AbstractObjectArrayAssert) return asAssumption(ObjectArrayAssert.class, Object[].class, actual);1441 if (assertion instanceof AtomicBooleanAssert) return asAssumption(AtomicBooleanAssert.class, AtomicBoolean.class, actual);1442 if (assertion instanceof AtomicIntegerAssert) return asAssumption(AtomicIntegerAssert.class, AtomicInteger.class, actual);1443 if (assertion instanceof AtomicIntegerArrayAssert) return asAssumption(AtomicIntegerArrayAssert.class, AtomicIntegerArray.class, actual);1444 if (assertion instanceof AtomicIntegerFieldUpdaterAssert) return asAssumption(AtomicIntegerFieldUpdaterAssert.class, AtomicIntegerFieldUpdater.class, actual);1445 if (assertion instanceof AtomicLongAssert) return asAssumption(AtomicLongAssert.class, AtomicLong.class, actual);1446 if (assertion instanceof AtomicLongArrayAssert) return asAssumption(AtomicLongArrayAssert.class, AtomicLongArray.class, actual);1447 if (assertion instanceof AtomicLongFieldUpdaterAssert) return asAssumption(AtomicLongFieldUpdaterAssert.class, AtomicLongFieldUpdater.class, actual);1448 if (assertion instanceof AtomicMarkableReferenceAssert) return asAssumption(AtomicMarkableReferenceAssert.class, AtomicMarkableReference.class, actual);1449 if (assertion instanceof AtomicReferenceAssert) return asAssumption(AtomicReferenceAssert.class, AtomicReference.class, actual);1450 if (assertion instanceof AtomicReferenceArrayAssert) return asAssumption(AtomicReferenceArrayAssert.class, AtomicReferenceArray.class, actual);1451 if (assertion instanceof AtomicReferenceFieldUpdaterAssert) return asAssumption(AtomicReferenceFieldUpdaterAssert.class, AtomicReferenceFieldUpdater.class, actual);1452 if (assertion instanceof AtomicStampedReferenceAssert) return asAssumption(AtomicStampedReferenceAssert.class, AtomicStampedReference.class, actual);1453 if (assertion instanceof BigDecimalAssert) return asAssumption(BigDecimalAssert.class, BigDecimal.class, actual);1454 if (assertion instanceof BigDecimalScaleAssert) return asBigDecimalScaleAssumption(assertion);1455 if (assertion instanceof BigIntegerAssert) return asAssumption(BigIntegerAssert.class, BigInteger.class, actual);1456 if (assertion instanceof BooleanAssert) return asAssumption(BooleanAssert.class, Boolean.class, actual);1457 if (assertion instanceof Boolean2DArrayAssert) return asAssumption(Boolean2DArrayAssert.class, boolean[][].class, actual);1458 if (assertion instanceof BooleanArrayAssert) return asAssumption(BooleanArrayAssert.class, boolean[].class, actual);1459 if (assertion instanceof ByteAssert) return asAssumption(ByteAssert.class, Byte.class, actual);1460 if (assertion instanceof Byte2DArrayAssert) return asAssumption(Byte2DArrayAssert.class, byte[][].class, actual);1461 if (assertion instanceof ByteArrayAssert) return asAssumption(ByteArrayAssert.class, byte[].class, actual);1462 if (assertion instanceof CharacterAssert) return asAssumption(CharacterAssert.class, char.class, actual);1463 if (assertion instanceof Char2DArrayAssert) return asAssumption(Char2DArrayAssert.class, char[][].class, actual);1464 if (assertion instanceof CharArrayAssert) return asAssumption(CharArrayAssert.class, char[].class, actual);1465 if (assertion instanceof CharSequenceAssert) return asAssumption(CharSequenceAssert.class, CharSequence.class, actual);1466 if (assertion instanceof ClassAssert) return asAssumption(ClassAssert.class, Class.class, actual);1467 if (assertion instanceof CollectionAssert) return asAssumption(CollectionAssert.class, Collection.class, actual);1468 if (assertion instanceof CompletableFutureAssert) return asAssumption(CompletableFutureAssert.class, CompletableFuture.class, actual);1469 if (assertion instanceof DateAssert) return asAssumption(DateAssert.class, Date.class, actual);1470 if (assertion instanceof DoubleAssert) return asAssumption(DoubleAssert.class, Double.class, actual);1471 if (assertion instanceof Double2DArrayAssert) return asAssumption(Double2DArrayAssert.class, double[][].class, actual);1472 if (assertion instanceof DoubleArrayAssert) return asAssumption(DoubleArrayAssert.class, double[].class, actual);1473 if (assertion instanceof DoublePredicateAssert) return asAssumption(DoublePredicateAssert.class, DoublePredicate.class, actual);1474 if (assertion instanceof DurationAssert) return asAssumption(DurationAssert.class, Duration.class, actual);1475 if (assertion instanceof FactoryBasedNavigableListAssert) return asAssumption(ListAssert.class, List.class, actual);1476 if (assertion instanceof FileAssert) return asAssumption(FileAssert.class, File.class, actual);1477 if (assertion instanceof FileSizeAssert) return asFileSizeAssumption(assertion);1478 if (assertion instanceof FloatAssert) return asAssumption(FloatAssert.class, Float.class, actual);1479 if (assertion instanceof Float2DArrayAssert) return asAssumption(Float2DArrayAssert.class, float[][].class, actual);1480 if (assertion instanceof FloatArrayAssert) return asAssumption(FloatArrayAssert.class, float[].class, actual);1481 if (assertion instanceof FutureAssert) return asAssumption(FutureAssert.class, Future.class, actual);1482 if (assertion instanceof InputStreamAssert) return asAssumption(InputStreamAssert.class, InputStream.class, actual);1483 if (assertion instanceof InstantAssert) return asAssumption(InstantAssert.class, Instant.class, actual);1484 if (assertion instanceof IntegerAssert) return asAssumption(IntegerAssert.class, Integer.class, actual);1485 if (assertion instanceof Int2DArrayAssert) return asAssumption(Int2DArrayAssert.class, int[][].class, actual);1486 if (assertion instanceof IntArrayAssert) return asAssumption(IntArrayAssert.class, int[].class, actual);1487 if (assertion instanceof IntPredicateAssert) return asAssumption(IntPredicateAssert.class, IntPredicate.class, actual);1488 if (assertion instanceof IterableAssert) return asAssumption(IterableAssert.class, Iterable.class, actual);1489 if (assertion instanceof IterableSizeAssert) return asIterableSizeAssumption(assertion);1490 if (assertion instanceof IteratorAssert) return asAssumption(IteratorAssert.class, Iterator.class, actual);1491 if (assertion instanceof LocalDateAssert) return asAssumption(LocalDateAssert.class, LocalDate.class, actual);1492 if (assertion instanceof LocalDateTimeAssert) return asAssumption(LocalDateTimeAssert.class, LocalDateTime.class, actual);1493 if (assertion instanceof LocalTimeAssert) return asAssumption(LocalTimeAssert.class, LocalTime.class, actual);1494 if (assertion instanceof LongAdderAssert) return asAssumption(LongAdderAssert.class, LongAdder.class, actual);1495 if (assertion instanceof LongArrayAssert) return asAssumption(LongArrayAssert.class, long[].class, actual);1496 if (assertion instanceof Long2DArrayAssert) return asAssumption(Long2DArrayAssert.class, long[][].class, actual);1497 if (assertion instanceof LongAssert) return asAssumption(LongAssert.class, Long.class, actual);1498 if (assertion instanceof LongPredicateAssert) return asAssumption(LongPredicateAssert.class, LongPredicate.class, actual);1499 if (assertion instanceof MapAssert) return asAssumption(MapAssert.class, Map.class, actual);1500 if (assertion instanceof MapSizeAssert) return asMapSizeAssumption(assertion);1501 if (assertion instanceof OffsetDateTimeAssert) return asAssumption(OffsetDateTimeAssert.class, OffsetDateTime.class, actual);1502 if (assertion instanceof OffsetTimeAssert) return asAssumption(OffsetTimeAssert.class, OffsetTime.class, actual);1503 if (assertion instanceof ObjectAssert) return asAssumption(ObjectAssert.class, Object.class, actual);1504 if (assertion instanceof OptionalAssert) return asAssumption(OptionalAssert.class, Optional.class, actual);1505 if (assertion instanceof OptionalDoubleAssert) return asAssumption(OptionalDoubleAssert.class, OptionalDouble.class, actual);1506 if (assertion instanceof OptionalIntAssert) return asAssumption(OptionalIntAssert.class, OptionalInt.class, actual);1507 if (assertion instanceof OptionalLongAssert) return asAssumption(OptionalLongAssert.class, OptionalLong.class, actual);1508 if (assertion instanceof PathAssert) return asAssumption(PathAssert.class, Path.class, actual);1509 if (assertion instanceof PeriodAssert) return asAssumption(PeriodAssert.class, Period.class, actual);1510 if (assertion instanceof PredicateAssert) return asAssumption(PredicateAssert.class, Predicate.class, actual);1511 if (assertion instanceof RecursiveComparisonAssert) return asRecursiveComparisonAssumption(assertion);1512 if (assertion instanceof ShortAssert) return asAssumption(ShortAssert.class, Short.class, actual);1513 if (assertion instanceof Short2DArrayAssert) return asAssumption(Short2DArrayAssert.class, short[][].class, actual);1514 if (assertion instanceof ShortArrayAssert) return asAssumption(ShortArrayAssert.class, short[].class, actual);1515 if (assertion instanceof SpliteratorAssert) return asAssumption(SpliteratorAssert.class, Spliterator.class, actual);1516 if (assertion instanceof StringAssert) return asAssumption(StringAssert.class, String.class, actual);1517 if (assertion instanceof ThrowableAssert) return asAssumption(ThrowableAssert.class, Throwable.class, actual);1518 if (assertion instanceof UriAssert) return asAssumption(UriAssert.class, URI.class, actual);1519 if (assertion instanceof UrlAssert) return asAssumption(UrlAssert.class, URL.class, actual);1520 if (assertion instanceof ZonedDateTimeAssert) return asAssumption(ZonedDateTimeAssert.class, ZonedDateTime.class, actual);1521 // should be last of 2D array assertions type to acoid shadowing Boolean2DArrayAssert and co1522 if (assertion instanceof Abstract2DArrayAssert) return asAssumption(Object2DArrayAssert.class, Object[][].class, actual);1523 // @format:on1524 // should not arrive here1525 throw new IllegalArgumentException("Unsupported assumption creation for " + assertion.getClass());1526 }1527 private static AbstractAssert<?, ?> asRecursiveComparisonAssumption(AbstractAssert<?, ?> assertion) {1528 RecursiveComparisonAssert<?> recursiveComparisonAssert = (RecursiveComparisonAssert<?>) assertion;1529 RecursiveComparisonConfiguration recursiveComparisonConfiguration = recursiveComparisonAssert.getRecursiveComparisonConfiguration();1530 Class<?>[] constructorTypes = array(Object.class, RecursiveComparisonConfiguration.class);1531 return asAssumption(RecursiveComparisonAssert.class, constructorTypes, assertion.actual, recursiveComparisonConfiguration);1532 }1533 private static AbstractAssert<?, ?> asMapSizeAssumption(AbstractAssert<?, ?> assertion) {1534 MapSizeAssert<?, ?> mapSizeAssert = (MapSizeAssert<?, ?>) assertion;1535 Class<?>[] constructorTypes = array(AbstractMapAssert.class, Integer.class);1536 return asAssumption(MapSizeAssert.class, constructorTypes, mapSizeAssert.returnToMap(), assertion.actual);1537 }1538 private static AbstractAssert<?, ?> asIterableSizeAssumption(AbstractAssert<?, ?> assertion) {1539 IterableSizeAssert<?> iterableSizeAssert = (IterableSizeAssert<?>) assertion;1540 Class<?>[] constructorTypes = array(AbstractIterableAssert.class, Integer.class);1541 return asAssumption(IterableSizeAssert.class, constructorTypes, iterableSizeAssert.returnToIterable(), assertion.actual);1542 }1543 private static AbstractAssert<?, ?> asFileSizeAssumption(AbstractAssert<?, ?> assertion) {1544 FileSizeAssert<?> fileSizeAssert = (FileSizeAssert<?>) assertion;1545 Class<?>[] constructorTypes = array(AbstractFileAssert.class);1546 return asAssumption(FileSizeAssert.class, constructorTypes, fileSizeAssert.returnToFile());1547 }1548 private static AbstractAssert<?, ?> asBigDecimalScaleAssumption(AbstractAssert<?, ?> assertion) {1549 BigDecimalScaleAssert<?> bigDecimalScaleAssert = (BigDecimalScaleAssert<?>) assertion;1550 Class<?>[] constructorTypes = array(AbstractBigDecimalAssert.class);1551 return asAssumption(BigDecimalScaleAssert.class, constructorTypes, bigDecimalScaleAssert.returnToBigDecimal());1552 }1553}...

Full Screen

Full Screen

Source:VavrAssumptions.java Github

copy

Full Screen

...50 public static Object intercept(@This AbstractVavrAssert<?, ?> assertion, @SuperCall Callable<Object> proxy) throws Exception {51 try {52 Object result = proxy.call();53 if (result != assertion && result instanceof AbstractVavrAssert) {54 final AbstractVavrAssert<?, ?> assumption = asAssumption((AbstractVavrAssert<?, ?>) result);55 return assumption.withAssertionState(assertion);56 }57 return result;58 } catch (AssertionError e) {59 throw assumptionNotMet(e);60 }61 }62 }63 /**64 * Creates a new instance of <code>{@link EitherAssert}</code> assumption.65 *66 * @param <LEFT> type of the left value contained in the {@link Either}.67 * @param <RIGHT> type of the right value contained in the {@link Either}.68 * @param actual the actual value.69 * @return the created assumption for assertion object.70 */71 @CheckReturnValue72 @SuppressWarnings("unchecked")73 public static <LEFT, RIGHT> EitherAssert<LEFT, RIGHT> assumeThat(Either<LEFT, RIGHT> actual) {74 return asAssumption(EitherAssert.class, Either.class, actual);75 }76 /**77 * Creates a new instance of <code>{@link LazyAssert}</code> assumption.78 *79 * @param <VALUE> type of the value contained in the {@link Lazy}.80 * @param actual the actual value.81 * @return the created assumption for assertion object.82 */83 @CheckReturnValue84 @SuppressWarnings("unchecked")85 public static <VALUE> LazyAssert<VALUE> assumeThat(Lazy<VALUE> actual) {86 return asAssumption(LazyAssert.class, Lazy.class, actual);87 }88 /**89 * Creates a new instance of <code>{@link MapAssert}</code> assumption.90 *91 * @param <K> the type of keys in the map.92 * @param <V> the type of values in the map.93 * @param actual the actual value.94 * @return the created assumption for assertion object.95 */96 @CheckReturnValue97 @SuppressWarnings("unchecked")98 public static <K, V> MapAssert<K, V> assumeThat(Map<K, V> actual) {99 return asAssumption(MapAssert.class, Map.class, actual);100 }101 /**102 * Creates a new instance of <code>{@link MultimapAssert}</code> assumption.103 *104 * @param <K> the type of keys in the multimap.105 * @param <V> the type of values in the multimap.106 * @param actual the actual value.107 * @return the created assumption for assertion object.108 */109 @CheckReturnValue110 @SuppressWarnings("unchecked")111 public static <K, V> MultimapAssert<K, V> assumeThat(Multimap<K, V> actual) {112 return asAssumption(MultimapAssert.class, Multimap.class, actual);113 }114 /**115 * Creates a new instance of <code>{@link OptionAssert}</code> assumption.116 *117 * @param <VALUE> type of the value contained in the {@link Option}.118 * @param actual the actual value.119 * @return the created assumption for assertion object.120 */121 @CheckReturnValue122 @SuppressWarnings("unchecked")123 public static <VALUE> OptionAssert<VALUE> assumeThat(Option<VALUE> actual) {124 return asAssumption(OptionAssert.class, Option.class, actual);125 }126 /**127 * Creates a new instance of <code>{@link SetAssert}</code> assumption.128 *129 * @param <ELEMENT> type of elements contained in the {@link Set}.130 * @param actual the actual value.131 * @return the created assumption for assertion object.132 */133 @CheckReturnValue134 @SuppressWarnings("unchecked")135 public static <ELEMENT> SetAssert<ELEMENT> assumeThat(Set<ELEMENT> actual) {136 return asAssumption(SetAssert.class, Set.class, actual);137 }138 /**139 * Creates a new instance of <code>{@link SeqAssert}</code> assumption.140 *141 * @param <ELEMENT> type of elements contained in the {@link Seq}.142 * @param actual the actual value.143 * @return the created assumption for assertion object.144 */145 @CheckReturnValue146 @SuppressWarnings("unchecked")147 public static <ELEMENT> SeqAssert<ELEMENT> assumeThat(Seq<ELEMENT> actual) {148 return asAssumption(SeqAssert.class, Seq.class, actual);149 }150 /**151 * Creates a new instance of <code>{@link TryAssert}</code> assumption.152 *153 * @param <VALUE> type of the value contained in the {@link io.vavr.control.Try}.154 * @param actual the actual value.155 * @return the created assumption for assertion object.156 */157 @CheckReturnValue158 @SuppressWarnings("unchecked")159 public static <VALUE> TryAssert<VALUE> assumeThat(Try<VALUE> actual) {160 return asAssumption(TryAssert.class, Try.class, actual);161 }162 /**163 * Creates a new instance of <code>{@link ValidationAssert}</code> assumption.164 *165 * @param <INVALID> type of the value in the case of the invalid {@link Validation}.166 * @param <VALID> type of the value in the case of the valid {@link Validation}.167 * @param actual the actual value.168 * @return the created assumption for assertion object.169 */170 @CheckReturnValue171 @SuppressWarnings("unchecked")172 public static <INVALID, VALID> ValidationAssert<INVALID, VALID> assumeThat(Validation<INVALID, VALID> actual) {173 return asAssumption(ValidationAssert.class, Validation.class, actual);174 }175 private static <ASSERTION, ACTUAL> ASSERTION asAssumption(Class<ASSERTION> assertionType,176 Class<ACTUAL> actualType,177 Object actual) {178 return asAssumption(assertionType, array(actualType), array(actual));179 }180 private static <ASSERTION> ASSERTION asAssumption(Class<ASSERTION> assertionType,181 Class<?>[] constructorTypes,182 Object... constructorParams) {183 try {184 Class<? extends ASSERTION> type = createAssumptionClass(assertionType);185 Constructor<? extends ASSERTION> constructor = type.getConstructor(constructorTypes);186 return constructor.newInstance(constructorParams);187 } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {188 throw new RuntimeException("Cannot create assumption instance", e);189 }190 }191 @SuppressWarnings("unchecked")192 private static <ASSERTION> Class<? extends ASSERTION> createAssumptionClass(Class<ASSERTION> assertClass) {193 TypeCache.SimpleKey cacheKey = new TypeCache.SimpleKey(assertClass);194 return (Class<ASSERTION>) CACHE.findOrInsert(VavrAssumptions.class.getClassLoader(),195 cacheKey,196 () -> generateAssumptionClass(assertClass));197 }198 private static <ASSERTION> Class<? extends ASSERTION> generateAssumptionClass(Class<ASSERTION> assertionType) {199 return BYTE_BUDDY.subclass(assertionType)200 .method(any())201 .intercept(ASSUMPTION)202 .make()203 .load(VavrAssumptions.class.getClassLoader(), classLoadingStrategy(assertionType))204 .getLoaded();205 }206 private static RuntimeException assumptionNotMet(AssertionError assertionError) throws ReflectiveOperationException {207 Class<?> assumptionClass = getAssumptionClass("org.junit.AssumptionViolatedException");208 if (assumptionClass != null) return assumptionNotMet(assumptionClass, assertionError);209 assumptionClass = getAssumptionClass("org.opentest4j.TestAbortedException");210 if (assumptionClass != null) return assumptionNotMet(assumptionClass, assertionError);211 assumptionClass = getAssumptionClass("org.testng.SkipException");212 if (assumptionClass != null) return assumptionNotMet(assumptionClass, assertionError);213 throw new IllegalStateException("Assumptions require JUnit, opentest4j or TestNG on the classpath");214 }215 private static Class<?> getAssumptionClass(String className) {216 try {217 return Class.forName(className);218 } catch (ClassNotFoundException e) {219 return null;220 }221 }222 private static RuntimeException assumptionNotMet(Class<?> exceptionClass,223 AssertionError e) throws ReflectiveOperationException {224 return (RuntimeException) exceptionClass.getConstructor(String.class, Throwable.class)225 .newInstance("assumption was not met due to: " + e.getMessage(), e);226 }227 // for method that change the object under test (e.g. extracting)228 private static AbstractVavrAssert<?, ?> asAssumption(AbstractVavrAssert<?, ?> assertion) {229 // @format:off230 Object actual = assertion.actual();231 if (assertion instanceof LazyAssert) return asAssumption(LazyAssert.class, Lazy.class, actual);232 if (assertion instanceof EitherAssert) return asAssumption(EitherAssert.class, Either.class, actual);233 if (assertion instanceof MapAssert) return asAssumption(MapAssert.class, Map.class, actual);234 if (assertion instanceof OptionAssert) return asAssumption(OptionAssert.class, Option.class, actual);235 if (assertion instanceof SeqAssert) return asAssumption(SeqAssert.class, Seq.class, actual);236 if (assertion instanceof TryAssert) return asAssumption(TryAssert.class, Try.class, actual);237 if (assertion instanceof ValidationAssert) return asAssumption(ValidationAssert.class, Validation.class, actual);238 // @format:on239 // should not arrive here240 throw new IllegalArgumentException("Unsupported assumption creation for " + assertion.getClass());241 }242}...

Full Screen

Full Screen

asAssumption

Using AI Code Generation

copy

Full Screen

1import org.junit.jupiter.api.Test;2import org.junit.jupiter.api.extension.ExtendWith;3import org.junit.jupiter.api.extension.RegisterExtension;4import org.junit.jupiter.api.parallel.Execution;5import org.junit.jupiter.api.parallel.ExecutionMode;6import org.junit.jupiter.api.parallel.ResourceAccessMode;7import org.junit.jupiter.api.parallel.ResourceLock;8import org.junit.jupiter.api.parallel.Resources;9import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;10import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;11import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;12import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;13import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;14import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;15import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;16import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;17import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;18import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;19import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;20import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;21import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;22import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;23import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;24import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;25import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;26import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;27import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;28import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;29import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;30import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;31import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;32import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;33import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;34import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;35import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;36import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;37import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;38import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;39import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;40import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;41import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;42import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;43import org.junit.jupiter.api.parallel.ResourceAccessMode.READ;44import org.junit.jupiter.api.parallel.ResourceAccessMode.WRITE;45import org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;46import org.junit.jupiter.api.parallel.ResourceAccess

Full Screen

Full Screen

asAssumption

Using AI Code Generation

copy

Full Screen

1import org.assertj.core.api.Assumptions;2import org.junit.jupiter.api.Test;3public class AssumptionTest {4 public void assumptionTest() {5 Assumptions.assumeThat(true).isTrue();6 System.out.println("This will be printed");7 }8}

Full Screen

Full Screen

asAssumption

Using AI Code Generation

copy

Full Screen

1import org.junit.Test;2import static org.assertj.core.api.Assertions.*;3import static org.assertj.core.api.Assumptions.*;4public class AssumptionTest {5 public void testAssumption() {6 String str = "abc";7 assumeThat(str).contains("a");8 assertThat(str).contains("a");9 }10}

Full Screen

Full Screen

asAssumption

Using AI Code Generation

copy

Full Screen

1package org.assertj.core.api;2public class Assumptions {3public static <T> T assumeThat(T actual) {4return actual;5}6}7package org.assertj.core.api;8public class Assertions {9public static <T> T assertThat(T actual) {10return actual;11}12}13package org.assertj.core.api;14public class BDDAssumptions {15public static <T> T given(T actual) {16return actual;17}18}19package org.assertj.core.api;20public class BDDAssertions {21public static <T> T then(T actual) {22return actual;23}24}25package org.assertj.core.api;26public class SoftAssertions {27public static <T> T softly(T actual) {28return actual;29}30}31package org.assertj.core.api;32public class WithAssertions {33public static <T> T assertThat(T actual) {34return actual;35}36}37package org.assertj.core.api;38public class WithAssumptions {39public static <T> T assumeThat(T actual) {40return actual;41}42}43package org.assertj.core.api;44public class WithBDDAssumptions {45public static <T> T given(T actual) {46return actual;47}48}49package org.assertj.core.api;50public class WithBDDSoftAssertions {51public static <T> T softly(T actual) {52return actual;53}54}55package org.assertj.core.api;56public class WithBDDSoftAssertions {57public static <T> T then(T actual) {58return actual;59}60}61package org.assertj.core.api;62public class WithBDDSoftAssertions {63public static <T> T softly(T actual) {64return actual;65}66}67package org.assertj.core.api;68public class WithBDDSoftAssertions {69public static <T> T softly(T actual) {70return actual;71}72}73package org.assertj.core.api;74public class WithBDDSoftAssertions {75public static <T> T softly(T actual) {76return actual;77}78}79package org.assertj.core.api;80public class WithBDDSoftAssertions {81public static <T> T softly(T actual) {82return actual;83}

Full Screen

Full Screen

asAssumption

Using AI Code Generation

copy

Full Screen

1package org.kodejava.example.assertj;2import org.assertj.core.api.Assumptions;3public class AssumptionsExample {4 public static void main(String[] args) {5 Assumptions.assumeThat(1 == 2).isTrue();6 System.out.println("This will not be printed.");7 }8}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful