By now hopefully all of us, developers, have embraced unit testing. Good test coverage of our codebase, combined with that green checkmark after running the tests, gives us a warm fuzzy feeling that everything is in order. While we all like that warm fuzzy feeling, writing tests usually requires some plumbing. This is the "boring part", where you create your test objects and manually set them up with dummy data. Oftentimes the values themselves don't even matter. A typical example of this is testing "converter" logic. For example, we might be converting a JPA entity to a DTO, or a JAXB class to something else. Such a test might look something like this:
@Test
void verifyCustomer() {
Customer customer = new Customer();
customer.setFirstName("John");
customer.setLastName("Doe");
customer.setAddress(new Address("123 Main St", "Seattle", "US"));
customer.setPhoneNumbers(List.of(
new Phone(PhoneType.HOME, "+1", "123-44-55"),
new Phone(PhoneType.WORK, "+1", "555-77-88")));
// ... etc
CustomerDTO customerDto = customerMapper.toDto(customer);
assertThat(customerDto.getFirstName()).isEqualTo(customer.getFirstName());
assertThat(customerDto.getLastName()).isEqualTo(customer.getLastName());
// ... etc
}