From a664b7f864191f4eb6ef1d21bd8464978f8ceae2 Mon Sep 17 00:00:00 2001 From: thguss Date: Wed, 29 May 2024 23:00:28 +0900 Subject: [PATCH] =?UTF-8?q?[TEST]=20=EC=B6=9C=EC=84=9D=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=AC=EA=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiaryCommandServiceIntegrationTest.java | 7 ++++ .../service/MemberServiceIntegrationTest.java | 41 +++++++++---------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/smeem-api/src/test/java/com/smeem/diary/service/DiaryCommandServiceIntegrationTest.java b/smeem-api/src/test/java/com/smeem/diary/service/DiaryCommandServiceIntegrationTest.java index 802ba317..81caf6e4 100644 --- a/smeem-api/src/test/java/com/smeem/diary/service/DiaryCommandServiceIntegrationTest.java +++ b/smeem-api/src/test/java/com/smeem/diary/service/DiaryCommandServiceIntegrationTest.java @@ -44,6 +44,13 @@ void setUp() { diaryRepository.deleteAllInBatch(); member = memberRepository.save(MemberFixture.member().build()); } + + @AfterEach + void tearDown() { + diaryRepository.deleteAllInBatch(); + memberRepository.deleteAllInBatch(); + } + @Test @Transactional @DisplayName("[성공] 오늘 일기를 작성하지 않은 회원은 일기를 작성할 수 있고, 연속 일기 작성 수가 업데이트된다.") diff --git a/smeem-api/src/test/java/com/smeem/member/service/MemberServiceIntegrationTest.java b/smeem-api/src/test/java/com/smeem/member/service/MemberServiceIntegrationTest.java index 65bd18cb..3a582194 100644 --- a/smeem-api/src/test/java/com/smeem/member/service/MemberServiceIntegrationTest.java +++ b/smeem-api/src/test/java/com/smeem/member/service/MemberServiceIntegrationTest.java @@ -10,10 +10,7 @@ import com.smeem.support.fixture.MemberFixture; import jakarta.transaction.Transactional; import lombok.val; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.Autowired; import static org.assertj.core.api.Assertions.*; @@ -44,23 +41,23 @@ public void setUp() { member = memberRepository.save(MemberFixture.member().build()); } -// @Test -// @Transactional -// @DisplayName("[성공] 회원이 방문하면 하루에 한 번 이력이 남는다.") -// void createMemberVisitedHistoryTodayAtOnce() { -// // given -// val request = new MemberVisitUpdateRequest(member.getId()); -// -// int initCount = visitCounter.countByMember(member); -// assertThat(initCount).isEqualTo(0); -// -// // when -// memberService.updateMemberVisit(request); -// memberService.updateMemberVisit(request); -// -// // then -// int visitCount = visitCounter.countByMember(member); -// assertThat(visitCount).isEqualTo(1); -// } + @Test + @Transactional + @DisplayName("[성공] 회원이 방문하면 하루에 한 번 이력이 남는다.") + void createMemberVisitedHistoryTodayAtOnce() { + // given + val request = new MemberVisitUpdateRequest(member.getId()); + + int initCount = visitCounter.countByMember(member); + assertThat(initCount).isEqualTo(0); + + // when + memberService.updateMemberVisit(request); + memberService.updateMemberVisit(request); + + // then + int visitCount = visitCounter.countByMember(member); + assertThat(visitCount).isEqualTo(1); + } } }