-
Notifications
You must be signed in to change notification settings - Fork 3
[BE] 마인드맵 내부 역량 태그 조회 fix #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
w0uldy0u
merged 5 commits into
dev
from
fix/#367/fix_get_all_competency_types_of_mindmap
Feb 15, 2026
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca4f894
refactor: EpisodeId lombok 활용
w0uldy0u a741ace
fix: 네이티브 쿼리 활용
w0uldy0u 77f0961
test: 테스트 작성 및 리팩토링
w0uldy0u a9ba404
Merge branch 'dev' into fix/#367/fix_get_all_competency_types_of_mindmap
w0uldy0u e122eb9
Merge branch 'dev' into fix/#367/fix_get_all_competency_types_of_mindmap
w0uldy0u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
136 changes: 136 additions & 0 deletions
136
backend/api/src/test/java/com/yat2/episode/episode/EpisodeRepositoryTest.java
This file contains hidden or 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,136 @@ | ||
| package com.yat2.episode.episode; | ||
|
|
||
| import jakarta.persistence.EntityManager; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; | ||
| import org.springframework.test.context.ActiveProfiles; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.Set; | ||
| import java.util.UUID; | ||
|
|
||
| import com.yat2.episode.episode.dto.EpisodeDetail; | ||
| import com.yat2.episode.mindmap.Mindmap; | ||
| import com.yat2.episode.utils.AbstractRepositoryTest; | ||
|
|
||
| import static com.yat2.episode.utils.TestEntityFactory.createEpisode; | ||
| import static com.yat2.episode.utils.TestEntityFactory.createEpisodeStar; | ||
| import static com.yat2.episode.utils.TestEntityFactory.createMindmap; | ||
| import static com.yat2.episode.utils.TestEntityFactory.createUser; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @DataJpaTest | ||
| @ActiveProfiles("test") | ||
| @DisplayName("EpisodeRepository 통합 테스트") | ||
| class EpisodeRepositoryTest extends AbstractRepositoryTest { | ||
|
|
||
| @Autowired | ||
| EpisodeRepository episodeRepository; | ||
| @Autowired | ||
| EntityManager em; | ||
|
|
||
| @Test | ||
| @DisplayName("mindmapId로 nodeId 목록 조회") | ||
| void findNodeIdsByMindmapId() { | ||
| Mindmap m1 = createMindmap("mm-1"); | ||
| Mindmap mOther = createMindmap("mm-other"); | ||
| em.persist(m1); | ||
| em.persist(mOther); | ||
|
|
||
| UUID node1 = UUID.randomUUID(); | ||
| UUID node2 = UUID.randomUUID(); | ||
|
|
||
| em.persist(createEpisode(node1, m1.getId(), "c1")); | ||
| em.persist(createEpisode(node2, m1.getId(), "c2")); | ||
| em.persist(createEpisode(UUID.randomUUID(), mOther.getId(), "other")); | ||
|
|
||
| flushAndClear(); | ||
|
|
||
| List<UUID> ids = episodeRepository.findNodeIdsByMindmapId(m1.getId()); | ||
|
|
||
| assertThat(ids).containsExactlyInAnyOrder(node1, node2); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("상세 리스트 조회") | ||
| void findDetailsByMindmapIdAndUserId() { | ||
| Mindmap m1 = createMindmap("mm-1"); | ||
| em.persist(m1); | ||
|
|
||
| long userId = 100L; | ||
| em.persist(createUser(userId)); | ||
|
|
||
| UUID node1 = UUID.randomUUID(); | ||
| UUID node2 = UUID.randomUUID(); | ||
|
|
||
| em.persist(createEpisode(node1, m1.getId(), "content1")); | ||
| em.persist(createEpisode(node2, m1.getId(), "content2")); | ||
|
|
||
| em.persist(createEpisodeStar(node1, userId, Set.of(1, 2))); | ||
| em.persist(createEpisodeStar(node2, userId, Set.of(2, 3))); | ||
|
|
||
| flushAndClear(); | ||
|
|
||
| List<EpisodeDetail> details = episodeRepository.findDetailsByMindmapIdAndUserId(m1.getId(), userId); | ||
|
|
||
| assertThat(details).hasSize(2); | ||
| assertThat(details).extracting(EpisodeDetail::nodeId).containsExactlyInAnyOrder(node1, node2); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("에피소드 상세 조회") | ||
| void findDetail() { | ||
| Mindmap m1 = createMindmap("mm-1"); | ||
| em.persist(m1); | ||
|
|
||
| long userId = 100L; | ||
| em.persist(createUser(userId)); | ||
|
|
||
| UUID node = UUID.randomUUID(); | ||
| em.persist(createEpisode(node, m1.getId(), "content")); | ||
| em.persist(createEpisodeStar(node, userId, Set.of(7, 8))); | ||
|
|
||
| flushAndClear(); | ||
|
|
||
| Optional<EpisodeDetail> opt = episodeRepository.findDetail(node, userId); | ||
|
|
||
| assertThat(opt).isPresent(); | ||
| assertThat(opt.get().nodeId()).isEqualTo(node); | ||
| assertThat(opt.get().competencyTypeIds()).containsExactlyInAnyOrder(7, 8); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Mindmap에 속한 competencyTypeIds 중복 제거 조회") | ||
| void findCompetencyTypesByMindmapId() { | ||
| Mindmap m1 = createMindmap("mm-1"); | ||
| em.persist(m1); | ||
|
|
||
| long userA = 100L; | ||
| long userB = 200L; | ||
| em.persist(createUser(userA)); | ||
| em.persist(createUser(userB)); | ||
|
|
||
| UUID node1 = UUID.randomUUID(); | ||
| UUID node2 = UUID.randomUUID(); | ||
|
|
||
| em.persist(createEpisode(node1, m1.getId(), "c1")); | ||
| em.persist(createEpisode(node2, m1.getId(), "c2")); | ||
|
|
||
| em.persist(createEpisodeStar(node1, userA, Set.of(1, 2, 3))); | ||
| em.persist(createEpisodeStar(node2, userB, Set.of(2, 3, 4))); | ||
|
|
||
| flushAndClear(); | ||
|
|
||
| List<Integer> ids = episodeRepository.findCompetencyTypesByMindmapId(m1.getId()); | ||
|
|
||
| assertThat(ids).containsExactlyInAnyOrder(1, 2, 3, 4); | ||
| } | ||
|
|
||
| private void flushAndClear() { | ||
| em.flush(); | ||
| em.clear(); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.