-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 이미 서포터 리뷰를 작성했으면 예외 반환하도록 함 * test: Repository 테스트 추가 * test: 테스트에 em.flush와 em.clear 추가 * style: 예외 메세지 이름 변경 * feat: Feedback 을 하면 isReviewed 속성이 true 가 되도록 변경
- Loading branch information
Showing
6 changed files
with
104 additions
and
15 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
65 changes: 65 additions & 0 deletions
65
...src/test/java/touch/baton/domain/feedback/repository/SupporterFeedbackRepositoryTest.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,65 @@ | ||
package touch.baton.domain.feedback.repository; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import touch.baton.config.RepositoryTestConfig; | ||
import touch.baton.domain.feedback.SupporterFeedback; | ||
import touch.baton.domain.member.Member; | ||
import touch.baton.domain.runner.Runner; | ||
import touch.baton.domain.runnerpost.RunnerPost; | ||
import touch.baton.domain.supporter.Supporter; | ||
import touch.baton.fixture.domain.MemberFixture; | ||
import touch.baton.fixture.domain.RunnerFixture; | ||
import touch.baton.fixture.domain.RunnerPostFixture; | ||
import touch.baton.fixture.domain.SupporterFeedbackFixture; | ||
import touch.baton.fixture.domain.SupporterFixture; | ||
import touch.baton.fixture.vo.DeadlineFixture; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static org.assertj.core.api.SoftAssertions.assertSoftly; | ||
|
||
class SupporterFeedbackRepositoryTest extends RepositoryTestConfig { | ||
|
||
@Autowired | ||
private EntityManager em; | ||
@Autowired | ||
private SupporterFeedbackRepository supporterFeedbackRepository; | ||
|
||
@DisplayName("러너 게시글 아이디와 서포터 아이디로 서포터 피드백 존재 유무를 확인할 수 있다.") | ||
@Test | ||
void existsByRunnerPostIdAndSupporterId() { | ||
// given | ||
final Member runnerMember = MemberFixture.createEthan(); | ||
em.persist(runnerMember); | ||
final Runner runner = RunnerFixture.createRunner(runnerMember); | ||
em.persist(runner); | ||
|
||
final Member reviewedSupporterMember = MemberFixture.createHyena(); | ||
em.persist(reviewedSupporterMember); | ||
final Supporter reviewedSupporter = SupporterFixture.create(reviewedSupporterMember); | ||
em.persist(reviewedSupporter); | ||
|
||
final RunnerPost runnerPost = RunnerPostFixture.create(runner, DeadlineFixture.deadline(LocalDateTime.now().plusDays(10))); | ||
em.persist(runnerPost); | ||
|
||
final SupporterFeedback supporterFeedback = SupporterFeedbackFixture.create(reviewedSupporter, runner, runnerPost); | ||
em.persist(supporterFeedback); | ||
|
||
final Member notReviewedSupporterMember = MemberFixture.createHyena(); | ||
em.persist(notReviewedSupporterMember); | ||
final Supporter notReviewedSupporter = SupporterFixture.create(notReviewedSupporterMember); | ||
em.persist(notReviewedSupporter); | ||
|
||
em.flush(); | ||
em.close(); | ||
|
||
// when, then | ||
assertSoftly(softly -> { | ||
softly.assertThat(supporterFeedbackRepository.existsByRunnerPostIdAndSupporterId(runnerPost.getId(), reviewedSupporter.getId())).isTrue(); | ||
softly.assertThat(supporterFeedbackRepository.existsByRunnerPostIdAndSupporterId(runnerPost.getId(), notReviewedSupporter.getId())).isFalse(); | ||
}); | ||
} | ||
} |
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