-
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.
Merge branch 'dev/be' into refactor/767-template-controller-test-mock
- Loading branch information
Showing
6 changed files
with
84 additions
and
16 deletions.
There are no files selected for viewing
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
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
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
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
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
40 changes: 40 additions & 0 deletions
40
backend/src/test/java/codezap/tag/controller/TagControllerTest.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,40 @@ | ||
package codezap.tag.controller; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.context.annotation.Import; | ||
|
||
import codezap.global.MockMvcTest; | ||
import codezap.tag.domain.Tag; | ||
import codezap.tag.dto.response.FindAllTagsResponse; | ||
import codezap.tag.dto.response.FindTagResponse; | ||
|
||
@Import(TagController.class) | ||
class TagControllerTest extends MockMvcTest { | ||
|
||
@Test | ||
@DisplayName("모든 태그 조회 성공") | ||
void getTags() throws Exception { | ||
// given | ||
FindAllTagsResponse findAllTagsResponse = new FindAllTagsResponse(List.of( | ||
FindTagResponse.from(new Tag(1L, "tag1")), | ||
FindTagResponse.from(new Tag(2L, "tag2")) | ||
)); | ||
|
||
when(tagService.findAllByMemberId(any())).thenReturn(findAllTagsResponse); | ||
|
||
// when & then | ||
mvc.perform(get("/tags") | ||
.param("memberId", "1")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.tags.size()").value(2)); | ||
} | ||
} |