Skip to content

Commit

Permalink
test: 커리큘럼의 모든 키워드 조회 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Nov 1, 2023
1 parent 11e87dc commit bc41ccb
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,42 @@ void findDoneQuizCountByMemberId() {
});
}

@Test
@DisplayName("커리큘럼 ID에 해당하는 모든 키워드들을 조회할 수 있다")
void findAllByCurriculumId() {
//given
final Long session1 = createSessionWithCurriculumId(1L);
final Long session2 = createSessionWithCurriculumId(1L);

final Keyword parent1 = createKeywordParent(
Keyword.createKeyword("자바", "자바에 대한 설명", 1, 1, session1, null));
createKeywordChildren(
Keyword.createKeyword("List", "List에 대한 설명", 1, 1, session1, parent1));
createKeywordChildren(
Keyword.createKeyword("List", "List에 대한 설명", 1, 1, session1, parent1));

createKeywordParent(
Keyword.createKeyword("자바", "자바에 대한 설명", 1, 1, session2, null));

//when
final List<Keyword> keywords = keywordRepository.findAllByCurriculumId(1L);

//then
assertThat(keywords).hasSize(4);
}

private Long createSession() {
Session session = new Session("테스트 세션");
sessionRepository.save(session);
return session.getId();
}

private Long createSessionWithCurriculumId(final Long curriculumId) {
Session session = new Session(curriculumId, "테스트 세션");
sessionRepository.save(session);
return session.getId();
}

private Keyword createKeywordParent(final Keyword keyword) {
return keywordRepository.save(keyword);
}
Expand Down

0 comments on commit bc41ccb

Please sign in to comment.