|
31 | 31 | import com.ajou.hertz.common.auth.JwtTokenProvider;
|
32 | 32 | import com.ajou.hertz.common.auth.UserPrincipal;
|
33 | 33 | import com.ajou.hertz.common.config.SecurityConfig;
|
| 34 | +import com.ajou.hertz.domain.instrument.service.InstrumentQueryService; |
34 | 35 | import com.ajou.hertz.domain.user.constant.Gender;
|
35 | 36 | import com.ajou.hertz.domain.user.constant.RoleType;
|
36 | 37 | import com.ajou.hertz.domain.user.controller.UserController;
|
@@ -61,6 +62,9 @@ class UserControllerTest {
|
61 | 62 | @MockBean
|
62 | 63 | private UserQueryService userQueryService;
|
63 | 64 |
|
| 65 | + @MockBean |
| 66 | + private InstrumentQueryService instrumentQueryService; |
| 67 | + |
64 | 68 | private final MockMvc mvc;
|
65 | 69 |
|
66 | 70 | private final ObjectMapper objectMapper;
|
@@ -295,6 +299,31 @@ public void securitySetUp() throws Exception {
|
295 | 299 | verifyEveryMocksShouldHaveNoMoreInteractions();
|
296 | 300 | }
|
297 | 301 |
|
| 302 | + @Test |
| 303 | + void 주어진_id로_판매자의_판매자_정보를_조회한다() throws Exception { |
| 304 | + // given |
| 305 | + long userId = 1L; |
| 306 | + UserDetails testUser = createTestUser(userId); |
| 307 | + UserDto expectedResult = createUserDto(userId); |
| 308 | + int sellingCount = 2; |
| 309 | + int soldCount = 3; |
| 310 | + given(userQueryService.getDtoById(userId)).willReturn(expectedResult); |
| 311 | + given(instrumentQueryService.countSellingItemsBySellerId(userId)).willReturn(sellingCount); |
| 312 | + given(instrumentQueryService.countSoldItemsBySellerId(userId)).willReturn(soldCount); |
| 313 | + |
| 314 | + // when & then |
| 315 | + mvc.perform( |
| 316 | + get("/api/users/{userId}/seller", userId) |
| 317 | + .header(API_VERSION_HEADER_NAME, 1) |
| 318 | + .with(user(testUser)) |
| 319 | + ) |
| 320 | + .andExpect(status().isOk()); |
| 321 | + then(userQueryService).should().getDtoById(userId); |
| 322 | + then(instrumentQueryService).should().countSellingItemsBySellerId(userId); |
| 323 | + then(instrumentQueryService).should().countSoldItemsBySellerId(userId); |
| 324 | + verifyEveryMocksShouldHaveNoMoreInteractions(); |
| 325 | + } |
| 326 | + |
298 | 327 | private void verifyEveryMocksShouldHaveNoMoreInteractions() {
|
299 | 328 | then(userCommandService).shouldHaveNoMoreInteractions();
|
300 | 329 | then(userQueryService).shouldHaveNoMoreInteractions();
|
|
0 commit comments