From 0ca9445c3b2b65c40e209598434e093ad425a593 Mon Sep 17 00:00:00 2001 From: JunHyeongChoi Date: Sat, 26 Oct 2024 21:06:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20ci=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MemberRepositoryTest.java | 94 ------------------- 1 file changed, 94 deletions(-) delete mode 100644 src/test/java/com/potatocake/everymoment/repository/MemberRepositoryTest.java diff --git a/src/test/java/com/potatocake/everymoment/repository/MemberRepositoryTest.java b/src/test/java/com/potatocake/everymoment/repository/MemberRepositoryTest.java deleted file mode 100644 index 2e72d9e..0000000 --- a/src/test/java/com/potatocake/everymoment/repository/MemberRepositoryTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.potatocake.everymoment.repository; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.potatocake.everymoment.entity.Member; -import java.util.Optional; -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; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.ScrollPosition; -import org.springframework.data.domain.Window; - -@DataJpaTest -class MemberRepositoryTest { - - @Autowired - private MemberRepository memberRepository; - - @Test - @DisplayName("회원 번호로 회원을 성공적으로 조회한다.") - void should_FindMemberByNumber_When_NumberExists() { - // given - Long number = 1234L; - memberRepository.save(Member.builder() - .number(number) - .nickname("testUser") - .build()); - - // when - Optional foundMember = memberRepository.findByNumber(number); - - // then - assertThat(foundMember).isPresent(); - assertThat(foundMember.get().getNumber()).isEqualTo(number); - } - - @Test - @DisplayName("회원 번호가 존재하는지 확인한다.") - void should_ReturnTrue_When_NumberExists() { - // given - Long number = 1234L; - memberRepository.save(Member.builder() - .number(number) - .nickname("testUser") - .build()); - - // when - boolean exists = memberRepository.existsByNumber(number); - - // then - assertThat(exists).isTrue(); - } - - @Test - @DisplayName("닉네임을 포함하여 스크롤 방식으로 회원 목록을 조회한다.") - void should_FindByNicknameContaining_When_ValidScrollPosition() { - // given - String nickname = "test"; - Long number = 1234L; - for (int i = 1; i <= 15; i++) { - memberRepository.save(Member.builder() - .nickname(nickname + i) - .number(number + i) - .build()); - } - - // when - ScrollPosition scrollPosition = ScrollPosition.offset(); - PageRequest pageRequest = PageRequest.of(0, 10); - Window window = memberRepository.findByNicknameContaining(nickname, scrollPosition, pageRequest); - - // then - assertThat(window).isNotNull(); - assertThat(window.getContent().size()).isEqualTo(10); - assertThat(window.hasNext()).isTrue(); // 총 15개 중 10개를 조회했으므로 다음 페이지 존재 - } - - @Test - @DisplayName("닉네임으로 검색 결과가 없다면 빈 결과를 반환한다.") - void should_ReturnEmpty_When_NoMatchingNickname() { - // given - ScrollPosition scrollPosition = ScrollPosition.offset(); - PageRequest pageRequest = PageRequest.of(0, 10); - - // when - Window window = memberRepository.findByNicknameContaining("nonexistent", scrollPosition, pageRequest); - - // then - assertThat(window.getContent()).isEmpty(); - } - -}