Skip to content

Commit c554e89

Browse files
committed
test: 프로필 생성 실패 시 에러 전파 X 테스트 추가
1 parent f4a2877 commit c554e89

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/test/java/com/techfork/domain/recommendation/listener/PersonalizedProfileGeneratedEventListenerTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.mockito.BDDMockito.given;
1919
import static org.mockito.Mockito.mock;
2020
import static org.mockito.Mockito.verify;
21+
import static org.mockito.Mockito.verifyNoInteractions;
2122

2223
@ExtendWith(MockitoExtension.class)
2324
class PersonalizedProfileGeneratedEventListenerTest {
@@ -61,6 +62,20 @@ void handle_RecommendationFailureDoesNotPropagateException() {
6162
verify(recommendationService).generateRecommendationsForUser(user);
6263
}
6364

65+
@Test
66+
@DisplayName("사용자 조회가 실패해도 예외를 전파하지 않고 추천을 시도하지 않는다")
67+
void handle_UserLookupFailureDoesNotPropagateExceptionAndSkipsRecommendation() {
68+
Long userId = 3L;
69+
given(userLookupService.getUserOrThrow(userId))
70+
.willThrow(new RuntimeException("user lookup failure"));
71+
72+
assertThatCode(() -> listener.handle(new PersonalizedProfileGeneratedEvent(userId)))
73+
.doesNotThrowAnyException();
74+
75+
verify(userLookupService).getUserOrThrow(userId);
76+
verifyNoInteractions(recommendationService);
77+
}
78+
6479
@Test
6580
@DisplayName("프로필 생성 이벤트 리스너는 AFTER_COMMIT 단계에서 실행된다")
6681
void listenerMethod_RunsAfterCommit() throws NoSuchMethodException {

0 commit comments

Comments
 (0)