Daniel Bohry пре 2 недеља
родитељ
комит
959f66ed58
1 измењених фајлова са 9 додато и 7 уклоњено
  1. 9 7
      src/test/java/com/danielbohry/authservice/TestDataFactory.java

+ 9 - 7
src/test/java/com/danielbohry/authservice/TestDataFactory.java

@@ -16,6 +16,8 @@ import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
 
+import static java.time.Instant.now;
+
 /**
  * Utility class for creating test data objects.
  * Provides builder methods and common test objects to reduce test code duplication.
@@ -146,7 +148,7 @@ public class TestDataFactory {
                 .id(DEFAULT_USER_ID)
                 .username(DEFAULT_USERNAME)
                 .token(DEFAULT_JWT_TOKEN)
-                .expirationDate(Instant.now().plusSeconds(3600))
+                .expirationDate(now().plusSeconds(3600))
                 .roles(List.of("ROLE_USER"))
                 .build();
     }
@@ -159,7 +161,7 @@ public class TestDataFactory {
                 .id(userId)
                 .username(username)
                 .token(DEFAULT_JWT_TOKEN)
-                .expirationDate(Instant.now().plusSeconds(3600))
+                .expirationDate(now().plusSeconds(3600))
                 .roles(roles)
                 .build();
     }
@@ -170,7 +172,7 @@ public class TestDataFactory {
     public static Authentication createAuthentication() {
         return new Authentication(
                 DEFAULT_JWT_TOKEN,
-                Instant.now().plusSeconds(3600),
+                now().plusSeconds(3600),
                 DEFAULT_USERNAME,
                 List.of("ROLE_USER")
         );
@@ -182,7 +184,7 @@ public class TestDataFactory {
     public static Authentication createAuthentication(long expirationSeconds) {
         return new Authentication(
                 DEFAULT_JWT_TOKEN,
-                Instant.now().plusSeconds(expirationSeconds),
+                now().plusSeconds(expirationSeconds),
                 DEFAULT_USERNAME,
                 List.of("ROLE_USER")
         );
@@ -206,14 +208,14 @@ public class TestDataFactory {
      * Creates a UserResponse
      */
     public static UserResponse createUserResponse() {
-        return new UserResponse(DEFAULT_USER_ID, DEFAULT_USERNAME, DEFAULT_EMAIL, List.of("USER"), true);
+        return new UserResponse(DEFAULT_USER_ID, DEFAULT_USERNAME, DEFAULT_EMAIL, List.of("USER"), true, now());
     }
 
     /**
      * Creates a UserResponse with specified parameters
      */
     public static UserResponse createUserResponse(String id, String username, List<String> roles) {
-        return new UserResponse(id, username, null, roles, true);
+        return new UserResponse(id, username, null, roles, true, now());
     }
 
     /**
@@ -232,6 +234,6 @@ public class TestDataFactory {
     public static AuthenticationResponse.AuthenticationResponseBuilder authResponseBuilder() {
         return AuthenticationResponse.builder()
                 .token(DEFAULT_JWT_TOKEN)
-                .expirationDate(Instant.now().plusSeconds(3600));
+                .expirationDate(now().plusSeconds(3600));
     }
 }