-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...d/src/test/java/com/gaebaljip/exceed/infrastructure/adapter/in/EmitterControllerTest.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,38 @@ | ||
package com.gaebaljip.exceed.infrastructure.adapter.in; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; | ||
|
||
import com.gaebaljip.exceed.common.ControllerTest; | ||
import com.gaebaljip.exceed.common.WithMockUser; | ||
import com.gaebaljip.exceed.infrastructure.sse.adapter.in.EmitterController; | ||
import com.gaebaljip.exceed.infrastructure.sse.application.port.in.ConnectEmitterUseCase; | ||
|
||
@WebMvcTest(EmitterController.class) | ||
public class EmitterControllerTest extends ControllerTest { | ||
|
||
@MockBean private ConnectEmitterUseCase connectEmitterUseCase; | ||
|
||
@Test | ||
@WithMockUser(memberId = 1L) | ||
void when_connect_expected_success() throws Exception { | ||
|
||
// given | ||
given(connectEmitterUseCase.execute(any(), any())).willReturn(new SseEmitter()); | ||
|
||
// when | ||
ResultActions resultActions = | ||
mockMvc.perform(get("/api/emitter/connect").contentType("text/event-stream")); | ||
|
||
// then | ||
resultActions.andExpect(status().isOk()); | ||
} | ||
} |