Best Assertj code snippet using org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.DefaultRecursiveAssertionIntrospectionStrategy
Source:RecursiveAssertionConfiguration.java
...142 }143 /**144 * Defines how objects are introspected in the recursive assertion.145 * <p>146 * Default to {@link DefaultRecursiveAssertionIntrospectionStrategy} that introspects all fields (including inherited ones).147 *148 * @param introspectionStrategy the {@link RecursiveAssertionIntrospectionStrategy} to use149 */150 public void setIntrospectionStrategy(RecursiveAssertionIntrospectionStrategy introspectionStrategy) {151 this.introspectionStrategy = introspectionStrategy;152 }153 @Override154 public String toString() {155 CONFIGURATION_PROVIDER.representation();156 StringBuilder description = new StringBuilder();157 describeIgnoreAllNullFields(description);158 describeIgnoredFields(description);159 describeIgnoredFieldsRegexes(description);160 describeIgnoredFieldsOfTypes(description);161 describeIgnorePrimitiveFields(description);162 describeSkipJCLTypeObjects(description);163 describeCollectionAssertionPolicy(description);164 describeMapAssertionPolicy(description);165 describeOptionalAssertionPolicy(description);166 describeIntrospectionStrategy(description);167 return description.toString();168 }169 boolean shouldIgnorePrimitiveFields() {170 return ignorePrimitiveFields;171 }172 boolean shouldSkipJavaLibraryTypeObjects() {173 return skipJavaLibraryTypeObjects;174 }175 CollectionAssertionPolicy getCollectionAssertionPolicy() {176 return collectionAssertionPolicy;177 }178 MapAssertionPolicy getMapAssertionPolicy() {179 return mapAssertionPolicy;180 }181 OptionalAssertionPolicy getOptionalAssertionPolicy() {182 return optionalAssertionPolicy;183 }184 RecursiveAssertionIntrospectionStrategy getIntrospectionStrategy() {185 return introspectionStrategy;186 }187 boolean shouldIgnoreMap() {188 return mapAssertionPolicy == MAP_VALUES_ONLY;189 }190 boolean shouldIgnoreOptional() {191 return optionalAssertionPolicy == OPTIONAL_VALUE_ONLY;192 }193 boolean shouldIgnoreContainer() {194 return collectionAssertionPolicy == ELEMENTS_ONLY;195 }196 boolean shouldIgnoreAllNullFields() {197 return this.ignoreAllNullFields;198 }199 private void describeIgnoreAllNullFields(StringBuilder description) {200 if (shouldIgnoreAllNullFields()) description.append(format("- all null fields were ignored in the assertion%n"));201 }202 private void describeIgnorePrimitiveFields(StringBuilder description) {203 if (shouldIgnorePrimitiveFields())204 description.append(format("- primitive fields were ignored in the recursive assertion%n"));205 }206 private void describeSkipJCLTypeObjects(StringBuilder description) {207 if (!shouldSkipJavaLibraryTypeObjects())208 description.append(format("- fields from Java Class Library types (java.* or javax.*) were included in the recursive assertion%n"));209 else210 description.append(format("- fields from Java Class Library types (java.* or javax.*) were excluded in the recursive assertion%n"));211 }212 private void describeCollectionAssertionPolicy(StringBuilder description) {213 description.append(format("- the collection assertion policy was %s%n", getCollectionAssertionPolicy().name()));214 }215 private void describeMapAssertionPolicy(StringBuilder description) {216 description.append(format("- the map assertion policy was %s%n", getMapAssertionPolicy().name()));217 }218 private void describeOptionalAssertionPolicy(StringBuilder description) {219 description.append(format("- the optional assertion policy was %s%n", getOptionalAssertionPolicy().name()));220 }221 private void describeIgnoredFieldsOfTypes(StringBuilder description) {222 if (!getIgnoredTypes().isEmpty())223 description.append(format("- the following types were ignored in the assertion: %s%n", describeIgnoredTypes()));224 }225 private void describeIntrospectionStrategy(StringBuilder description) {226 description.append(format("- the introspection strategy used was: %s%n", introspectionStrategy.getDescription()));227 }228 @Override229 public boolean equals(Object o) {230 if (this == o) return true;231 if (o == null || getClass() != o.getClass()) return false;232 RecursiveAssertionConfiguration that = (RecursiveAssertionConfiguration) o;233 return shouldIgnoreAllNullFields() == that.shouldIgnoreAllNullFields()234 && java.util.Objects.equals(getIgnoredFields(), that.getIgnoredFields())235 && java.util.Objects.equals(getIgnoredFieldsRegexes(), that.getIgnoredFieldsRegexes())236 && shouldIgnorePrimitiveFields() == that.shouldIgnorePrimitiveFields()237 && shouldSkipJavaLibraryTypeObjects() == that.shouldSkipJavaLibraryTypeObjects()238 && getCollectionAssertionPolicy() == that.getCollectionAssertionPolicy()239 && getOptionalAssertionPolicy() == that.getOptionalAssertionPolicy()240 && getMapAssertionPolicy() == that.getMapAssertionPolicy();241 }242 @Override243 public int hashCode() {244 return Objects.hash(shouldIgnoreAllNullFields(), getIgnoredFields(), getIgnoredFieldsRegexes(), getIgnoredTypes(),245 shouldIgnorePrimitiveFields(), shouldSkipJavaLibraryTypeObjects(), getCollectionAssertionPolicy(),246 getOptionalAssertionPolicy(), getMapAssertionPolicy());247 }248 /**249 * @return A {@link Builder} that will assist the developer in creating a valid instance of {@link RecursiveAssertionConfiguration}.250 */251 public static Builder builder() {252 return new Builder();253 }254 /**255 * Builder for {@link RecursiveAssertionConfiguration}256 *257 * @since 3.24.0258 */259 public static class Builder extends AbstractBuilder<Builder> {260 private boolean ignorePrimitiveFields = false;261 private boolean skipJavaLibraryTypeObjects = true;262 private CollectionAssertionPolicy collectionAssertionPolicy = ELEMENTS_ONLY;263 private MapAssertionPolicy mapAssertionPolicy = MAP_VALUES_ONLY;264 private OptionalAssertionPolicy optionalAssertionPolicy = OPTIONAL_VALUE_ONLY;265 private boolean ignoreAllNullFields;266 private RecursiveAssertionIntrospectionStrategy introspectionStrategy = new DefaultRecursiveAssertionIntrospectionStrategy();267 private Builder() {268 super(Builder.class);269 }270 /**271 * Makes the recursive assertion to ignore the specified fields in the object under test.272 * <p>273 * Example:274 * <pre><code class='java'> class Person {275 * String name;276 * String occupation;277 * int age;278 * Address address = new Address();279 * }280 *281 * class Address {282 * int number;283 * String street;284 * }285 *286 * Person sherlock = new Person("Sherlock", "Detective", 60);287 * sherlock.address.street = "Baker Street";288 * sherlock.address.number = 221;289 *290 * RecursiveAssertionConfiguration config = RecursiveAssertionConfiguration.builder()291 * .withIgnoredFields("address", "age")292 * .build();293 *294 * // assertion succeeds Person has only String fields except for address and age295 * assertThat(sherlock).usingRecursiveAssertion(config)296 * .allFieldsSatisfy(field -> field instanceof String);297 *298 * // assertion fails because of age, address and address.number fields299 * assertThat(sherlock).usingRecursiveComparison()300 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>301 *302 * @param fieldsToIgnore the fields to ignore in the object under test.303 * @return this builder.304 */305 @Override306 public Builder withIgnoredFields(String... fieldsToIgnore) {307 return super.withIgnoredFields(fieldsToIgnore);308 }309 /**310 * Makes the recursive assertion to ignore the fields matching the specified regexes in the object under test.311 * <p>312 * Example:313 * <pre><code class='java'> class Person {314 * String name;315 * String occupation;316 * int age;317 * Address address = new Address();318 * }319 *320 * class Address {321 * int number;322 * String street;323 * }324 *325 * Person sherlock = new Person("Sherlock", "Detective", 60);326 * sherlock.address.street = "Baker Street";327 * sherlock.address.number = 221;328 *329 * RecursiveAssertionConfiguration config = RecursiveAssertionConfiguration.builder()330 * .withIgnoredFieldsMatchingRegexes("ad.*", "ag.")331 * .build();332 *333 * // assertion succeeds Person has only String fields except for address and age334 * assertThat(sherlock).usingRecursiveAssertion(config)335 * .allFieldsSatisfy(field -> field instanceof String);336 *337 * // assertion fails because of age, address and address.number fields as by default no fields are ignored338 * assertThat(sherlock).usingRecursiveComparison()339 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>340 *341 * @param regexes regexes used to ignore fields in the assertion.342 * @return this builder.343 */344 @Override345 public Builder withIgnoredFieldsMatchingRegexes(String... regexes) {346 return super.withIgnoredFieldsMatchingRegexes(regexes);347 }348 /**349 * Makes the recursive assertion to ignore all null fields.350 * <p>351 * Example:352 * <pre><code class='java'> class Person {353 * String name;354 * String occupation;355 * Address address;356 * }357 *358 * class Address {359 * int number;360 * String street;361 * }362 *363 * Person sherlock = new Person("Sherlock", "Detective");364 * sherlock.address = null;365 *366 * RecursiveAssertionConfiguration config = RecursiveAssertionConfiguration.builder()367 * .withIgnoreAllNullFields(true)368 * .build();369 *370 * // assertion succeeds as name and home.address.street fields are ignored in the comparison371 * assertThat(noName).usingRecursiveAssertion(config)372 * .allFieldsSatisfy(field -> field instanceof String);373 *374 * // assertion fails as name and home.address.street fields are populated for sherlock but not for noName.375 * assertThat(sherlock).usingRecursiveComparison()376 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>377 *378 * @param ignoreAllNullFields whether to ignore empty optional fields in the recursive comparison379 * @return This builder.380 */381 public Builder withIgnoreAllNullFields(boolean ignoreAllNullFields) {382 this.ignoreAllNullFields = ignoreAllNullFields;383 return this;384 }385 /**386 * Choose between running the {@link Predicate} in use over the primitive fields of an object in an object tree or not,387 * by default asserting over primitives is <em>enabled</em>.388 * <p>389 * For example, consider the following class:390 * <pre><code class='java'> class Example {391 * public int primitiveField;392 * public String objectField;393 * } </code></pre>394 * <p>395 * By default, the assertion being applied recursively is applied to <code>primitiveField</code> and to396 * <code>objectField</code>. If ignoring primitives it set to true, the assertion will only be applied to <code>objectField</code>.397 * <p>398 * If you elect to assert over primitives then it is your own responsibility as a developer to ensure that your399 * {@link Predicate} can handle (boxed) primitive arguments.</p>400 *401 * @param ignorePrimitiveFields <code>true</code> to avoid asserting over primitives, <code>false</code> to enable.402 * @return This builder.403 */404 public Builder withIgnorePrimitiveFields(final boolean ignorePrimitiveFields) {405 this.ignorePrimitiveFields = ignorePrimitiveFields;406 return this;407 }408 /**409 * <p>Choose whether or not, while recursively applying a {@link Predicate} to an object tree, the recursion will dive into 410 * types defined in the Java Class Library. That is to say, whether or not to recurse into objects whose classes are 411 * declared in a package starting with java.* or javax.* .</p>412 * <p>Consider the following example:</p>413 * <pre><code style='java'> class Example {414 * String s = "Don't look at me!";415 * }416 *417 * assertThat(new Example()).usingRecursiveAssertion(...).allFieldsSatisfy(o -> myPredicate(o)); </code></pre>418 *419 * <p>With no recursion into Java Class Library types, <code>myPredicate()</code> is applied to the field <code>s</code>420 * but not to the internal fields of {@link String}. With recursion into Java standard types active, the internal 421 * fields of String will be examined as well.</p>422 * <p>By default, recursion into Java Class Library types is <em>disabled</em>. 423 *424 * @param recursionIntoJavaClassLibraryTypes <code>true</code> to enable recursion into Java Class Library types, <code>false</code> to disable it. Defaults to <code>false</code>. 425 * @return This builder.426 */427 public Builder withRecursionIntoJavaClassLibraryTypes(final boolean recursionIntoJavaClassLibraryTypes) {428 this.skipJavaLibraryTypeObjects = !recursionIntoJavaClassLibraryTypes;429 return this;430 }431 /**432 * Makes the recursive assertion to ignore the object under test fields of the given types.433 * The fields are ignored if their types <b>exactly match one of the ignored types</b>, for example if a field is a subtype of an ignored type it is not ignored.434 * <p>435 * If some object under test fields are null it is not possible to evaluate their types and thus these fields are not ignored.436 * <p>437 * Example:438 * <pre><code class='java'> class Person {439 * String name;440 * String occupation;441 * Address address = new Address();442 * }443 *444 * class Address {445 * int number;446 * String street;447 * }448 *449 * Person sherlock = new Person("Sherlock", "Detective");450 * sherlock.address.street = "Baker Street";451 * sherlock.address.number = 221;452 *453 * RecursiveAssertionConfiguration config = RecursiveAssertionConfiguration.builder()454 * .withIgnoredFieldsOfTypes(Address.class)455 * .build();456 *457 * // assertion succeeds Person has only String fields except for address458 * assertThat(sherlock).usingRecursiveAssertion(config)459 * .allFieldsSatisfy(field -> field instanceof String);460 *461 * // assertion fails because of address and address.number fields as the default config does not ignore any types.462 * assertThat(sherlock).usingRecursiveComparison()463 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>464 *465 * @param types the types we want to ignore in the object under test fields.466 * @return This builder.467 */468 @Override469 public Builder withIgnoredFieldsOfTypes(Class<?>... types) {470 return super.withIgnoredFieldsOfTypes(types);471 }472 /**473 * <p>Selects the {@link CollectionAssertionPolicy} to use for recursive application of a {@link Predicate} to an object tree. 474 * If not set, defaults to {@link CollectionAssertionPolicy#COLLECTION_OBJECT_AND_ELEMENTS}.</p>475 * <p>Note that for the purposes of recursive asserting, an array counts as a collection, so this policy is applied to476 * arrays as well as children of {@link Collection}.477 *478 * @param policy The policy to use for collections and arrays in recursive asserting.479 * @return This builder.480 */481 public Builder withCollectionAssertionPolicy(CollectionAssertionPolicy policy) {482 collectionAssertionPolicy = policy;483 return this;484 }485 /**486 * <p>Selects the {@link MapAssertionPolicy} to use for recursive application of a {@link Predicate} to an object tree. 487 * If not set, defaults to {@link MapAssertionPolicy#MAP_OBJECT_AND_ENTRIES}.</p>488 *489 * @param policy The policy to use for maps in recursive asserting.490 * @return This builder.491 */492 public Builder withMapAssertionPolicy(MapAssertionPolicy policy) {493 mapAssertionPolicy = policy;494 return this;495 }496 /**497 * Makes the recursive assertion to use the specified {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy}.498 * <p>499 * See {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy} for the different possible policies, by default500 * {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy#OPTIONAL_VALUE_ONLY} is used.501 *502 * @param policy the {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy} to use.503 * @return This builder.504 */505 public Builder withOptionalAssertionPolicy(RecursiveAssertionConfiguration.OptionalAssertionPolicy policy) {506 optionalAssertionPolicy = policy;507 return this;508 }509 /**510 * Defines how objects are introspected in the recursive assertion.511 * <p>512 * Default to {@link DefaultRecursiveAssertionIntrospectionStrategy} that introspects all fields (including inherited ones).513 * 514 * @param introspectionStrategy the {@link RecursiveAssertionIntrospectionStrategy} to use515 * @return This builder.516 */517 public Builder withIntrospectionStrategy(RecursiveAssertionIntrospectionStrategy introspectionStrategy) {518 this.introspectionStrategy = introspectionStrategy;519 return this;520 }521 public RecursiveAssertionConfiguration build() {522 return new RecursiveAssertionConfiguration(this);523 }524 }525 /**526 * Possible policies to use regarding collections (including arrays) when recursively asserting over the fields of an object tree....
Source:RecursiveAssertionAssert.java
...15import java.util.List;16import java.util.Objects;17import java.util.function.Predicate;18import org.assertj.core.annotations.Beta;19import org.assertj.core.api.recursive.assertion.DefaultRecursiveAssertionIntrospectionStrategy;20import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;21import org.assertj.core.api.recursive.assertion.RecursiveAssertionDriver;22import org.assertj.core.api.recursive.assertion.RecursiveAssertionIntrospectionStrategy;23import org.assertj.core.api.recursive.comparison.FieldLocation;24/**25 * <p>An assertion that supports asserting a {@link Predicate} over all the fields of an object graph. Cycle avoidance is used,26 * so a graph that has cyclic references is essentially reduced to a tree by this class (the actual object graph is not changed27 * of course, it is treated as an immutable value).</p>28 *29 * @since 3.24.030 */31@Beta32public class RecursiveAssertionAssert extends AbstractAssert<RecursiveAssertionAssert, Object> {33 private final RecursiveAssertionConfiguration recursiveAssertionConfiguration;34 private final RecursiveAssertionDriver recursiveAssertionDriver;35 public RecursiveAssertionAssert(Object o, RecursiveAssertionConfiguration recursiveAssertionConfiguration) {36 super(o, RecursiveAssertionAssert.class);37 this.recursiveAssertionConfiguration = recursiveAssertionConfiguration;38 this.recursiveAssertionDriver = new RecursiveAssertionDriver(recursiveAssertionConfiguration);39 }40 /**41 * <p>Asserts that the given predicate is met for all fields of the object under test <b>recursively</b> (but not the object itself).</p>42 *43 * <p>For example if the object under test is an instance of class A, A has a B field and B a C field then the assertion checks A's B field and B's C field and all C's fields.</p>44 *45 * <p>The recursive algorithm employs cycle detection, so object graphs with cyclic references can safely be asserted over without causing looping.</p>46 *47 * <p>This method enables recursive asserting using default configuration, which means all fields of all objects have the 48 * {@link java.util.function.Predicate} applied to them (including primitive fields), no fields are excluded, but:49 * <ul>50 * <li>The recursion does not enter into Java Class Library types (java.*, javax.*)</li>51 * <li>The {@link java.util.function.Predicate} is applied to {@link java.util.Collection} and array elements (but the collection/array itself)</li>52 * <li>The {@link java.util.function.Predicate} is applied to {@link java.util.Map} values but not the map itself or its keys</li>53 * <li>The {@link java.util.function.Predicate} is applied to {@link java.util.Optional} and primitive optional values</li>54 * </ul>55 *56 * <p>It is possible to assert several predicates over the object graph in a row.</p>57 *58 * <p>The classes used in recursive asserting are <em>not</em> thread safe. Care must be taken when running tests in parallel59 * not to run assertions over object graphs that are being shared between tests.</p>60 * 61 * <p>Example:</p>62 * <pre><code style='java'> class Author {63 * String name;64 * String email;65 * List<Book> books = new ArrayList<>();66 *67 * Author(String name, String email) {68 * this.name = name;69 * this.email = email;70 * }71 * }72 *73 * class Book {74 * String title;75 * Author[] authors;76 *77 * Book(String title, Author[] authors) {78 * this.title = title;79 * this.authors = authors;80 * }81 * }82 *83 * Author pramodSadalage = new Author("Pramod Sadalage", "p.sadalage@recursive.test");84 * Author martinFowler = new Author("Martin Fowler", "m.fowler@recursive.test");85 * Author kentBeck = new Author("Kent Beck", "k.beck@recursive.test");86 *87 * Book noSqlDistilled = new Book("NoSql Distilled", new Author[] {pramodSadalage, martinFowler});88 * pramodSadalage.books.add(noSqlDistilled);89 * martinFowler.books.add(noSqlDistilled);90 * 91 * Book refactoring = new Book("Refactoring", new Author[] {martinFowler, kentBeck});92 * martinFowler.books.add(refactoring);93 * kentBeck.books.add(refactoring);94 *95 * // assertion succeeds96 * assertThat(pramodSadalage).usingRecursiveAssertion()97 * .allFieldsSatisfy(field -> field != null); </code></pre>98 *99 * @param predicate The predicate that is recursively applied to all the fields in the object tree of which actual is the root.100 * @return {@code this} assertions object101 * @throws AssertionError if one or more fields as described above fail the predicate test.102 */103 public RecursiveAssertionAssert allFieldsSatisfy(Predicate<Object> predicate) {104 // Reset the driver in case this is not the first predicate being run over actual.105 recursiveAssertionDriver.reset();106 List<FieldLocation> failedFields = recursiveAssertionDriver.assertOverObjectGraph(predicate, actual);107 if (!failedFields.isEmpty()) {108 throw objects.getFailures().failure(info, shouldNotSatisfyRecursively(recursiveAssertionConfiguration, failedFields));109 }110 return this;111 }112 /**113 * Asserts that none of the fields of the object under test graph (i.e. recursively getting the fields) are null (but not the object itself).114 * <p>115 * This is a convenience method for a common test, and it is equivalent to {@code allFieldsSatisfy(field -> field != null)}.116 * <p>117 * Example:118 * <pre><code style='java'> class Author {119 * String name;120 * String email;121 * List<Book> books = new ArrayList<>();122 *123 * Author(String name, String email) {124 * this.name = name;125 * this.email = email;126 * }127 * }128 *129 * class Book {130 * String title;131 * Author[] authors;132 *133 * Book(String title, Author[] authors) {134 * this.title = title;135 * this.authors = authors;136 * }137 * }138 *139 * Author pramodSadalage = new Author("Pramod Sadalage", "p.sadalage@recursive.test");140 * Author martinFowler = new Author("Martin Fowler", "m.fowler@recursive.test");141 * Author kentBeck = new Author("Kent Beck", "k.beck@recursive.test");142 *143 * Book noSqlDistilled = new Book("NoSql Distilled", new Author[]{pramodSadalage, martinFowler});144 * pramodSadalage.books.add(noSqlDistilled);145 * martinFowler.books.add(noSqlDistilled);146 * 147 * Book refactoring = new Book("Refactoring", new Author[] {martinFowler, kentBeck});148 * martinFowler.books.add(refactoring);149 * kentBeck.books.add(refactoring);150 *151 * // assertion succeeds152 * assertThat(pramodSadalage).usingRecursiveAssertion()153 * .hasNoNullFields(); </code></pre>154 *155 * @return {@code this} assertions object156 * @throws AssertionError if one or more fields as described above are null.157 */158 public RecursiveAssertionAssert hasNoNullFields() {159 return allFieldsSatisfy(Objects::nonNull);160 }161 /**162 * Makes the recursive assertion to ignore the specified fields in the object under test.163 * <p>164 * When a field is ignored, all its fields are ignored too.165 * <p>166 * Example:167 * <pre><code class='java'> class Person {168 * String name;169 * String occupation;170 * int age;171 * Address address = new Address();172 * }173 *174 * class Address {175 * int number;176 * String street;177 * }178 *179 * Person sherlock = new Person("Sherlock", "Detective", 60);180 * sherlock.address.street = "Baker Street";181 * sherlock.address.number = 221;182 *183 * // assertion succeeds because Person has only String fields except for address and age (address fields are ignored)184 * assertThat(sherlock).usingRecursiveAssertion()185 * .ignoringFields("address", "age")186 * .allFieldsSatisfy(field -> field instanceof String);187 *188 * // assertion fails because of age, address and address.number fields189 * assertThat(sherlock).usingRecursiveAssertion()190 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>191 *192 * @param fieldsToIgnore the fields to ignore in the object under test.193 * @return this {@link RecursiveAssertionAssert} to chain other methods.194 */195 public RecursiveAssertionAssert ignoringFields(String... fieldsToIgnore) {196 recursiveAssertionConfiguration.ignoreFields(fieldsToIgnore);197 return this;198 }199 /**200 * Makes the recursive assertion to ignore the fields matching the specified regexes in the object under test.201 * <p>202 * When a field is ignored, all its fields are ignored too.203 * <p>204 * Example:205 * <pre><code class='java'> class Person {206 * String name;207 * String occupation;208 * int age;209 * Address address = new Address();210 * }211 *212 * class Address {213 * int number;214 * String street;215 * }216 *217 * Person sherlock = new Person("Sherlock", "Detective", 60);218 * sherlock.address.street = "Baker Street";219 * sherlock.address.number = 221;220 *221 * // assertion succeeds because Person has only String fields except for address and age (address fields are ignored)222 * assertThat(sherlock).usingRecursiveAssertion()223 * .ignoringFieldsMatchingRegexes("ad.*", "ag.")224 * .allFieldsSatisfy(field -> field instanceof String);225 *226 * // assertion fails because of age and address fields (address.number is ignored)227 * assertThat(sherlock).usingRecursiveAssertion()228 * .ignoringFieldsMatchingRegexes(".*ber")229 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>230 *231 * @param regexes regexes used to ignore fields in the assertion.232 * @return this {@link RecursiveAssertionAssert} to chain other methods.233 */234 public RecursiveAssertionAssert ignoringFieldsMatchingRegexes(String... regexes) {235 recursiveAssertionConfiguration.ignoreFieldsMatchingRegexes(regexes);236 return this;237 }238 /**239 * Makes the recursive assertion to ignore the object under test fields of the given types.240 * The fields are ignored if their types <b>exactly match one of the ignored types</b>, for example if a field is a subtype of an ignored type it is not ignored.241 * <p>242 * If some object under test fields are null it is not possible to evaluate their types and thus these fields are not ignored.243 * <p>244 * When a field is ignored, all its fields are ignored too.245 * <p>246 * Example:247 * <pre><code class='java'> class Person {248 * String name;249 * String occupation;250 * Address address = new Address();251 * }252 *253 * class Address {254 * int number;255 * String street;256 * }257 *258 * Person sherlock = new Person("Sherlock", "Detective");259 * sherlock.address.street = "Baker Street";260 * sherlock.address.number = 221;261 *262 * // assertion succeeds because Person has only String fields except for address (address fields are ignored)263 * assertThat(sherlock).usingRecursiveAssertion()264 * .ignoringFieldsOfTypes(Address.class)265 * .allFieldsSatisfy(field -> field instanceof String);266 *267 * // assertion fails because of address and address.number fields268 * assertThat(sherlock).usingRecursiveAssertion()269 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>270 *271 * @param typesToIgnore the types we want to ignore in the object under test fields.272 * @return this {@link RecursiveAssertionAssert} to chain other methods.273 */274 public RecursiveAssertionAssert ignoringFieldsOfTypes(Class<?>... typesToIgnore) {275 recursiveAssertionConfiguration.ignoreFieldsOfTypes(typesToIgnore);276 return this;277 }278 /**279 * Choose between running the {@link Predicate} in use over the primitive fields of an object in an object tree or not,280 * by default asserting over primitives is <em>enabled</em>.281 * <p>282 * For example, consider the following class:283 * <pre><code class='java'> class Example {284 * public int primitiveField;285 * public String objectField;286 * } </code></pre>287 * <p>288 * By default, the assertion being applied recursively will be applied to <code>primitiveField</code> and to289 * <code>objectField</code>. If ignoring primitives it set to true, the assertion will only be applied to <code>objectField</code>.290 * <p>291 * If you elect to assert over primitives then it is your own responsibility as a developer to ensure that your292 * {@link Predicate} can handle (boxed) primitive arguments.</p>293 *294 * @return this {@link RecursiveAssertionAssert} to chain other methods.295 */296 public RecursiveAssertionAssert ignoringPrimitiveFields() {297 recursiveAssertionConfiguration.ignorePrimitiveFields(true);298 return this;299 }300 /**301 * Makes the recursive assertion to ignore all null fields.302 * <p>303 * <pre><code class='java'> class Person {304 * String name;305 * String occupation;306 * Address address;307 * }308 *309 * class Address {310 * int number;311 * String street;312 * }313 *314 * Person sherlock = new Person("Sherlock", "Detective");315 * sherlock.address = null;316 *317 * // assertion succeeds as address field is ignored318 * assertThat(noName).usingRecursiveAssertion()319 * .ignoringAllNullFields()320 * .allFieldsSatisfy(field -> field instanceof String);321 *322 * // assertion fails as address, address.number and address.street fields are not evaluated as String, street because it's null.323 * assertThat(sherlock).usingRecursiveAssertion()324 * .allFieldsSatisfy(field -> field instanceof String);</code></pre>325 *326 * @return this {@link RecursiveAssertionAssert} to chain other methods.327 */328 public RecursiveAssertionAssert ignoringAllNullFields() {329 recursiveAssertionConfiguration.ignoreAllNullFields(true);330 return this;331 }332 /**333 * Makes the recursive assertion to use the specified {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy}.334 * <p>335 * See {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy} for the different possible policies, by default336 * {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy#OPTIONAL_VALUE_ONLY} is used.337 *338 * @param optionalAssertionPolicy the {@link RecursiveAssertionConfiguration.OptionalAssertionPolicy} to use.339 * @return this {@link RecursiveAssertionAssert} to chain other methods.340 */341 public RecursiveAssertionAssert withOptionalAssertionPolicy(RecursiveAssertionConfiguration.OptionalAssertionPolicy optionalAssertionPolicy) {342 recursiveAssertionConfiguration.setOptionalAssertionPolicy(optionalAssertionPolicy);343 return this;344 }345 /**346 * Makes the recursive assertion to use the specified {@link RecursiveAssertionConfiguration.CollectionAssertionPolicy}.347 * <p>348 * See {@link RecursiveAssertionConfiguration.CollectionAssertionPolicy} for the different possible policies, by default349 * {@link RecursiveAssertionConfiguration.CollectionAssertionPolicy#ELEMENTS_ONLY} is used.350 *351 * @param collectionAssertionPolicy the {@link RecursiveAssertionConfiguration.CollectionAssertionPolicy} to use.352 * @return this {@link RecursiveAssertionAssert} to chain other methods.353 */354 public RecursiveAssertionAssert withCollectionAssertionPolicy(RecursiveAssertionConfiguration.CollectionAssertionPolicy collectionAssertionPolicy) {355 recursiveAssertionConfiguration.setCollectionAssertionPolicy(collectionAssertionPolicy);356 return this;357 }358 /**359 * Makes the recursive assertion to use the specified {@link RecursiveAssertionConfiguration.MapAssertionPolicy}.360 * <p>361 * See {@link RecursiveAssertionConfiguration.MapAssertionPolicy} for the different possible policies, by default362 * {@link RecursiveAssertionConfiguration.MapAssertionPolicy#MAP_VALUES_ONLY} is used.363 *364 * @param mapAssertionPolicy the {@link RecursiveAssertionConfiguration.MapAssertionPolicy} to use.365 * @return this {@link RecursiveAssertionAssert} to chain other methods.366 */367 public RecursiveAssertionAssert withMapAssertionPolicy(RecursiveAssertionConfiguration.MapAssertionPolicy mapAssertionPolicy) {368 recursiveAssertionConfiguration.setMapAssertionPolicy(mapAssertionPolicy);369 return this;370 }371 /**372 * Defines how objects are introspected in the recursive assertion.373 * <p>374 * Default to {@link DefaultRecursiveAssertionIntrospectionStrategy} that introspects all fields (including inherited ones).375 *376 * @param introspectionStrategy the {@link RecursiveAssertionIntrospectionStrategy} to use377 * @return this {@link RecursiveAssertionAssert} to chain other methods.378 */379 public RecursiveAssertionAssert withIntrospectionStrategy(RecursiveAssertionIntrospectionStrategy introspectionStrategy) {380 recursiveAssertionConfiguration.setIntrospectionStrategy(introspectionStrategy);381 return this;382 }383}...
Source:RecursiveAssertionConfiguration_toString_Test.java
...67 then(recursiveAssertionConfiguration).hasToString(format("- fields from Java Class Library types (java.* or javax.*) were excluded in the recursive assertion%n" +68 "- the collection assertion policy was ELEMENTS_ONLY%n" +69 "- the map assertion policy was MAP_VALUES_ONLY%n"+70 "- the optional assertion policy was OPTIONAL_VALUE_ONLY%n"+71 "- the introspection strategy used was: DefaultRecursiveAssertionIntrospectionStrategy which introspects all fields (including inherited ones)%n"));72 // @format:on73 }74 static class MyIntrospectionStrategy implements RecursiveAssertionIntrospectionStrategy {75 @Override76 public List<RecursiveAssertionNode> getChildNodesOf(Object node) {77 return emptyList();78 }79 @Override80 public String getDescription() {81 return "not introspecting anything!";82 }83 }84}...
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;2import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfigurationBuilder;3import org.assertj.core.api.recursive.assertion.RecursiveAssertionMode;4import org.assertj.core.api.recursive.assertion.RecursiveComparisonConfiguration;5import org.assertj.core.api.recursive.assertion.RecursiveComparisonConfigurationBuilder;6import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifference;7import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluator;8import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;9import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;10import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;11import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;12import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;13import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;14import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;15import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;16import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;17import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;18import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;19import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;20import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;21import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;22import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;23import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;24import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;25import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;26import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;27import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;28import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;29import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;30import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluatorRegistry;31import org.assertj.core.api.recursive.assertion.RecursiveComparisonDifferenceEvaluators;32import
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;2import org.assertj.core.api.recursive.assertion.RecursiveAssertionMode;3import org.assertj.core.api.recursive.assertion.RecursiveAssertionType;4import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.DefaultRecursiveAssertionIntrospectionStrategy;5public class RecursiveAssertionConfiguration1 {6 public static void main(String[] args) {7 RecursiveAssertionConfiguration recursiveAssertionConfiguration = new RecursiveAssertionConfiguration();8 DefaultRecursiveAssertionIntrospectionStrategy defaultRecursiveAssertionIntrospectionStrategy = recursiveAssertionConfiguration.DefaultRecursiveAssertionIntrospectionStrategy();9 System.out.println("DefaultRecursiveAssertionIntrospectionStrategy: " + defaultRecursiveAssertionIntrospectionStrategy);10 }11}12DefaultRecursiveAssertionIntrospectionStrategy()13isRecursiveAssertionEnabled()14getRecursiveAssertionMode()15getRecursiveAssertionType()16setRecursiveAssertionMode(RecursiveAssertionMode recursiveAssertionMode)17setRecursiveAssertionType(RecursiveAssertionType recursiveAssertionType)18setRecursiveAssertionEnabled(boolean recursiveAssertionEnabled)19setRecursiveAssertionIntrospectionStrategy(RecursiveAssertionIntrospectionStrategy recursiveAssertionIntrospectionStrategy)20setRecursiveAssertionConfiguration(RecursiveAssertionConfiguration recursiveAssertionConfiguration)21setRecursiveAssertionIntrospectionStrategy(RecursiveAssertionIntrospectionStrategy recursiveAssertionIntrospectionStrategy)
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1package org.example;2import org.assertj.core.api.recursive.assertion.DefaultRecursiveAssertionIntrospectionStrategy;3import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;4import org.assertj.core.api.recursive.assertion.RecursiveAssertionIntrospectionStrategy;5import org.junit.jupiter.api.Test;6public class RecursiveAssertionConfigurationTest {7 public void test() {8 RecursiveAssertionConfiguration configuration = new RecursiveAssertionConfiguration();9 RecursiveAssertionIntrospectionStrategy strategy = new DefaultRecursiveAssertionIntrospectionStrategy();10 configuration.setRecursiveAssertionIntrospectionStrategy(strategy);11 }12}13C:\Users\USER\Desktop\java\assertj-core-3.20.2\assertj-core-3.20.2\src\test\java\org\assertj\core\api\recursive\assertion>javac -cp .;junit-jupiter-api-5.7.1.jar;assertj-core-3.20.2.jar RecursiveAssertionConfigurationTest.java14C:\Users\USER\Desktop\java\assertj-core-3.20.2\assertj-core-3.20.2\src\test\java\org\assertj\core\api\recursive\assertion>java -cp .;junit-jupiter-api-5.7.1.jar;assertj-core-3.20.2.jar RecursiveAssertionConfigurationTest
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1import java.util.ArrayList;2import java.util.List;3import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;4import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfigurationBuilder;5public class DefaultRecursiveAssertionIntrospectionStrategy {6 public static void main(String[] args) {7 List<String> list = new ArrayList<>();8 list.add("1");9 list.add("2");10 list.add("3");11 List<String> list2 = new ArrayList<>();12 list2.add("1");13 list2.add("2");14 list2.add("3");15 List<List<String>> list3 = new ArrayList<>();16 list3.add(list);17 list3.add(list2);18 .recursiveAssertionConfiguration()19 .withDefaultRecursiveAssertionIntrospectionStrategy()20 .build();21 org.assertj.core.api.Assertions.assertThat(list3).usingRecursiveComparison(configuration).isEqualTo(list3);22 }23}24at org.assertj.core.internal.objects.Objects.assertIsEqualTo(Objects.java:120)25at org.assertj.core.api.AbstractObjectAssert.isEqualTo(AbstractObjectAssert.java:91)26at org.assertj.core.api.AbstractObjectAssert.isEqualTo(AbstractObjectAssert.java:95)27at DefaultRecursiveAssertionIntrospectionStrategy.main(DefaultRecursiveAssertionIntrospectionStrategy.java:32)
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1package org.assertj.core.api.recursive.assertion;2import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration;3import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration.RecursiveComparisonConfigurationBuilder;4public class RecursiveAssertionConfiguration {5 private final RecursiveComparisonConfiguration recursiveComparisonConfiguration;6 public RecursiveAssertionConfiguration() {7 this.recursiveComparisonConfiguration = new RecursiveComparisonConfiguration();8 }9 public RecursiveAssertionConfiguration(RecursiveComparisonConfiguration recursiveComparisonConfiguration) {10 this.recursiveComparisonConfiguration = recursiveComparisonConfiguration;11 }12 public RecursiveComparisonConfigurationBuilder recursiveComparisonConfiguration() {13 return new RecursiveComparisonConfigurationBuilder(this.recursiveComparisonConfiguration);14 }15 public boolean isUseFieldByFieldComparison() {16 return this.recursiveComparisonConfiguration.isUseFieldByFieldComparison();17 }18 public boolean isAllowingInfiniteRecursion() {19 return this.recursiveComparisonConfiguration.isAllowingInfiniteRecursion();20 }21 public boolean isIgnoringCollectionOrder() {22 return this.recursiveComparisonConfiguration.isIgnoringCollectionOrder();23 }24 public boolean isIgnoringOverriddenEqualsForFields() {25 return this.recursiveComparisonConfiguration.isIgnoringOverriddenEqualsForFields();26 }27 public boolean isIgnoringAllOverriddenEquals() {28 return this.recursiveComparisonConfiguration.isIgnoringAllOverriddenEquals();29 }30 public boolean isIgnoringAllActualNullFields() {31 return this.recursiveComparisonConfiguration.isIgnoringAllActualNullFields();32 }33 public boolean isIgnoringAllExpectedNullFields() {34 return this.recursiveComparisonConfiguration.isIgnoringAllExpectedNullFields();35 }36 public boolean isIgnoringActualNullFields() {37 return this.recursiveComparisonConfiguration.isIgnoringActualNullFields();38 }39 public boolean isIgnoringExpectedNullFields() {40 return this.recursiveComparisonConfiguration.isIgnoringExpectedNullFields();41 }42 public boolean isIgnoringFieldsWithoutDeclaredFields() {43 return this.recursiveComparisonConfiguration.isIgnoringFieldsWithoutDeclaredFields();44 }45 public boolean isIgnoringFieldsMatchingRegexes() {46 return this.recursiveComparisonConfiguration.isIgnoringFieldsMatchingRegexes();47 }48 public boolean isIgnoringFieldsMatchingPaths() {49 return this.recursiveComparisonConfiguration.isIgnoringFieldsMatchingPaths();50 }51 public boolean isIgnoringFieldsNamed() {52 return this.recursiveComparisonConfiguration.isIgnoringFieldsNamed();53 }54 public boolean isIgnoringActualEqualsToExpected() {
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1package org.example;2import static org.assertj.core.api.Assertions.assertThat;3import java.util.ArrayList;4import java.util.List;5import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration;6import org.junit.jupiter.api.Test;7public class DefaultRecursiveAssertionIntrospectionStrategyTest {8 public void testDefaultRecursiveAssertionIntrospectionStrategy() {9 List<String> list1 = new ArrayList<>();10 list1.add("a");11 list1.add("b");12 list1.add("c");13 List<String> list2 = new ArrayList<>();14 list2.add("a");15 list2.add("b");16 list2.add("c");17 RecursiveComparisonConfiguration recursiveComparisonConfiguration = new RecursiveComparisonConfiguration();18 recursiveComparisonConfiguration.setUseDefaultRecursiveAssertionIntrospectionStrategy(true);19 assertThat(list1).usingRecursiveComparison(recursiveComparisonConfiguration).isEqualTo(list2);20 }21}
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1import org.assertj.core.api.recursive.assertion.*;2import org.assertj.core.api.*;3import org.assertj.core.internal.*;4import org.assertj.core.internal.bytebuddy.*;5import org.assertj.core.internal.bytebuddy.implementation.*;6import org.assertj.core.internal.bytebuddy.implementation.bind.*;7import org.assertj.core.internal.bytebuddy.matcher.*;8import org.assertj.core.internal.bytebuddy.matcher.ElementMatcher.*;9import org.assertj.core.internal.bytebuddy.utility.*;10import org.assertj.core.internal.bytebuddy.agent.*;11import org.assertj.core.internal.bytebuddy.description.*;12import org.assertj.core.internal.bytebuddy.description.method.*;13import org.assertj.core.internal.bytebuddy.description.type.*;14import org.assertj.core.internal.bytebuddy.dynamic.*;15import org.assertj.core.internal.bytebuddy.dynamic.scaffold.*;16import org.assertj.core.internal.bytebuddy.dynamic.scaffold.inline.*;17import org.assertj.core.internal.bytebuddy.dynamic.scaffold.subclass.*;18import org.assertj.core.internal.bytebuddy.dynamic.loading.*;19import org.assertj.core.internal.bytebuddy.utility.*;20import org.assertj.core.internal.bytebuddy.utility.visitor.*;21import org.assertj.core.internal.bytebuddy.implementation.bytecode.*;22import org.assertj.core.internal.bytebuddy.implementation.bytecode.assign.*;23import org.assertj.core.internal.bytebuddy.implementation.bytecode.collection.*;24import org.assertj.core.internal.bytebuddy.implementation.bytecode.constant.*;25import org.assertj.core.internal.bytebuddy.implementation.bytecode.member.*;26import org.assertj.core.internal.bytebuddy.implementation.bytecode.member.MethodVariableAccess.*;27import org.assertj.core.internal.bytebuddy.implementation.bytecode.stack.*;28import org.assertj.core.internal.bytebuddy.implementation.bytecode.stack.member.*;29import org.assertj.core.internal.bytebuddy.implementation.bytecode.*;30import org.assertj.core.internal.bytebuddy.implementation.bytecode.assign.*;31import org.assertj.core.internal.bytebuddy.implementation.bytecode.collection.*;32import org.assertj.core.internal.bytebuddy.implementation.bytecode.constant.*;33import org.assertj.core.internal.bytebuddy.implementation.bytecode.member.*;34import org.assertj.core.internal.bytebuddy.implementation.bytecode.member.MethodVariableAccess.*;35import org.assertj.core.internal.bytebuddy.implementation.bytecode.stack.*;36import org.assertj.core.internal.bytebuddy.implementation.bytecode.stack.member.*;37import org.assertj.core.internal.bytebuddy.implementation.bytecode.*;38import org.assertj.core.internal.bytebuddy.implementation.bytecode.assign.*;39import org.assertj.core.internal.bytebuddy.implementation.bytecode.collection.*;40import org.assertj.core.internal.bytebuddy.implementation.bytecode.constant.*;41import org.assertj
DefaultRecursiveAssertionIntrospectionStrategy
Using AI Code Generation
1import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;2import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.DefaultRecursiveAssertionIntrospectionStrategy;3import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.RecursiveAssertionIntrospectionStrategy;4import org.assertj.core.internal.DeepDifference;5import org.assertj.core.internal.DeepDifference.Difference;6import java.util.List;7import java.util.stream.Collectors;8import java.util.stream.Stream;9public class RecursiveAssertionConfigurationDefaultRecursiveAssertionIntrospectionStrategy {10 public static void main(String[] args) {11 RecursiveAssertionIntrospectionStrategy recursiveAssertionIntrospectionStrategy = DefaultRecursiveAssertionIntrospectionStrategy.INSTANCE;12 RecursiveAssertionConfiguration recursiveAssertionConfiguration = new RecursiveAssertionConfiguration();13 recursiveAssertionConfiguration.setRecursiveAssertionIntrospectionStrategy(recursiveAssertionIntrospectionStrategy);14 DeepDifference deepDifference = new DeepDifference();15 Difference difference = deepDifference.difference("test", "test1");16 List<Difference> differenceList = Stream.of(difference).collect(Collectors.toList());17 String recursiveAssertionErrorMessage = recursiveAssertionConfiguration.createRecursiveAssertionErrorMessage(differenceList);18 System.out.println("RecursiveAssertionErrorMessage: " + recursiveAssertionErrorMessage);19 }20}21import org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration;22import org.assertj.core.internal.DeepDifference;23import org.assertj.core.internal.DeepDifference.Difference;24import java.util.List;25import java.util.stream.Collectors;26import java.util.stream.Stream;27public class RecursiveAssertionConfiguration {28 public static void main(String[] args) {29 RecursiveAssertionConfiguration recursiveAssertionConfiguration = new RecursiveAssertionConfiguration();
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!!