I need to compare a DTO class with its Entity class.
For example, an AddressDTO class would be:
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class AddressDTO {
private StringTypeDTO text;
private List line;
…
I am trying to implement lambda expression for constructor. My constructor can throw an IllegalArgumentException. I tried different ways. First way is just calling lambda expression:
catchThrowable(() -> new SomeClass(testVar1, null, testVar2));
It…
I want to compare two objects (DTO and an Entity) using AssertJ's recursive comparison, for purpose of unit-testing DTO->Entity mapper.
Both of these objects have fields with pretty much the same values, but some of the fields have different names…
I have two xml files. First contains namespace prefix and the second one doesn't. So when I assert them I want to ignore these prefixes and check for equality.
@Test
public void test1(){
String control = "
SoftAssertions in AssertJ is useful when I need to make sure multiple conditions hold or collect as many failures as possible:
final SoftAssertions softly = new SoftAssertions();
softly.assertThat("foo").hasToString("foo");
…
I'm stuck trying to get the second test of the code below to work.
Both have the same payload structure, the one that works use Map<> only, the second one uses classes.
Why does the first test work but the second doesn't?
It seems a bug with…
I feel like I'm missing something obvious here, but the documentation is letting me down. I'm attempting to compare two maps while ignoring a set of fields in assertJ. I would like to see this assert pass:
private static final String[]…
Context
I got an AssertJ-Swing (3.9.2) test giving me headaches, sometimes it fails with a ComponentLookupError declaring that the entire component hierarchy is empty. This is the exact scenario of this question, with the addition that I'm using VNC…
I have the following test code which checks the content of a particular directory structure
assertThat(install_should_not_fail).isDirectory().satisfies(isnf -> {
assertThat(new File(isnf, "maven-metadata-local.xml")).isNotEmpty();
assertThat(new…
Hi Java Gurus and AssertJ Gurus,
I would like to ask if there is a way in AssertJ to verify if an object exists from a list of Objects (e.g. ArrayList listOfTestObjects). Where that particular object's field (getter method's return)…
I am trying to write a test for a method that throws custom exception. It fails with Assertion error. What could be done to properly catch the exception and pass the test?
Service method:
@Service
public class CustomServiceImpl implements…
I want to provide an API to an API consumer. This API can be used to perform certain tests easily. I'm using AssertJ custom assertions to build this API.
While the API consumer calls or uses my custom assertions, I would like him to easily configure…
I have a service SomeService with one method to do some logic.
@Override
public CompletableFuture process(User user) {
Objects.requiredNonNull(user, "user must not be null");
// other logic...
}
Then I have a test for…