From 7128b5f44db33e6eb6b49e62c5c748264f5c55e2 Mon Sep 17 00:00:00 2001 From: balasr3 Date: Mon, 4 Sep 2023 00:36:13 +0530 Subject: [PATCH] BAEL-6572: Modified dto to remove lombok annotation as per guidelines and review comment --- .../baeldung/expression/dto/LicenseDto.java | 27 ++++++++++++++----- .../mapper/LicenseMapperUnitTest.java | 26 +++++++++--------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/mapstruct/src/main/java/com/baeldung/expression/dto/LicenseDto.java b/mapstruct/src/main/java/com/baeldung/expression/dto/LicenseDto.java index cd6e9bad68..2121038cf3 100644 --- a/mapstruct/src/main/java/com/baeldung/expression/dto/LicenseDto.java +++ b/mapstruct/src/main/java/com/baeldung/expression/dto/LicenseDto.java @@ -3,13 +3,6 @@ package com.baeldung.expression.dto; import java.time.LocalDateTime; import java.util.UUID; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -@AllArgsConstructor -@Data -@Builder public class LicenseDto { private UUID id; @@ -18,4 +11,24 @@ public class LicenseDto { private LocalDateTime endDate; + public UUID getId() { + return id; + } + + public LocalDateTime getStartDate() { + return startDate; + } + + public void setStartDate(LocalDateTime startDate) { + this.startDate = startDate; + } + + public LocalDateTime getEndDate() { + return endDate; + } + + public void setEndDate(LocalDateTime endDate) { + this.endDate = endDate; + } + } 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 98f704e61c..73be63561b 100644 --- a/mapstruct/src/test/java/com/baeldung/expression/mapper/LicenseMapperUnitTest.java +++ b/mapstruct/src/test/java/com/baeldung/expression/mapper/LicenseMapperUnitTest.java @@ -17,9 +17,9 @@ class LicenseMapperUnitTest { @Test void givenLicenseDtoWithStartDateAndWithoutEndDate_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithDefaultEndDate() { - License license = licenseMapper.toLicense(LicenseDto.builder() - .startDate(LocalDateTime.now()) - .build()); + LicenseDto licenseDto = new LicenseDto(); + licenseDto.setStartDate(LocalDateTime.now()); + License license = licenseMapper.toLicense(licenseDto); assertThat(license).isNotNull(); assertThat(license.getEndDate() .toLocalDate()).isEqualTo(LocalDate.now() @@ -28,10 +28,10 @@ class LicenseMapperUnitTest { @Test void givenLicenseDtoWithEndDateAndWithoutStartDate_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithDefaultStartDate() { - License license = licenseMapper.toLicense(LicenseDto.builder() - .endDate(LocalDateTime.now() - .plusYears(2)) - .build()); + LicenseDto licenseDto = new LicenseDto(); + licenseDto.setEndDate(LocalDateTime.now() + .plusYears(2)); + License license = licenseMapper.toLicense(licenseDto); assertThat(license).isNotNull(); assertThat(license.getStartDate() .toLocalDate()).isEqualTo(LocalDate.now()); @@ -39,8 +39,8 @@ class LicenseMapperUnitTest { @Test void givenLicenseDtoWithoutStartDateAndEndDate_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithDefaultDetails() { - License license = licenseMapper.toLicense(LicenseDto.builder() - .build()); + LicenseDto licenseDto = new LicenseDto(); + License license = licenseMapper.toLicense(licenseDto); assertThat(license).isNotNull(); assertThat(license.getStartDate() .toLocalDate()).isEqualTo(LocalDate.now()); @@ -53,10 +53,10 @@ class LicenseMapperUnitTest { @Test void givenLicenseDtoWithEndDateInTwoWeeks_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithRenewalRequiredSetToTrue() { - License license = licenseMapper.toLicense(LicenseDto.builder() - .endDate(LocalDateTime.now() - .plusDays(10)) - .build()); + LicenseDto licenseDto = new LicenseDto(); + licenseDto.setEndDate(LocalDateTime.now() + .plusDays(10)); + License license = licenseMapper.toLicense(licenseDto); assertThat(license).isNotNull(); assertThat(license.isRenewalRequired()).isTrue(); }