-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from Funssion-SWM/qna
fix: 질문이 달린 메모를 삭제시 질문조회시 메모 id가 없어서 발생하는 오류 해결
- Loading branch information
Showing
8 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
src/test/java/Funssion/Inforum/domain/post/qna/repository/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,47 @@ | ||
package Funssion.Inforum.domain.post.qna.repository; | ||
|
||
import Funssion.Inforum.domain.post.qna.domain.Question; | ||
import Funssion.Inforum.domain.score.Rank; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
public class QuestionRepositoryTest { | ||
@Autowired | ||
QuestionRepository questionRepository; | ||
|
||
Question memoQuestion; | ||
Long targetMemoId = 1L; | ||
Long memoIdWhichDoNotHaveQuestion = 2L; | ||
@BeforeEach | ||
void init(){ | ||
memoQuestion = questionRepository.createQuestion(Question.builder() | ||
.authorId(1L) | ||
.authorName("test") | ||
.authorImagePath("test") | ||
.title("java") | ||
.text("{\"content\":\"java is good?\"}") | ||
.description("java is ...") | ||
.tags(Collections.emptyList()) | ||
.memoId(targetMemoId) | ||
.rank(Rank.BRONZE_5.toString()) | ||
.build()); | ||
} | ||
|
||
@Test | ||
@DisplayName("메모와 연관된 질문인지 아닌지 확인합니다") | ||
void isMemoQuestionOrNot(){ | ||
assertThat(questionRepository.getQuestionIdByMemoId(targetMemoId).isPresent()).isEqualTo(true); | ||
assertThat(questionRepository.getQuestionIdByMemoId(memoIdWhichDoNotHaveQuestion).isEmpty()).isEqualTo(true); | ||
|
||
} | ||
} |