@@ -116,14 +116,15 @@ void findBestCandidateByPriority_success() {
116116 .festival (festival )
117117 .build ();
118118 ReflectionTestUtils .setField (applicant , "participantId" , 1L );
119+ List <Long > excludedIds = matchingRepository .findExcludeIds (applicant .getParticipantId ());
119120
120121 Participant target = Participant .builder ()
121122 .user (targetUser )
122123 .typeResult (TypeResult .PHOTO )
123124 .festival (festival )
124125 .build ();
125126
126- when (matchingRepository .findMatchingCandidates (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
127+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
127128 .thenReturn (List .of (target ));
128129
129130 var result = matchingService .findBestCandidateByPriority (festival .getFestivalId (), applicant );
@@ -145,9 +146,10 @@ void findBestCandidate_prioritySecond_success() {
145146 .festival (festival )
146147 .build ();
147148 ReflectionTestUtils .setField (applicant , "participantId" , 1L );
149+ List <Long > excludedIds = matchingRepository .findExcludeIds (applicant .getParticipantId ());
148150
149151 // 1순위 PHOTO에 대상 없음
150- when (matchingRepository .findMatchingCandidates (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
152+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
151153 .thenReturn (Collections .emptyList ());
152154
153155 // 2순위 INFLUENCER에 대상 있음
@@ -157,7 +159,7 @@ void findBestCandidate_prioritySecond_success() {
157159 .festival (festival )
158160 .build ();
159161
160- when (matchingRepository .findMatchingCandidates (1L , TypeResult .INFLUENCER , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
162+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .INFLUENCER , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
161163 .thenReturn (List .of (secondPriorityCandidate ));
162164
163165 var result = matchingService .findBestCandidateByPriority (festival .getFestivalId (), applicant );
@@ -176,16 +178,18 @@ void findBestCandidate_priorityThird_success() {
176178
177179 // 신청자
178180 Participant applicant = mockParticipant (applicantUser , festival , TypeResult .INFLUENCER , 1L );
181+ List <Long > excludedIds = matchingRepository .findExcludeIds (applicant .getParticipantId ());
182+
179183 // 3순위 NEWBIE에 대상 있음
180184 Participant thirdPriorityCandidate = mockParticipant (thirdPriorityUser , festival , TypeResult .NEWBIE , 2L );
181185
182186 // 1순위 PHOTO, 2순위 INFLUENCER 대상 없음
183- when (matchingRepository .findMatchingCandidates (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
187+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
184188 .thenReturn (Collections .emptyList ());
185- when (matchingRepository .findMatchingCandidates (1L , TypeResult .INFLUENCER , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
189+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .INFLUENCER , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
186190 .thenReturn (Collections .emptyList ());
187191 // 3순위 대상 있음
188- when (matchingRepository .findMatchingCandidates (1L , TypeResult .NEWBIE , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
192+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .NEWBIE , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
189193 .thenReturn (List .of (thirdPriorityCandidate ));
190194
191195 var result = matchingService .findBestCandidateByPriority (festival .getFestivalId (), applicant );
@@ -206,13 +210,14 @@ void findBestCandidate_alreadyMatchedCandidate_empty() {
206210 .festival (festival )
207211 .build ();
208212 ReflectionTestUtils .setField (applicant , "participantId" , 1L );
213+ List <Long > excludedIds = matchingRepository .findExcludeIds (applicant .getParticipantId ());
209214
210215 // 대상이 존재하나 이미 매칭됨 (Repository에서 필터링 됨)
211- when (matchingRepository .findMatchingCandidates (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
216+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
212217 .thenReturn (Collections .emptyList ());
213- when (matchingRepository .findMatchingCandidates (1L , TypeResult .INFLUENCER , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
218+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .INFLUENCER , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
214219 .thenReturn (Collections .emptyList ());
215- when (matchingRepository .findMatchingCandidates (1L , TypeResult .NEWBIE , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
220+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .NEWBIE , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
216221 .thenReturn (Collections .emptyList ());
217222
218223 Optional <Participant > result = matchingService .findBestCandidateByPriority (festival .getFestivalId (), applicant );
@@ -231,9 +236,10 @@ void findBestCandidateByPriority_empty() {
231236 .typeResult (TypeResult .INFLUENCER )
232237 .festival (festival )
233238 .build ();
239+ List <Long > excludedIds = matchingRepository .findExcludeIds (applicant .getParticipantId ());
234240
235- when (matchingRepository .findMatchingCandidates (
236- applicant .getParticipantId (), TypeResult .PHOTO , Gender .MAN , festival .getFestivalId (), PageRequest .of (0 , 1 )
241+ when (matchingRepository .findMatchingCandidatesDsl (
242+ applicant .getParticipantId (), TypeResult .PHOTO , Gender .MAN , festival .getFestivalId (), PageRequest .of (0 , 1 ), excludedIds
237243 )).thenReturn (Collections .emptyList ());
238244
239245 Optional <Participant > result = matchingService .findBestCandidateByPriority (
@@ -369,14 +375,15 @@ void findBestCandidate_multipleCandidates_returnsFirstOnly() {
369375 User applicantUser = mockUser ("신청자" , Gender .MAN , 1L );
370376 Festival festival = mockFestival (applicantUser , 1L , LocalDate .now ().minusDays (1 ), LocalDate .now ().plusDays (1 ));
371377 Participant applicant = mockParticipant (applicantUser , festival , TypeResult .INFLUENCER , 1L );
378+ List <Long > excludedIds = matchingRepository .findExcludeIds (applicant .getParticipantId ());
372379
373380 User candidate1 = mockUser ("후보1" , Gender .WOMAN , 2L );
374381 User candidate2 = mockUser ("후보2" , Gender .WOMAN , 3L );
375382 Participant p1 = mockParticipant (candidate1 , festival , TypeResult .PHOTO , 2L );
376383 Participant p2 = mockParticipant (candidate2 , festival , TypeResult .PHOTO , 3L );
377384
378385 // 후보 2명 반환
379- when (matchingRepository .findMatchingCandidates (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 )))
386+ when (matchingRepository .findMatchingCandidatesDsl (1L , TypeResult .PHOTO , Gender .MAN , 1L , PageRequest .of (0 , 1 ), excludedIds ))
380387 .thenReturn (List .of (p1 , p2 ));
381388
382389 // when
0 commit comments