AssertJ: For a Pojo how to check each nested Property/Field in one chained sentence

I think the best way is to extract all the properties/fields and then checks it does not contain null. Example: TolkienCharacter frodo = new TolkienCharacter(“Frodo”, 33, HOBBIT); // support nested properties: assertThat(frodo).extracting(“name”, “age”, “race.name”) .doesNotContainNull() .containsExactly(“Frodo”, 33, “Hobbit”); Note that you can also use lambdas to extract values from the object under test. assertThat(frodo).extracting(TolkienCharacter::getName, character … Read more

How to compare recursively ignoring given fields using assertJ?

With latest ‘Recursive comparison api improvements’ from AssertJ release 3.12.0 it’s possible now to do a recursive comparison and ignore fields: Assertions.assertThat(objActual) .usingRecursiveComparison() .ignoringFields(“uniqueId”, “otherId”) .ignoringFieldsMatchingRegexes(“.*someId”) .ignoringOverriddenEqualsForTypes(MyData.class, MyDataItem.class) .isEqualTo(objExpected);

Can you add a custom message to AssertJ assertThat?

And in classic fashion, I found what I was looking for moments after posting the question. Hopefully this will make it easier for the next person to find without first having to know what it’s called. The magic method is the deceptively short-named as, which is part of another interface that AbstractAssert implements: Descriptable, not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)