Merge branch 'mimocode/proud-moon'

This commit is contained in:
Bernhard Müller 2026-07-23 13:55:47 +02:00
commit 727105a92d
2 changed files with 39 additions and 0 deletions

View File

@ -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();
} }

View File

@ -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>");
}
}