-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: NotificationController 테스트 (#453)
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...presentation/src/test/java/com/depromeet/notification/api/NotificationControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.depromeet.notification.api; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
import com.depromeet.config.ControllerTestConfig; | ||
import com.depromeet.config.mock.WithCustomMockMember; | ||
import com.depromeet.notification.facade.NotificationFacade; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
@WebMvcTest(NotificationController.class) | ||
public class NotificationControllerTest extends ControllerTestConfig { | ||
@MockBean NotificationFacade notificationFacade; | ||
|
||
@Test | ||
@WithCustomMockMember | ||
public void 알림을_조회합니다() throws Exception { | ||
mockMvc.perform(get("/notification")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.code").value("NOTIFICATION_1")) | ||
.andExpect(jsonPath("$.message").value("알림 조회에 성공하였습니다")) | ||
.andDo(print()); | ||
} | ||
|
||
@Test | ||
@WithCustomMockMember | ||
public void 알림을_확인처리합니다() throws Exception { | ||
mockMvc.perform(patch("/notification/read")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.code").value("NOTIFICATION_2")) | ||
.andExpect(jsonPath("$.message").value("알림을 읽음 처리하였습니다")) | ||
.andDo(print()); | ||
} | ||
|
||
@Test | ||
@WithCustomMockMember | ||
public void 미확인_알림_개수를_조회합니다() throws Exception { | ||
mockMvc.perform(get("/notification/count")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.code").value("NOTIFICATION_3")) | ||
.andExpect(jsonPath("$.message").value("읽지 않은 알림 개수 조회에 성공하였습니다")) | ||
.andDo(print()); | ||
} | ||
} |