Merge branch 'mimocode/jolly-planet' into master
This commit is contained in:
commit
93c0151113
@ -37,6 +37,9 @@ public interface MembershipRepository extends JpaRepository<Membership, UUID> {
|
|||||||
@Query("SELECT m FROM Membership m JOIN FETCH m.meteringPoint mp JOIN FETCH m.energyCommunity ec WHERE m.status = 'PENDING'")
|
@Query("SELECT m FROM Membership m JOIN FETCH m.meteringPoint mp JOIN FETCH m.energyCommunity ec WHERE m.status = 'PENDING'")
|
||||||
List<Membership> findPendingWithDetails();
|
List<Membership> findPendingWithDetails();
|
||||||
|
|
||||||
|
@Query("SELECT m FROM Membership m JOIN FETCH m.meteringPoint mp JOIN FETCH m.energyCommunity ec")
|
||||||
|
List<Membership> findAllWithDetails();
|
||||||
|
|
||||||
@Query("SELECT mp.userId FROM Membership m JOIN m.meteringPoint mp WHERE m.energyCommunity.id = :communityId AND m.status != 'INACTIVE'")
|
@Query("SELECT mp.userId FROM Membership m JOIN m.meteringPoint mp WHERE m.energyCommunity.id = :communityId AND m.status != 'INACTIVE'")
|
||||||
List<UUID> findActiveMemberUserIdsByCommunityId(@Param("communityId") UUID communityId);
|
List<UUID> findActiveMemberUserIdsByCommunityId(@Param("communityId") UUID communityId);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
package at.mueller.eeg.backend.community.repository;
|
||||||
|
|
||||||
|
import at.mueller.eeg.backend.community.domain.Membership;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class MembershipRepositoryTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findAllWithDetails_methodExists() throws NoSuchMethodException {
|
||||||
|
Method method = MembershipRepository.class.getMethod("findAllWithDetails");
|
||||||
|
assertNotNull(method);
|
||||||
|
assertEquals(List.class, method.getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findAllWithDetails_hasQueryAnnotation() {
|
||||||
|
Method method = null;
|
||||||
|
try {
|
||||||
|
method = MembershipRepository.class.getMethod("findAllWithDetails");
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
fail("findAllWithDetails method not found on MembershipRepository");
|
||||||
|
}
|
||||||
|
|
||||||
|
org.springframework.data.jpa.repository.Query queryAnnotation =
|
||||||
|
method.getAnnotation(org.springframework.data.jpa.repository.Query.class);
|
||||||
|
assertNotNull(queryAnnotation, "findAllWithDetails should have @Query annotation");
|
||||||
|
|
||||||
|
String queryValue = queryAnnotation.value();
|
||||||
|
assertTrue(queryValue.contains("JOIN FETCH m.meteringPoint"),
|
||||||
|
"Query should JOIN FETCH meteringPoint");
|
||||||
|
assertTrue(queryValue.contains("JOIN FETCH m.energyCommunity"),
|
||||||
|
"Query should JOIN FETCH energyCommunity");
|
||||||
|
assertFalse(queryValue.contains("WHERE"),
|
||||||
|
"Query should not have WHERE clause (returns all statuses)");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user