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