Skip to content

Commit

Permalink
test/#359: EmitterControllerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
LJH098 committed Jul 10, 2024
1 parent d7938a2 commit 44fc422
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.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());
}
}

0 comments on commit 44fc422

Please sign in to comment.