Skip to content

Commit

Permalink
feat: 허브 링크 묶음 목록 조회 api 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
hseong3243 committed Feb 18, 2024
1 parent aed13ce commit 811ced9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.seong.shoutlink.domain.linkbundle.controller;

import com.seong.shoutlink.domain.auth.LoginUser;
import com.seong.shoutlink.domain.auth.NullableUser;
import com.seong.shoutlink.domain.linkbundle.controller.request.CreateLinkBundleRequest;
import com.seong.shoutlink.domain.linkbundle.service.LinkBundleService;
import com.seong.shoutlink.domain.linkbundle.service.request.CreateHubLinkBundleCommand;
import com.seong.shoutlink.domain.linkbundle.service.request.FindHubLinkBundlesCommand;
import com.seong.shoutlink.domain.linkbundle.service.request.FindLinkBundlesCommand;
import com.seong.shoutlink.domain.linkbundle.service.response.CreateLinkBundleCommand;
import com.seong.shoutlink.domain.linkbundle.service.response.CreateLinkBundleResponse;
Expand Down Expand Up @@ -59,4 +61,13 @@ public ResponseEntity<CreateLinkBundleResponse> createHubLinkBundle(
request.isDefault()));
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}

@GetMapping("/hubs/{hubId}/link-bundles")
public ResponseEntity<FindLinkBundlesResponse> findHubLinkBundles(
@NullableUser Long nullableMemberId,
@PathVariable("hubId") Long hubId) {
FindLinkBundlesResponse response = linkBundleService.findHubLinkBundles(
new FindHubLinkBundlesCommand(hubId, nullableMemberId));
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,39 @@ void createHubLinkBundle() throws Exception {
)
));
}

@Test
@DisplayName("성공: 허브 링크 묶음 목록 조회 api 호출 시")
void findHubLinkBundles() throws Exception {
//given
long hubId = 1L;
FindLinkBundleResponse content = new FindLinkBundleResponse(1L, "기본", false);
FindLinkBundlesResponse response = new FindLinkBundlesResponse(List.of(content));

given(linkBundleService.findHubLinkBundles(any())).willReturn(response);

//when
ResultActions resultActions = mockMvc.perform(get("/api/hubs/{hubId}/link-bundles", hubId)
.header(AUTHORIZATION, bearerAccessToken));

//then
resultActions.andExpect(status().isOk())
.andDo(restDocs.document(
pathParameters(
parameterWithName("hubId").description("허브 ID")
),
requestHeaders(
headerWithName(AUTHORIZATION).description("액세스 토큰").optional()
),
responseFields(
fieldWithPath("linkBundles").type(JsonFieldType.ARRAY).description("링크 묶음 목록"),
fieldWithPath("linkBundles[].linkBundleId").type(JsonFieldType.NUMBER)
.description("링크 묶음 ID"),
fieldWithPath("linkBundles[].description").type(JsonFieldType.STRING)
.description("링크 묶음 설명"),
fieldWithPath("linkBundles[].isDefault").type(JsonFieldType.BOOLEAN)
.description("기본 여부")
)
));
}
}

0 comments on commit 811ced9

Please sign in to comment.