Skip to content

Commit

Permalink
Feat: 사용자는 허브 태그를 확인할 수 있다.
Browse files Browse the repository at this point in the history
Feat: 사용자는 허브 태그를 확인할 수 있다.
  • Loading branch information
hseong3243 authored Apr 11, 2024
2 parents 862c619 + c17ebef commit 3754776
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.seong.shoutlink.domain.hub.service;

import com.seong.shoutlink.domain.hub.Hub;
import com.seong.shoutlink.domain.hub.service.response.FindHubResponse;
import com.seong.shoutlink.domain.hub.service.result.HubTagResponse;
import com.seong.shoutlink.domain.hub.service.result.HubTagResult;
import java.util.List;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class HubMapper {

public static FindHubResponse findHubResponse(Hub hub, List<HubTagResult> tags) {
List<HubTagResponse> hubTagResponses = tags.stream()
.map(HubMapper::hubTagResponse)
.toList();
return new FindHubResponse(
hub.getHubId(),
hub.getMasterId(),
hub.getName(),
hub.getDescription(),
hub.isPrivate(),
hubTagResponses
);
}

private static HubTagResponse hubTagResponse(HubTagResult result) {
return new HubTagResponse(result.tagId(), result.name());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
import com.seong.shoutlink.domain.hub.service.request.FindHubCommand;
import com.seong.shoutlink.domain.hub.service.response.CreateHubResponse;
import com.seong.shoutlink.domain.hub.service.response.FindHubDetailResponse;
import com.seong.shoutlink.domain.hub.service.response.FindHubResponse;
import com.seong.shoutlink.domain.hub.service.response.FindHubsCommand;
import com.seong.shoutlink.domain.hub.service.response.FindHubsResponse;
import com.seong.shoutlink.domain.hub.service.result.HubPaginationResult;
import com.seong.shoutlink.domain.hub.service.result.HubTagResult;
import com.seong.shoutlink.domain.member.Member;
import com.seong.shoutlink.domain.member.service.MemberRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -25,6 +31,7 @@ public class HubService {

private final MemberRepository memberRepository;
private final HubRepository hubRepository;
private final HubTagReader hubTagReader;
private final EventPublisher eventPublisher;

@Transactional
Expand All @@ -44,7 +51,16 @@ private Member getMember(Long memberId) {
@Transactional(readOnly = true)
public FindHubsResponse findHubs(FindHubsCommand command) {
HubPaginationResult result = hubRepository.findHubs(command.page(), command.size());
return FindHubsResponse.of(result.hubs(), result.totalElements(), result.hasNext());
List<Hub> hubs = result.hubs();
List<HubTagResult> tagsInHubs = hubTagReader.findTagsInHubs(hubs);

Map<Hub, List<HubTagResult>> tagsCollectedByHub = tagsInHubs.stream()
.collect(Collectors.groupingBy(HubTagResult::hub));
List<FindHubResponse> findHubs = hubs.stream()
.map(hub -> HubMapper.findHubResponse(hub,
tagsCollectedByHub.getOrDefault(hub, new ArrayList<>())))
.toList();
return new FindHubsResponse(findHubs, result.totalElements(), result.hasNext());
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.seong.shoutlink.domain.hub.service;

import com.seong.shoutlink.domain.hub.Hub;
import com.seong.shoutlink.domain.hub.service.result.HubTagResult;
import java.util.List;

public interface HubTagReader {

List<HubTagResult> findTagsInHubs(List<Hub> hubs);
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package com.seong.shoutlink.domain.hub.service.response;

import com.seong.shoutlink.domain.hub.Hub;
import com.seong.shoutlink.domain.hub.service.result.HubTagResponse;
import java.util.List;

public record FindHubResponse(
Long hubId,
Long masterId,
String name,
String description,
boolean isPrivate) {
boolean isPrivate,
List<HubTagResponse> tags) {

public static FindHubResponse from(Hub hub) {
return new FindHubResponse(
hub.getHubId(),
hub.getMasterId(),
hub.getName(),
hub.getDescription(),
hub.isPrivate());
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package com.seong.shoutlink.domain.hub.service.response;

import com.seong.shoutlink.domain.hub.Hub;
import java.util.List;

public record FindHubsResponse(List<FindHubResponse> hubs, long totalElements, boolean hasNext) {

public static FindHubsResponse of(List<Hub> hubs, long totalElements, boolean hasNext) {
List<FindHubResponse> content = hubs.stream()
.map(FindHubResponse::from)
.toList();
return new FindHubsResponse(content, totalElements, hasNext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.seong.shoutlink.domain.hub.service.result;

public record HubTagResponse(Long tagId, String name) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.seong.shoutlink.domain.hub.service.result;

import com.seong.shoutlink.domain.hub.Hub;

public record HubTagResult(Long tagId, String name, Hub hub) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.seong.shoutlink.domain.tag.repository;

import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -15,4 +16,8 @@ public interface TagJpaRepository extends JpaRepository<TagEntity, Long> {
+ " order by t.createdAt"
+ " limit 1")
Optional<TagEntity> findLatestTagByHubId(Long hubId);

@Query("select t from HubTagEntity t"
+ " where t.hubId in :hubIds")
List<HubTagEntity> findTagsInHubIds(@Param("hubIds") List<Long> hubIds);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.seong.shoutlink.domain.tag.repository;

import com.seong.shoutlink.domain.hub.Hub;
import com.seong.shoutlink.domain.hub.service.HubTagReader;
import com.seong.shoutlink.domain.hub.service.result.HubTagResult;
import com.seong.shoutlink.domain.tag.HubTag;
import com.seong.shoutlink.domain.tag.Tag;
import com.seong.shoutlink.domain.tag.service.TagRepository;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class TagRepositoryImpl implements TagRepository {
public class TagRepositoryImpl implements TagRepository, HubTagReader {

private final TagJpaRepository tagJpaRepository;

Expand All @@ -35,4 +39,19 @@ public Optional<Tag> findLatestTagByHub(Hub hub) {
return tagJpaRepository.findLatestTagByHubId(hub.getHubId())
.map(TagEntity::toDomain);
}

@Override
public List<HubTagResult> findTagsInHubs(List<Hub> hubs) {
Map<Long, Hub> hubMap = hubs.stream()
.collect(Collectors.toMap(Hub::getHubId, hub -> hub));
List<Long> hubIds = hubMap.keySet().stream()
.toList();
List<HubTagEntity> hubTagEntities = tagJpaRepository.findTagsInHubIds(hubIds);
return hubTagEntities.stream()
.map(hubTagEntity -> {
Hub hub = hubMap.get(hubTagEntity.getHubId());
return new HubTagResult(hubTagEntity.getTagId(), hubTagEntity.getName(), hub);
})
.toList();
}
}
43 changes: 31 additions & 12 deletions src/main/resources/static/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ <h5 id="_request_3_http_request"><a class="link" href="#_request_3_http_request"
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /api/link-bundles HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU3LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU3LCJyb2xlIjoiUk9MRV9VU0VSIn0.WPdbP1PJPZPAOYlaQTNqdGUIMSsq9XkwtxL9QVOw6TY
Content-Length: 57
Host: localhost:8080

Expand Down Expand Up @@ -833,7 +833,7 @@ <h5 id="_request_4_http_request"><a class="link" href="#_request_4_http_request"
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/link-bundles HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU4LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU4LCJyb2xlIjoiUk9MRV9VU0VSIn0.U_KvGd4gAIMEdv_8zR0tPTJ0d64wh1Bpsw1OKWxExh0
Host: localhost:8080</code></pre>
</div>
</div>
Expand Down Expand Up @@ -938,7 +938,7 @@ <h5 id="_request_5_http_request"><a class="link" href="#_request_5_http_request"
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /api/hubs/1/link-bundles HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU4LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU4LCJyb2xlIjoiUk9MRV9VU0VSIn0.U_KvGd4gAIMEdv_8zR0tPTJ0d64wh1Bpsw1OKWxExh0
Content-Length: 53
Host: localhost:8080

Expand Down Expand Up @@ -1076,7 +1076,7 @@ <h5 id="_request_6_http_request"><a class="link" href="#_request_6_http_request"
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/hubs/1/link-bundles HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU4LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU4LCJyb2xlIjoiUk9MRV9VU0VSIn0.U_KvGd4gAIMEdv_8zR0tPTJ0d64wh1Bpsw1OKWxExh0
Host: localhost:8080</code></pre>
</div>
</div>
Expand Down Expand Up @@ -1204,7 +1204,7 @@ <h5 id="_request_7_http_request"><a class="link" href="#_request_7_http_request"
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /api/links HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU3LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU3LCJyb2xlIjoiUk9MRV9VU0VSIn0.WPdbP1PJPZPAOYlaQTNqdGUIMSsq9XkwtxL9QVOw6TY
Content-Length: 100
Host: localhost:8080

Expand Down Expand Up @@ -1326,7 +1326,7 @@ <h5 id="_request_8_http_request"><a class="link" href="#_request_8_http_request"
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/links?linkBundleId=1&amp;page=0&amp;size=10 HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU3LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU3LCJyb2xlIjoiUk9MRV9VU0VSIn0.WPdbP1PJPZPAOYlaQTNqdGUIMSsq9XkwtxL9QVOw6TY
Host: localhost:8080</code></pre>
</div>
</div>
Expand Down Expand Up @@ -1393,7 +1393,7 @@ <h5 id="_request_9_http_request"><a class="link" href="#_request_9_http_request"
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /api/hubs/1/links HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU3LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU3LCJyb2xlIjoiUk9MRV9VU0VSIn0.WPdbP1PJPZPAOYlaQTNqdGUIMSsq9XkwtxL9QVOw6TY
Content-Length: 69
Host: localhost:8080

Expand Down Expand Up @@ -1537,7 +1537,7 @@ <h5 id="_request_10_http_request"><a class="link" href="#_request_10_http_reques
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">GET /api/hubs/1/links?linkBundleId=1&amp;page=0&amp;size=20 HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU3LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU3LCJyb2xlIjoiUk9MRV9VU0VSIn0.WPdbP1PJPZPAOYlaQTNqdGUIMSsq9XkwtxL9QVOw6TY
Host: localhost:8080</code></pre>
</div>
</div>
Expand Down Expand Up @@ -1706,7 +1706,7 @@ <h5 id="_request_11_http_request"><a class="link" href="#_request_11_http_reques
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /api/hubs HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzExNjMxOTM1LCJzdWIiOiIxIiwiZXhwIjoxNzExNjM1NTM1LCJyb2xlIjoiUk9MRV9VU0VSIn0.0V1ZcvM6a1HPSMSbXJ2jVNijQKWJnCNVJrWnQNXG788
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0IiwiaWF0IjoxNzEyODE0MTU3LCJzdWIiOiIxIiwiZXhwIjoxNzEyODE3NzU3LCJyb2xlIjoiUk9MRV9VU0VSIn0.WPdbP1PJPZPAOYlaQTNqdGUIMSsq9XkwtxL9QVOw6TY
Content-Length: 88
Host: localhost:8080

Expand Down Expand Up @@ -1870,15 +1870,19 @@ <h5 id="_response_11_http_response"><a class="link" href="#_response_11_http_res
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 189
Content-Length: 259

{
"hubs" : [ {
"hubId" : 1,
"masterId" : 1,
"name" : "허브 이름",
"description" : "설명",
"isPrivate" : false
"isPrivate" : false,
"tags" : [ {
"tagId" : 1,
"name" : "태그1"
} ]
} ],
"totalElements" : 1,
"hasNext" : false
Expand Down Expand Up @@ -1933,6 +1937,21 @@ <h5 id="_response_11_response_fields"><a class="link" href="#_response_11_respon
<td class="tableblock halign-left valign-top"><p class="tableblock">허브 공개 여부</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>hubs[].tags[]</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Array</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">허브 태그 목록</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>hubs[].tags[].tagId</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">허브 태그 ID</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>hubs[].tags[].name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">허브 태그 이름</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>totalElements</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">총 요소 개수</p></td>
Expand Down Expand Up @@ -2441,7 +2460,7 @@ <h5 id="_response_16_response_fields"><a class="link" href="#_response_16_respon
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2024-03-28 22:19:59 +0900
Last updated 2024-03-28 22:32:59 +0900
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.seong.shoutlink.domain.hub.service.response.FindHubDetailResponse;
import com.seong.shoutlink.domain.hub.service.response.FindHubResponse;
import com.seong.shoutlink.domain.hub.service.response.FindHubsResponse;
import com.seong.shoutlink.domain.hub.service.result.HubTagResponse;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -70,7 +71,9 @@ void findHubs() throws Exception {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("page", "0");
params.add("size", "0");
FindHubResponse content = new FindHubResponse(1L, 1L, "허브 이름", "설명", false);
HubTagResponse tagResponse = new HubTagResponse(1L, "태그1");
FindHubResponse content = new FindHubResponse(1L, 1L, "허브 이름", "설명", false,
List.of(tagResponse));
FindHubsResponse response = new FindHubsResponse(List.of(content), 1, false);

given(hubService.findHubs(any())).willReturn(response);
Expand All @@ -96,6 +99,12 @@ void findHubs() throws Exception {
.description("허브 설명"),
fieldWithPath("hubs[].isPrivate").type(JsonFieldType.BOOLEAN)
.description("허브 공개 여부"),
fieldWithPath("hubs[].tags[]").type(JsonFieldType.ARRAY)
.description("허브 태그 목록"),
fieldWithPath("hubs[].tags[].tagId").type(JsonFieldType.NUMBER)
.description("허브 태그 ID"),
fieldWithPath("hubs[].tags[].name").type(JsonFieldType.STRING)
.description("허브 태그 이름"),
fieldWithPath("totalElements").type(JsonFieldType.NUMBER)
.description("총 요소 개수"),
fieldWithPath("hasNext").type(JsonFieldType.BOOLEAN).description("다음 페이지 여부")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.seong.shoutlink.fixture;
package com.seong.shoutlink.domain.hub.repository;

import com.seong.shoutlink.domain.hub.Hub;
import com.seong.shoutlink.domain.hub.HubWithMaster;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.seong.shoutlink.domain.hub.repository;

import com.seong.shoutlink.domain.hub.Hub;
import com.seong.shoutlink.domain.hub.service.HubTagReader;
import com.seong.shoutlink.domain.hub.service.result.HubTagResult;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class StubHubTagReader implements HubTagReader {

private final Map<Long, HubTagResult> hubTagMap = new HashMap<>();

public void stub(HubTagResult... results) {
for (HubTagResult result : results) {
hubTagMap.put((long) (hubTagMap.size()+1), result);
}
}

@Override
public List<HubTagResult> findTagsInHubs(List<Hub> hubs) {
return hubTagMap.values().stream().toList();
}
}
Loading

0 comments on commit 3754776

Please sign in to comment.