Skip to content

Commit

Permalink
test: 친구 목록 조회 Controller 테스트 코드 추가 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Sep 28, 2023
1 parent 3969e38 commit 45598c9
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.project.mapdagu.domain.friend.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.project.mapdagu.domain.friend.dto.response.FriendGetAllResponseDto;
import com.project.mapdagu.domain.friend.dto.response.FriendSearchResponseDto;
import com.project.mapdagu.domain.friend.service.FriendService;
import com.project.mapdagu.utils.TestUserArgumentResolver;
Expand Down Expand Up @@ -97,4 +98,24 @@ void setUp() {
result.andExpect(status().isNoContent());
verify(friendService, times(1)).deleteFriend(anyString(), anyLong());
}

@Test
void 친구_목록_조회() throws Exception {
//given
PageRequest pageable = PageRequest.of(0, 2);
List<FriendGetAllResponseDto> dtos = new ArrayList<>();
dtos.add(new FriendGetAllResponseDto(1L, 2, "test1", 5));
dtos.add(new FriendGetAllResponseDto(2L, 4, "test2", 9));
Slice<FriendGetAllResponseDto> response = new SliceImpl<>(dtos, pageable, false);

//when
given(friendService.getFriends(anyString(), any())).willReturn(response);
ResultActions result = mockMvc.perform(
get("/api/friends/me")
);

//then
result.andExpect(status().isOk());
verify(friendService, times(1)).getFriends(anyString(), any());
}
}

0 comments on commit 45598c9

Please sign in to comment.