Best Assertj code snippet using org.assertj.core.test.TestData.TestData
Source:Assumptions_assumeThat_with_extracting_and_narrowing_value_Test.java
...157import java.util.stream.Stream;158import org.assertj.core.util.Lists;159import org.junit.jupiter.api.Test;160class Assumptions_assumeThat_with_extracting_and_narrowing_value_Test {161 private TestData data = new TestData();162 @Test163 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_array() {164 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::array, as(ARRAY)).isNull());165 }166 @Test167 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_array2d() {168 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::array2D, as(ARRAY_2D)).isNull());169 }170 @Test171 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicBoolean() {172 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicBoolean, as(ATOMIC_BOOLEAN)).isNull());173 }174 @Test175 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicInteger() {176 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicInteger, as(ATOMIC_INTEGER)).isNull());177 }178 @Test179 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicIntegerArray() {180 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicIntegerArray, as(ATOMIC_INTEGER_ARRAY))181 .isNull());182 }183 @Test184 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicIntegerFieldUpdater() {185 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicIntegerFieldUpdater,186 as(ATOMIC_INTEGER_FIELD_UPDATER))187 .isNull());188 }189 @Test190 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicLong() {191 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicLong, as(ATOMIC_LONG)).isNull());192 }193 @Test194 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicLongArray() {195 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicLongArray, as(ATOMIC_LONG_ARRAY))196 .isNull());197 }198 @Test199 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicLongFieldUpdater() {200 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicLongFieldUpdater,201 as(ATOMIC_LONG_FIELD_UPDATER))202 .isNull());203 }204 @Test205 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicMarkableReference() {206 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicMarkableReference,207 as(ATOMIC_MARKABLE_REFERENCE))208 .isNull());209 }210 @Test211 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicReference() {212 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicReference, as(ATOMIC_REFERENCE))213 .isNull());214 }215 @Test216 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicReferenceArray() {217 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicReferenceArray, as(ATOMIC_REFERENCE_ARRAY))218 .isNull());219 }220 @Test221 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicReferenceFieldUpdater() {222 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicReferenceFieldUpdater,223 as(ATOMIC_REFERENCE_FIELD_UPDATER))224 .isNull());225 }226 @Test227 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_AtomicStampedReference() {228 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::atomicStampedReference,229 as(ATOMIC_STAMPED_REFERENCE))230 .isNull());231 }232 // https://github.com/assertj/assertj-core/issues/2349233 @Test234 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_BigDecimal() {235 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::bigDecimal, as(BIG_DECIMAL)).isZero());236 }237 @Test238 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_BigInteger() {239 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::bigInteger, as(BIG_INTEGER)).isZero());240 }241 @Test242 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_boolean() {243 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::booleanPrimitive, as(BOOLEAN)).isFalse());244 }245 @Test246 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Boolean() {247 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getBoolean, as(BOOLEAN)).isFalse());248 }249 @Test250 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Boolean2DArray() {251 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::boolean2DArray, as(BOOLEAN_2D_ARRAY))252 .isNotEmpty());253 }254 @Test255 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_BooleanArray() {256 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::booleanArray, as(BOOLEAN_ARRAY)).isNotEmpty());257 }258 @Test259 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_byte() {260 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::bytePrimitive, as(BYTE)).isZero());261 }262 @Test263 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Byte() {264 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getByte, as(BYTE)).isZero());265 }266 @Test267 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Byte2DArray() {268 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::byte2DArray, as(BYTE_2D_ARRAY))269 .isNotEmpty());270 }271 @Test272 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_ByteArray() {273 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::byteArray, as(BYTE_ARRAY)).isNotEmpty());274 }275 @Test276 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_char() {277 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getChar, as(CHARACTER)).isNull());278 }279 @Test280 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Character() {281 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::character, as(CHARACTER)).isNull());282 }283 @Test284 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Char2DArray() {285 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::char2DArray, as(CHAR_2D_ARRAY)).isNotEmpty());286 }287 @Test288 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_CharArray() {289 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::charArray, as(CHAR_ARRAY)).isNotEmpty());290 }291 @Test292 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_CharSequence() {293 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::charSequence, as(CHAR_SEQUENCE)).isBlank());294 }295 @Test296 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Class() {297 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getClass, as(CLASS)).isFinal());298 }299 @Test300 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Collection() {301 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::collection, as(COLLECTION)).isNotEmpty());302 }303 @Test304 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_CompletableFuture() {305 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::completableFuture, as(COMPLETABLE_FUTURE))306 .isNull());307 }308 @Test309 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Future() {310 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::future, as(FUTURE)).isNull());311 }312 @Test313 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_CompletionStage() {314 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::completionStage, as(COMPLETION_STAGE))315 .isNull());316 }317 @Test318 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Date() {319 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::date, as(DATE)).isInTheFuture());320 }321 @Test322 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Double() {323 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getDouble, as(DOUBLE)).isNegative());324 }325 @Test326 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_double() {327 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::doublePrimitive, as(DOUBLE)).isNegative());328 }329 @Test330 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Double2DArray() {331 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::double2DArray, as(DOUBLE_2D_ARRAY))332 .isNotEmpty());333 }334 @Test335 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_DoubleArray() {336 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::doubleArray, as(DOUBLE_ARRAY)).isNotEmpty());337 }338 @Test339 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_DoublePredicate() {340 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::doublePredicate, as(DOUBLE_PREDICATE))341 .accepts(1));342 }343 @Test344 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_DoubleStream() {345 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::doubleStream, as(DOUBLE_STREAM))346 .isSorted());347 }348 @Test349 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Duration() {350 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::duration, as(DURATION)).isNegative());351 }352 @Test353 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_File() {354 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::file, as(FILE)).isDirectory());355 }356 @Test357 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Float() {358 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getFloat, as(FLOAT)).isNegative());359 }360 @Test361 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_float() {362 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::floatPrimitive, as(FLOAT)).isNegative());363 }364 @Test365 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Float2DArray() {366 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::float2DArray, as(FLOAT_2D_ARRAY)).isNotEmpty());367 }368 @Test369 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_FloatArray() {370 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::floatArray, as(FLOAT_ARRAY)).isNotEmpty());371 }372 @Test373 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_InputStream() {374 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::inputStream, as(INPUT_STREAM)).hasContent("foo"));375 }376 @Test377 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_Instant() {378 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::instant, as(INSTANT)).isAfter(Instant.MAX));379 }380 @Test381 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_int() {382 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getInt, as(INTEGER)).isNegative());383 }384 @Test385 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_Integer() {386 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::integer, as(INTEGER)).isNegative());387 }388 @Test389 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Integer2DArray() {390 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::int2DArray, as(INT_2D_ARRAY))391 .isNotEmpty());392 }393 @Test394 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_int_array() {395 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::intArray, as(INT_ARRAY)).isNotEmpty());396 }397 @Test398 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_IntegerPredicate() {399 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::intPredicate, as(INT_PREDICATE)).accepts(1));400 }401 @Test402 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_IntegerStream() {403 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::intStream, as(INT_STREAM)).isSorted());404 }405 @Test406 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_iterable() {407 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::iterable, as(ITERABLE)).isNotEmpty());408 }409 @Test410 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_iterator() {411 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::iterator, as(ITERATOR)).hasNext());412 }413 @Test414 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_list() {415 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::list, as(LIST)).isNotEmpty());416 }417 @Test418 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_list_of_String() {419 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::stringList, as(list(String.class))).isEmpty());420 }421 @Test422 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_localDate() {423 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::localDate, as(LOCAL_DATE))424 .isAfter(LocalDate.MAX));425 }426 @Test427 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_localDateTime() {428 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::localDateTime, as(LOCAL_DATE_TIME))429 .isAfter(LocalDateTime.MAX));430 }431 @Test432 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_localTime() {433 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::localTime, as(LOCAL_TIME))434 .isAfter(LocalTime.MAX));435 }436 @Test437 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_long() {438 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::longPrimitive, as(LONG)).isNegative());439 }440 @Test441 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Long() {442 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getLong, as(LONG)).isNegative());443 }444 @Test445 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Long2DArray() {446 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::long2DArray, as(LONG_2D_ARRAY))447 .isNotEmpty());448 }449 @Test450 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_LongAdder() {451 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::longAdder, as(LONG_ADDER)).isNull());452 }453 @Test454 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_LongArray() {455 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::longArray, as(LONG_ARRAY)).isNotEmpty());456 }457 @Test458 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_LongPredicate() {459 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::longPredicate, as(LONG_PREDICATE)).accepts(1));460 }461 @Test462 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_LongStream() {463 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::longStream, as(LONG_STREAM)).isSorted());464 }465 @Test466 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Map() {467 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::map, as(MAP)).isNotEmpty());468 }469 @Test470 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_offsetDateTime() {471 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::offsetDateTime, as(OFFSET_DATE_TIME))472 .isAfter(OffsetDateTime.MAX));473 }474 @Test475 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_offsetTime() {476 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::offsetTime, as(OFFSET_TIME))477 .isAfter(OffsetTime.MAX));478 }479 @Test480 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_optional() {481 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::optional, as(OPTIONAL)).isNotEmpty());482 }483 @Test484 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_optionalDouble() {485 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::optionalDouble, as(OPTIONAL_DOUBLE))486 .isNotEmpty());487 }488 @Test489 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_optionalInt() {490 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::optionalInt, as(OPTIONAL_INT)).isNotEmpty());491 }492 @Test493 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_an_optionalLong() {494 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::optionalLong, as(OPTIONAL_LONG)).isNotEmpty());495 }496 @Test497 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_path() {498 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::path, as(PATH)).isDirectory());499 }500 @Test501 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_period() {502 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::period, as(PERIOD)).hasYears(2000));503 }504 @Test505 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_predicate() {506 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::predicate, as(PREDICATE)).accepts(123));507 }508 @Test509 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_short() {510 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::shortPrimitive, as(SHORT)).isNegative());511 }512 @Test513 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Short() {514 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getShort, as(SHORT)).isNegative());515 }516 @Test517 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Short2DArray() {518 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::short2DArray, as(SHORT_2D_ARRAY)).isNotEmpty());519 }520 @Test521 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_ShortArray() {522 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::shortArray, as(SHORT_ARRAY)).isNotEmpty());523 }524 @Test525 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Spliterator() {526 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::spliterator, as(SPLITERATOR)).isNull());527 }528 @Test529 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Stream() {530 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::stream, as(STREAM)).isEmpty());531 }532 @Test533 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_String() {534 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::getString, as(STRING)).isBlank());535 }536 @Test537 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_StringBuffer() {538 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::stringBuffer, as(STRING_BUFFER)).isBlank());539 }540 @Test541 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_StringBuilder() {542 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::stringBuilder, as(STRING_BUILDER)).isBlank());543 }544 @Test545 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_Throwable() {546 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::throwable, as(THROWABLE)).hasMessage("foo"));547 }548 @Test549 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_URI() {550 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::uri, as(URI_TYPE)).hasHost("google"));551 }552 @Test553 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_URL() {554 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::url, as(URL_TYPE)).hasHost("google"));555 }556 @Test557 void should_ignore_test_for_failing_assumption_extracting_and_narrowing_a_ZonedDateTime() {558 expectAssumptionNotMetException(() -> assumeThat(data).extracting(TestData::zonedDateTime, as(ZONED_DATE_TIME))559 .isAfter(ZonedDateTime.now()));560 }561 static class TestData {562 volatile int foo;563 volatile long fooLong;564 volatile TestData fooTestData;565 Object[] array() {566 return new Object[0];567 }568 Object[][] array2D() {569 return new Object[0][0];570 }571 AtomicBoolean atomicBoolean() {572 return new AtomicBoolean(true);573 }574 AtomicInteger atomicInteger() {575 return new AtomicInteger(1);576 }577 AtomicIntegerArray atomicIntegerArray() {578 return new AtomicIntegerArray(0);579 }580 AtomicIntegerFieldUpdater<?> atomicIntegerFieldUpdater() {581 return AtomicIntegerFieldUpdater.newUpdater(TestData.class, "foo");582 }583 AtomicLong atomicLong() {584 return new AtomicLong(1);585 }586 AtomicLongArray atomicLongArray() {587 return new AtomicLongArray(0);588 }589 AtomicLongFieldUpdater<?> atomicLongFieldUpdater() {590 return AtomicLongFieldUpdater.newUpdater(TestData.class, "fooLong");591 }592 AtomicMarkableReference<?> atomicMarkableReference() {593 return new AtomicMarkableReference<>("foo", true);594 }595 AtomicReference<?> atomicReference() {596 return new AtomicReference<>(1);597 }598 AtomicReferenceArray<?> atomicReferenceArray() {599 return new AtomicReferenceArray<>(0);600 }601 AtomicReferenceFieldUpdater<?, ?> atomicReferenceFieldUpdater() {602 return AtomicReferenceFieldUpdater.newUpdater(TestData.class, TestData.class, "fooTestData");603 }604 AtomicStampedReference<?> atomicStampedReference() {605 return new AtomicStampedReference<>("foo", 1);606 }607 BigDecimal bigDecimal() {608 return BigDecimal.ONE;609 }610 BigInteger bigInteger() {611 return BigInteger.ONE;612 }613 boolean booleanPrimitive() {614 return Boolean.TRUE;615 }616 Boolean getBoolean() {...
Source:Iterables_assertContainsAnyOf_Test.java
...16import org.assertj.core.error.ShouldContainAnyOf;17import org.assertj.core.internal.ErrorMessages;18import org.assertj.core.internal.IterablesBaseTest;19import org.assertj.core.test.Name;20import org.assertj.core.test.TestData;21import org.assertj.core.test.TestFailures;22import org.assertj.core.util.Arrays;23import org.assertj.core.util.FailureMessages;24import org.assertj.core.util.Lists;25import org.junit.jupiter.api.Test;26import org.mockito.Mockito;27import static java.util.Arrays.asList;28/**29 * Tests for <code>{@link Iterables#assertContainsAnyOf(AssertionInfo, Iterable, Object[])} </code>.30 *31 * @author Marko Bekhta32 */33public class Iterables_assertContainsAnyOf_Test extends IterablesBaseTest {34 @Test35 public void should_pass_if_actual_contains_given_values() {36 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("Luke"));37 }38 @Test39 public void should_pass_with_non_comparable_values() {40 // GIVEN41 Iterable<Name> names = asList(Name.name("John", "Doe"));42 // THEN43 iterables.assertContainsAnyOf(TestData.someInfo(), names, Arrays.array(Name.name("John", "Doe"), Name.name("Jane", "Doe")));44 }45 @Test46 public void should_pass_if_actual_contains_given_values_in_different_order() {47 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("Leia", "Yoda"));48 }49 @Test50 public void should_pass_if_actual_contains_all_given_values() {51 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("Luke", "Yoda", "Leia"));52 }53 @Test54 public void should_pass_if_actual_contains_given_values_more_than_once() {55 actual.addAll(Lists.newArrayList("Luke", "Luke"));56 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("Luke"));57 }58 @Test59 public void should_pass_if_actual_contains_just_one_of_given_values() {60 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("Luke", "John", "Tom"));61 }62 @Test63 public void should_pass_if_actual_contains_given_values_even_if_duplicated() {64 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("Luke", "Luke"));65 }66 @Test67 public void should_pass_if_actual_and_given_values_are_empty() {68 actual.clear();69 iterables.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array());70 }71 @Test72 public void should_fail_if_array_of_values_to_look_for_is_empty_and_actual_is_not() {73 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> iterables.assertContainsAnyOf(someInfo(), actual, emptyArray()));74 }75 @Test76 public void should_throw_error_if_array_of_values_to_look_for_is_null() {77 Assertions.assertThatNullPointerException().isThrownBy(() -> iterables.assertContainsAnyOf(someInfo(), actual, null)).withMessage(ErrorMessages.valuesToLookForIsNull());78 }79 @Test80 public void should_fail_if_actual_is_null() {81 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> iterables.assertContainsAnyOf(someInfo(), null, array("Yoda"))).withMessage(FailureMessages.actualIsNull());82 }83 @Test84 public void should_fail_if_actual_does_not_contain_any_of_the_given_values() {85 AssertionInfo info = TestData.someInfo();86 Object[] expected = new Object[]{ "Han", "John" };87 try {88 iterables.assertContainsAnyOf(info, actual, expected);89 } catch (AssertionError e) {90 Mockito.verify(failures).failure(info, ShouldContainAnyOf.shouldContainAnyOf(actual, expected));91 return;92 }93 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();94 }95 // ------------------------------------------------------------------------------------------------------------------96 // tests using a custom comparison strategy97 // ------------------------------------------------------------------------------------------------------------------98 @Test99 public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() {100 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("LUKE"));101 }102 @Test103 public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() {104 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("LEIA", "yODa"));105 }106 @Test107 public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() {108 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("luke", "YODA", "leia"));109 }110 @Test111 public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() {112 actual.addAll(Lists.newArrayList("Luke", "Luke"));113 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("LUke"));114 }115 @Test116 public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() {117 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("LUke", "LuKe"));118 }119 @Test120 public void should_pass_if_actual_contains_just_one_of_given_values_according_to_custom_comparison_strategy() {121 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(TestData.someInfo(), actual, Arrays.array("LuKe", "JoHn", "ToM"));122 }123 @Test124 public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() {125 AssertionInfo info = TestData.someInfo();126 Object[] expected = new Object[]{ "Han", "John" };127 try {128 iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAnyOf(info, actual, expected);129 } catch (AssertionError e) {130 Mockito.verify(failures).failure(info, ShouldContainAnyOf.shouldContainAnyOf(actual, expected, comparisonStrategy));131 return;132 }133 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();134 }135}...
Source:Iterables_assertContains_Test.java
...15import org.assertj.core.api.Assertions;16import org.assertj.core.error.ShouldContain;17import org.assertj.core.internal.ErrorMessages;18import org.assertj.core.internal.IterablesBaseTest;19import org.assertj.core.test.TestData;20import org.assertj.core.test.TestFailures;21import org.assertj.core.util.Arrays;22import org.assertj.core.util.FailureMessages;23import org.assertj.core.util.Lists;24import org.assertj.core.util.Sets;25import org.junit.jupiter.api.Test;26import org.mockito.Mockito;27/**28 * Tests for <code>{@link Iterables#assertContains(AssertionInfo, Collection, Object[])}</code>.29 *30 * @author Alex Ruiz31 * @author Joel Costigliola32 */33public class Iterables_assertContains_Test extends IterablesBaseTest {34 @Test35 public void should_pass_if_actual_contains_given_values() {36 iterables.assertContains(TestData.someInfo(), actual, Arrays.array("Luke"));37 }38 @Test39 public void should_pass_if_actual_contains_given_values_in_different_order() {40 iterables.assertContains(TestData.someInfo(), actual, Arrays.array("Leia", "Yoda"));41 }42 @Test43 public void should_pass_if_actual_contains_all_given_values() {44 iterables.assertContains(TestData.someInfo(), actual, Arrays.array("Luke", "Yoda"));45 }46 @Test47 public void should_pass_if_actual_contains_given_values_more_than_once() {48 actual.addAll(Lists.newArrayList("Luke", "Luke"));49 iterables.assertContains(TestData.someInfo(), actual, Arrays.array("Luke"));50 }51 @Test52 public void should_pass_if_actual_contains_given_values_even_if_duplicated() {53 iterables.assertContains(TestData.someInfo(), actual, Arrays.array("Luke", "Luke"));54 }55 @Test56 public void should_pass_if_actual_and_given_values_are_empty() {57 actual.clear();58 iterables.assertContains(TestData.someInfo(), actual, Arrays.array());59 }60 @Test61 public void should_fail_if_array_of_values_to_look_for_is_empty_and_actual_is_not() {62 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> iterables.assertContains(someInfo(), actual, emptyArray()));63 }64 @Test65 public void should_throw_error_if_array_of_values_to_look_for_is_null() {66 Assertions.assertThatNullPointerException().isThrownBy(() -> iterables.assertContains(someInfo(), actual, null)).withMessage(ErrorMessages.valuesToLookForIsNull());67 }68 @Test69 public void should_fail_if_actual_is_null() {70 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> iterables.assertContains(someInfo(), null, array("Yoda"))).withMessage(FailureMessages.actualIsNull());71 }72 @Test73 public void should_fail_if_actual_does_not_contain_values() {74 AssertionInfo info = TestData.someInfo();75 Object[] expected = new Object[]{ "Han", "Luke" };76 try {77 iterables.assertContains(info, actual, expected);78 } catch (AssertionError e) {79 Mockito.verify(failures).failure(info, ShouldContain.shouldContain(actual, expected, Sets.newLinkedHashSet("Han")));80 return;81 }82 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();83 }84 // ------------------------------------------------------------------------------------------------------------------85 // tests using a custom comparison strategy86 // ------------------------------------------------------------------------------------------------------------------87 @Test88 public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() {89 iterablesWithCaseInsensitiveComparisonStrategy.assertContains(TestData.someInfo(), actual, Arrays.array("LUKE"));90 }91 @Test92 public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() {93 iterablesWithCaseInsensitiveComparisonStrategy.assertContains(TestData.someInfo(), actual, Arrays.array("LEIA", "yODa"));94 }95 @Test96 public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() {97 iterablesWithCaseInsensitiveComparisonStrategy.assertContains(TestData.someInfo(), actual, Arrays.array("luke", "YODA"));98 }99 @Test100 public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() {101 actual.addAll(Lists.newArrayList("Luke", "Luke"));102 iterablesWithCaseInsensitiveComparisonStrategy.assertContains(TestData.someInfo(), actual, Arrays.array("LUke"));103 }104 @Test105 public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() {106 iterablesWithCaseInsensitiveComparisonStrategy.assertContains(TestData.someInfo(), actual, Arrays.array("LUke", "LuKe"));107 }108 @Test109 public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() {110 AssertionInfo info = TestData.someInfo();111 Object[] expected = new Object[]{ "Han", "Luke" };112 try {113 iterablesWithCaseInsensitiveComparisonStrategy.assertContains(info, actual, expected);114 } catch (AssertionError e) {115 Mockito.verify(failures).failure(info, ShouldContain.shouldContain(actual, expected, Sets.newLinkedHashSet("Han"), comparisonStrategy));116 return;117 }118 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();119 }120}...
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2import org.junit.Test;3import static org.assertj.core.api.Assertions.assertThat;4public class Test1 {5 public void test1() {6 assertThat(TestData.someInfo()).isNotNull();7 }8}9import org.assertj.core.test.TestData;10import org.junit.Test;11import static org.assertj.core.api.Assertions.assertThat;12public class Test2 {13 public void test2() {14 assertThat(TestData.someInfo()).isNotNull();15 }16}17import org.assertj.core.test.TestData;18import org.junit.Test;19import static org.assertj.core.api.Assertions.assertThat;20public class Test3 {21 public void test3() {22 assertThat(TestData.someInfo()).isNotNull();23 }24}25import org.assertj.core.test.TestData;26import org.junit.Test;27import static org.assertj.core.api.Assertions.assertThat;28public class Test4 {29 public void test4() {30 assertThat(TestData.someInfo()).isNotNull();31 }32}33import org.assertj.core.test.TestData;34import org.junit.Test;35import static org.assertj.core.api.Assertions.assertThat;36public class Test5 {37 public void test5() {38 assertThat(TestData.someInfo()).isNotNull();39 }40}41import org.assertj.core.test.TestData;42import org.junit.Test;43import static org.assertj.core.api.Assertions.assertThat;44public class Test6 {45 public void test6() {46 assertThat(TestData.someInfo()).isNotNull();47 }48}49import org.assertj.core.test.TestData;50import org.junit.Test;51import static org.assertj.core.api.Assertions.assertThat;52public class Test7 {53 public void test7() {54 assertThat(TestData.someInfo()).isNotNull();55 }56}
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2import org.junit.Test;3import static org.assertj.core.api.Assertions.assertThat;4public class Test1 {5 public void test1() {6 assertThat(TestData.someInfo()).isNotNull();7 }8}9import org.assertj.core.test.TestData;10import org.junit.Test;11import static org.assertj.core.api.Assertions.assertThat;12public class Test2 {13 public void test2() {14 assertThat(TestData.someInfo()).isNotNull();15 }16}
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2import org.assertj.core.api.Assertions;3import org.assertj.core.api.AbstractAssert;4import org.assertj.core.api.AbstractCharSequenceAssert;5import org.assertj.core.api.AbstractObjectArrayAssert;6import org.assertj.core.api.AbstractListAssert;7import org.assertj.core.api.AbstractObjectAssert;8import org.assertj.core.api.AbstractIntegerAssert;9import org.assertj.core.api.AbstractLongAssert;10import org.assertj.core.api.AbstractDoubleAssert;11import org.assertj.core.api.AbstractFloatAssert;12import org.assertj.core.api.AbstractShortAssert;13import org.assertj.core.api.AbstractByteAssert;14import org.assertj.core.api.AbstractBooleanAssert;15import org.assertj.core.api.AbstractCharacterAssert;16import org.assertj.core.api.AbstractDateAssert;17import org.assertj.core.api.AbstractInstantAssert;18import org.assertj.core.api.AbstractLocalDateAssert;19import org.assertj.core.api.AbstractLocalDateTimeAssert;20import org.assertj.core.api.AbstractLocalTimeAssert;21import org.assertj.core.api.AbstractOffsetDateTimeAssert;22import org.assertj.core.api.AbstractOffsetTimeAssert;23import org.assertj.core.api.AbstractZonedDateTimeAssert;24import org.assertj.core.api.AbstractDurationAssert;25import org.assertj.core.api.AbstractPeriodAssert;26import org.assertj.core.api.AbstractPathAssert;27import org.assertj.core.api.AbstractFileAssert;28import org.assertj.core.api.AbstractComparableAssert;29import org.assertj.core.api.AbstractThrowableAssert;
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2import org.assertj.core.api.*;3public class 1 {4 public static void main(String[] args) {5 System.out.println(TestData.someInfo());6 }7}8import org.assertj.core.test.TestData;9import org.assertj.core.api.*;10public class 2 {11 public static void main(String[] args) {12 System.out.println(TestData.someInfo().toString());13 }14}15import org.assertj.core.test.TestData;16import org.assertj.core.api.*;17public class 3 {18 public static void main(String[] args) {19 System.out.println(TestData.someInfo().toString().getClass());20 }21}22import org.assertj.core.test.TestData;23import org.assertj.core.api.*;24public class 4 {25 public static void main(String[] args) {26 System.out.println(TestData.someInfo().toString().getClass().getName());27 }28}29import org.assertj.core.test.TestData;30import org.assertj.core.api.*;31public class 5 {32 public static void main(String[] args) {33 System.out.println(TestData.someInfo().toString().getClass().getSimpleName());34 }35}36import org.assertj.core.test.TestData;37import org.assertj.core.api.*;38public class 6 {39 public static void main(String[] args) {
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2public class AssertJCoreTestData {3 public static void main(String[] args) {4 System.out.println(TestData.someInfo().toString());5 }6}
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2import org.assertj.core.util.*;3import org.junit.*;4import org.junit.runner.*;5import org.junit.runners.*;6import static org.assertj.core.api.Assertions.*;7import static org.assertj.core.api.Assertions.assertThat;8import static org.assertj.core.api.Assertions.assertThatExceptionOfType;9import static org.assertj.core.api.Assertions.assertThatNullPointerException;10import
TestData
Using AI Code Generation
1import static org.assertj.core.test.TestData.someInfo;2import static org.assertj.core.api.Assertions.assertThat;3public class AssertJCoreTestDataExample {4 public static void main(String[] args) {5 assertThat(someInfo()).isEqualTo("Hello");6 }7}8import static org.assertj.core.test.TestData.someInfo;9import static org.assertj.core.api.Assertions.assertThat;10public class AssertJCoreTestDataExample {11 public static void main(String[] args) {12 assertThat(someInfo()).isEqualTo("Hello");13 }14}15import static org.assertj.core.test.TestData.someInfo;16import static org.assertj.core.api.Assertions.assertThat;17public class AssertJCoreTestDataExample {18 public static void main(String[] args) {19 assertThat(someInfo()).isEqualTo("Hello");20 }21}22import static org.assertj.core.test.TestData.someInfo;23import static org.assertj.core.api.Assertions.assertThat;24public class AssertJCoreTestDataExample {25 public static void main(String[] args) {26 assertThat(someInfo()).isEqualTo("Hello");27 }28}
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2import java.util.List;3import java.util.Collections;4import java.util.Arrays;5public class TestAssertJ {6 public static void main(String[] args) {7 List<String> list = Arrays.asList("a", "b", "c");8 System.out.println("List: " + list);9 List<String> copy = TestData.someInfo().list();10 System.out.println("Copy: " + copy);11 System.out.println("List == Copy: " + (list == copy));12 System.out.println("List.equals(Copy): " + list.equals(copy));13 }14}15List.equals(Copy): true16Your name to display (optional):17Your name to display (optional):18The asList() method is a static method of the Arrays class. It returns a fixed-size list backed by the specified array. The asList() method is overloaded, it can take the following arguments:19import java.util.Arrays;20import java.util.List;21public class TestArrays {22 public static void main(String[] args) {23 String[] array = {"a", "b", "c"};24 List<String> list = Arrays.asList(array);25 System.out.println("List: " + list);26 }27}28import java.util.Arrays;29import java.util.List;30public class TestArrays {31 public static void main(String[] args) {32 int[] array = {1, 2, 3};33 List<int[]> list = Arrays.asList(array);34 System.out.println("List: " + list);35 }36}
TestData
Using AI Code Generation
1import org.assertj.core.test.TestData;2public class TestDataTest {3 public static void main(String[] args) {4 System.out.println(TestData.someInfo());5 }6}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!