Skip to content

Commit 56534b1

Browse files
committed
refactor(VolunteerDetailAccessValidator): elseThrow 반환이 없는 것을 anyMatch로 수정
1 parent 7cbabba commit 56534b1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/com/somemore/facade/validator/VolunteerDetailAccessValidatorImpl.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ public class VolunteerDetailAccessValidatorImpl implements VolunteerDetailAccess
2323
* 해당 모집글들에 연관된 봉사자들의 ID 목록에 타겟 봉사자 ID가 포함되어 있는지 검증.
2424
*/
2525
public void validateByCenterId(UUID centerId, UUID targetVolunteerId) {
26-
List<Long> allNotCompletedIdsByCenterId = recruitBoardQueryUseCase.getNotCompletedIdsByCenterIds(centerId);
26+
List<Long> notCompletedIdsByCenterIds = recruitBoardQueryUseCase.getNotCompletedIdsByCenterIds(centerId);
2727

28-
List<UUID> volunteerIdsByRecruitIds = volunteerApplyQueryUseCase.getVolunteerIdsByRecruitIds(allNotCompletedIdsByCenterId);
28+
List<UUID> volunteerIdsByRecruitIds = volunteerApplyQueryUseCase.getVolunteerIdsByRecruitIds(notCompletedIdsByCenterIds);
2929

30-
volunteerIdsByRecruitIds.stream()
31-
.filter(volunteerId -> volunteerId.equals(targetVolunteerId))
32-
.findAny()
33-
.orElseThrow(() -> new BadRequestException(UNAUTHORIZED_VOLUNTEER_DETAIL));
30+
if (volunteerIdsByRecruitIds.stream()
31+
.anyMatch(volunteerId -> volunteerId.equals(targetVolunteerId))) {
32+
return;
33+
}
34+
35+
throw new BadRequestException(UNAUTHORIZED_VOLUNTEER_DETAIL);
3436
}
3537
}

0 commit comments

Comments
 (0)