From 12e12e10803e30c8c1b3bf17178c93cbe1041b15 Mon Sep 17 00:00:00 2001 From: Nour Eldien Ayman Date: Fri, 16 May 2025 20:41:29 +0300 Subject: [PATCH 1/3] Add DeliveryAddress DTO and update references in authentication classes --- .../podzilla/auth/dto/DeliveryAddress.java | 21 +++++++++++++++++++ .../com/podzilla/auth/dto/SignupRequest.java | 1 - .../com/podzilla/auth/dto/UpdateRequest.java | 1 - .../podzilla/auth/dto/UserDetailsRequest.java | 1 - .../podzilla/auth/service/UserService.java | 2 +- .../AuthenticationControllerTest.java | 2 +- .../service/AuthenticationServiceTest.java | 2 +- 7 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/podzilla/auth/dto/DeliveryAddress.java diff --git a/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java b/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java new file mode 100644 index 0000000..0bb84c3 --- /dev/null +++ b/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java @@ -0,0 +1,21 @@ +package com.podzilla.auth.dto; + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DeliveryAddress implements Serializable { + + private static final long serialVersionUID = 1L; + + private String street; + private String city; + private String state; + private String country; + private String postalCode; +} \ No newline at end of file diff --git a/src/main/java/com/podzilla/auth/dto/SignupRequest.java b/src/main/java/com/podzilla/auth/dto/SignupRequest.java index 380f4ff..2312e97 100644 --- a/src/main/java/com/podzilla/auth/dto/SignupRequest.java +++ b/src/main/java/com/podzilla/auth/dto/SignupRequest.java @@ -1,6 +1,5 @@ package com.podzilla.auth.dto; -import com.podzilla.mq.events.DeliveryAddress; import jakarta.validation.Valid; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; diff --git a/src/main/java/com/podzilla/auth/dto/UpdateRequest.java b/src/main/java/com/podzilla/auth/dto/UpdateRequest.java index 9258d09..53ef460 100644 --- a/src/main/java/com/podzilla/auth/dto/UpdateRequest.java +++ b/src/main/java/com/podzilla/auth/dto/UpdateRequest.java @@ -1,6 +1,5 @@ package com.podzilla.auth.dto; -import com.podzilla.mq.events.DeliveryAddress; import lombok.Data; @Data diff --git a/src/main/java/com/podzilla/auth/dto/UserDetailsRequest.java b/src/main/java/com/podzilla/auth/dto/UserDetailsRequest.java index 6f75b6f..9f36a3c 100644 --- a/src/main/java/com/podzilla/auth/dto/UserDetailsRequest.java +++ b/src/main/java/com/podzilla/auth/dto/UserDetailsRequest.java @@ -1,6 +1,5 @@ package com.podzilla.auth.dto; -import com.podzilla.mq.events.DeliveryAddress; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/com/podzilla/auth/service/UserService.java b/src/main/java/com/podzilla/auth/service/UserService.java index 95616eb..2577ce8 100644 --- a/src/main/java/com/podzilla/auth/service/UserService.java +++ b/src/main/java/com/podzilla/auth/service/UserService.java @@ -1,6 +1,7 @@ package com.podzilla.auth.service; import com.podzilla.auth.dto.CustomUserDetails; +import com.podzilla.auth.dto.DeliveryAddress; import com.podzilla.auth.dto.UpdateRequest; import com.podzilla.auth.dto.UserDetailsRequest; import com.podzilla.auth.exception.NotFoundException; @@ -9,7 +10,6 @@ import com.podzilla.auth.model.User; import com.podzilla.auth.repository.AddressRepository; import com.podzilla.auth.repository.UserRepository; -import com.podzilla.mq.events.DeliveryAddress; import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/test/java/com/podzilla/auth/controller/AuthenticationControllerTest.java b/src/test/java/com/podzilla/auth/controller/AuthenticationControllerTest.java index 31553e1..b2cecd6 100644 --- a/src/test/java/com/podzilla/auth/controller/AuthenticationControllerTest.java +++ b/src/test/java/com/podzilla/auth/controller/AuthenticationControllerTest.java @@ -11,7 +11,7 @@ import com.podzilla.auth.repository.RoleRepository; import com.podzilla.auth.repository.UserRepository; import com.podzilla.auth.service.TokenService; // Assuming you have a JwtService -import com.podzilla.mq.events.DeliveryAddress; +import com.podzilla.auth.dto.DeliveryAddress; import jakarta.servlet.http.Cookie; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/com/podzilla/auth/service/AuthenticationServiceTest.java b/src/test/java/com/podzilla/auth/service/AuthenticationServiceTest.java index b111cf2..40eaf8e 100644 --- a/src/test/java/com/podzilla/auth/service/AuthenticationServiceTest.java +++ b/src/test/java/com/podzilla/auth/service/AuthenticationServiceTest.java @@ -14,7 +14,7 @@ import com.podzilla.mq.EventsConstants; import com.podzilla.mq.events.BaseEvent; import com.podzilla.mq.events.CustomerRegisteredEvent; -import com.podzilla.mq.events.DeliveryAddress; +import com.podzilla.auth.dto.DeliveryAddress; import jakarta.servlet.http.HttpServletRequest; // Added import import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.BeforeEach; From b451ddfb4d614eee4504066a7c48b2d244194bab Mon Sep 17 00:00:00 2001 From: Nour Eldien Ayman Date: Fri, 16 May 2025 20:41:50 +0300 Subject: [PATCH 2/3] Fix formatting in DeliveryAddress DTO by adding newline at end of file --- src/main/java/com/podzilla/auth/dto/DeliveryAddress.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java b/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java index 0bb84c3..aa0d03c 100644 --- a/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java +++ b/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java @@ -18,4 +18,4 @@ public class DeliveryAddress implements Serializable { private String state; private String country; private String postalCode; -} \ No newline at end of file +} From f2cda13894444e63ca89940edfbc5e9917dd4d32 Mon Sep 17 00:00:00 2001 From: Nour Eldien Ayman Date: Fri, 16 May 2025 20:42:56 +0300 Subject: [PATCH 3/3] Add validation annotations to DeliveryAddress fields --- .../java/com/podzilla/auth/dto/DeliveryAddress.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java b/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java index aa0d03c..5663c98 100644 --- a/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java +++ b/src/main/java/com/podzilla/auth/dto/DeliveryAddress.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import jakarta.validation.constraints.NotBlank; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -13,9 +14,18 @@ public class DeliveryAddress implements Serializable { private static final long serialVersionUID = 1L; + @NotBlank(message = "Street is required") private String street; + + @NotBlank(message = "City is required") private String city; + + @NotBlank(message = "State is required") private String state; + + @NotBlank(message = "Country is required") private String country; + + @NotBlank(message = "Postal code is required") private String postalCode; }