Skip to content

Commit

Permalink
test: 알림 이벤트 리스너 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim0914 committed Jan 18, 2024
1 parent d2defe0 commit 3e8c068
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.official.pium.notification.application;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import com.official.pium.IntegrationTest;
import com.official.pium.petPlant.event.notification.NotificationEvent;
import java.util.UUID;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.ApplicationEventPublisher;

@SuppressWarnings("NonAsciiCharacters")
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
class NotificationEventListenerTest extends IntegrationTest {

@Autowired
private ApplicationEventPublisher eventPublisher;

@MockBean
private NotificationEventListener notificationEventListener;

@Test
void 알림_이벤트가_발행되면_알림_이벤트_리스너가_동작한다() {
NotificationEvent event = NotificationEvent.builder()
.deviceToken(UUID.randomUUID().toString())
.title("알림 이벤트")
.body("발송")
.build();

eventPublisher.publishEvent(event);

verify(notificationEventListener, times(1)).handleNotificationEvent(event);
}
}

0 comments on commit 3e8c068

Please sign in to comment.