feat(iam): add UserRepository.findAllByOrderByCreatedAtDesc()
Add method to retrieve all users ordered by creation date descending. This supports the admin user management overview feature. Tests: - UserRepositoryTest: verify method exists and returns List<User>
This commit is contained in:
parent
72c29cfcc1
commit
b80b22ea46
@ -19,4 +19,6 @@ public interface UserRepository extends JpaRepository<User, UUID> {
|
|||||||
Optional<User> findByVerificationToken(String token);
|
Optional<User> findByVerificationToken(String token);
|
||||||
|
|
||||||
Optional<User> findByPasswordResetToken(String token);
|
Optional<User> findByPasswordResetToken(String token);
|
||||||
|
|
||||||
|
List<User> findAllByOrderByCreatedAtDesc();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
package at.mueller.eeg.backend.iam.repository;
|
||||||
|
|
||||||
|
import at.mueller.eeg.backend.iam.domain.User;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class UserRepositoryTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findAllByOrderByCreatedAtDesc_methodExists() throws NoSuchMethodException {
|
||||||
|
Method method = UserRepository.class.getMethod("findAllByOrderByCreatedAtDesc");
|
||||||
|
assertNotNull(method);
|
||||||
|
assertEquals(List.class, method.getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findAllByOrderByCreatedAtDesc_returnsUserList() throws NoSuchMethodException {
|
||||||
|
Method method = UserRepository.class.getMethod("findAllByOrderByCreatedAtDesc");
|
||||||
|
assertNotNull(method, "findAllByOrderByCreatedAtDesc method not found on UserRepository");
|
||||||
|
|
||||||
|
Class<?> returnType = method.getReturnType();
|
||||||
|
assertEquals(List.class, returnType, "Method should return List");
|
||||||
|
|
||||||
|
java.lang.reflect.Type genericReturnType = method.getGenericReturnType();
|
||||||
|
assertTrue(genericReturnType instanceof java.lang.reflect.ParameterizedType,
|
||||||
|
"Generic return type should be ParameterizedType");
|
||||||
|
|
||||||
|
java.lang.reflect.ParameterizedType parameterizedType =
|
||||||
|
(java.lang.reflect.ParameterizedType) genericReturnType;
|
||||||
|
Class<?> actualTypeArgument = (Class<?>) parameterizedType.getActualTypeArguments()[0];
|
||||||
|
assertEquals(User.class, actualTypeArgument, "Method should return List<User>");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user