-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: QuestionRepository 질문 리스트 조회 테스트 #3
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/test/java/com/nexters/covid/letter/domain/QuestionRepositoryTest.java
This file contains 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,30 @@ | ||
package com.nexters.covid.letter.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
|
||
@DataJpaTest | ||
public class QuestionRepositoryTest { | ||
|
||
@Autowired | ||
QuestionRepository questionRepository; | ||
|
||
@Test | ||
@DisplayName("[QuestionRepository] 선택한 옵션에 따른 질문과 공통 질문 조회 테스트") | ||
void findQuestionByOptionTest() { | ||
List<Question> questions = questionRepository.findQuestionsBySendOptionIdEqualsOrSendOptionIdEquals(1L, 3L); | ||
|
||
List<Long> sendOptionIds = questions.stream() | ||
.map(q -> q.getSendOption().getId()) | ||
.collect(Collectors.toList()); | ||
|
||
assertThat(sendOptionIds.contains(1L)).isTrue(); | ||
assertThat(sendOptionIds.contains(3L)).isTrue(); | ||
} | ||
} |
This file contains 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