From eb4a1d040e8aabd9e44d716f8d0b306709c6bc81 Mon Sep 17 00:00:00 2001 From: balasr3 Date: Tue, 22 Aug 2023 20:59:17 +0100 Subject: [PATCH] BAEL-6572: Modified test based on review comments --- .../mapper/LicenseMapperUnitTest.java | 51 ++++++------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/mapstruct/src/test/java/com/baeldung/expression/mapper/LicenseMapperUnitTest.java b/mapstruct/src/test/java/com/baeldung/expression/mapper/LicenseMapperUnitTest.java index b741c45e4e..38bf940325 100644 --- a/mapstruct/src/test/java/com/baeldung/expression/mapper/LicenseMapperUnitTest.java +++ b/mapstruct/src/test/java/com/baeldung/expression/mapper/LicenseMapperUnitTest.java @@ -20,14 +20,10 @@ class LicenseMapperUnitTest { License license = licenseMapper.toLicense(LicenseDto.builder() .startDate(LocalDateTime.now()) .build()); - assertThat(license).isNotNull() - .satisfies(l -> { - assertThat(l.getStartDate() - .toLocalDate()).isEqualTo(LocalDate.now()); - assertThat(l.getEndDate() - .toLocalDate()).isEqualTo(LocalDate.now() - .plusYears(1)); - }); + assertThat(license).isNotNull(); + assertThat(license.getEndDate() + .toLocalDate()).isEqualTo(LocalDate.now() + .plusYears(1)); } @Test @@ -36,28 +32,21 @@ class LicenseMapperUnitTest { .endDate(LocalDateTime.now() .plusYears(2)) .build()); - assertThat(license).isNotNull() - .satisfies(l -> { - assertThat(l.getStartDate() - .toLocalDate()).isEqualTo(LocalDate.now()); - assertThat(l.getEndDate() - .toLocalDate()).isEqualTo(LocalDate.now() - .plusYears(2)); - }); + assertThat(license).isNotNull(); + assertThat(license.getStartDate() + .toLocalDate()).isEqualTo(LocalDate.now()); } @Test void givenLicenseDtoWithoutEndDateAndWithoutStartDate_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithDefaultStartDateAndEndDate() { License license = licenseMapper.toLicense(LicenseDto.builder() .build()); - assertThat(license).isNotNull() - .satisfies(l -> { - assertThat(l.getStartDate() - .toLocalDate()).isEqualTo(LocalDate.now()); - assertThat(l.getEndDate() - .toLocalDate()).isEqualTo(LocalDate.now() - .plusYears(1)); - }); + assertThat(license).isNotNull(); + assertThat(license.getStartDate() + .toLocalDate()).isEqualTo(LocalDate.now()); + assertThat(license.getEndDate() + .toLocalDate()).isEqualTo(LocalDate.now() + .plusYears(1)); } @Test @@ -77,21 +66,13 @@ class LicenseMapperUnitTest { } @Test - void givenLicenseDtoWithEndDateInTwoWeeks_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithReminderSetToTrue() { + void givenLicenseDtoWithEndDateInTwoWeeks_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithRenewalRequiredSetToTrue() { License license = licenseMapper.toLicense(LicenseDto.builder() .endDate(LocalDateTime.now() .plusDays(10)) .build()); - assertThat(license).isNotNull() - .satisfies(l -> { - assertThat(l.getStartDate() - .toLocalDate()).isEqualTo(LocalDate.now()); - assertThat(l.getEndDate() - .toLocalDate()).isEqualTo(LocalDate.now() - .plusDays(10)); - assertThat(l.isActive()).isTrue(); - assertThat(l.isRenewalRequired()).isTrue(); - }); + assertThat(license).isNotNull(); + assertThat(license.isRenewalRequired()).isTrue(); } } \ No newline at end of file