From e030e314b04c0c2b337d9fb489668a23d0bce3e5 Mon Sep 17 00:00:00 2001 From: Jinu Yi Date: Mon, 20 Nov 2023 20:31:10 +0900 Subject: [PATCH] =?UTF-8?q?[Week9][Chap3]=20Feat=20:=20=EA=B3=B5=ED=86=B5?= =?UTF-8?q?=20=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20(#108)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datajpa/repository/TeamRepository.java" | 8 ++++++ .../repository/MemberRepositoryTest.java" | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 "\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/main/java/study/datajpa/repository/TeamRepository.java" diff --git "a/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/main/java/study/datajpa/repository/TeamRepository.java" "b/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/main/java/study/datajpa/repository/TeamRepository.java" new file mode 100644 index 00000000..8c84ee15 --- /dev/null +++ "b/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/main/java/study/datajpa/repository/TeamRepository.java" @@ -0,0 +1,8 @@ +package study.datajpa.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import study.datajpa.entity.Team; + +public interface TeamRepository extends JpaRepository { + +} diff --git "a/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/test/java/study/datajpa/repository/MemberRepositoryTest.java" "b/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/test/java/study/datajpa/repository/MemberRepositoryTest.java" index b263bce3..0cb38c9d 100644 --- "a/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/test/java/study/datajpa/repository/MemberRepositoryTest.java" +++ "b/\354\235\264\354\247\204\354\232\260/spring_data_jpa_jinu/data-jpa/src/test/java/study/datajpa/repository/MemberRepositoryTest.java" @@ -8,6 +8,8 @@ import org.springframework.transaction.annotation.Transactional; import study.datajpa.entity.Member; +import java.util.List; + import static org.junit.jupiter.api.Assertions.*; @SpringBootTest @Transactional @@ -34,4 +36,29 @@ public void testMember(){ } + @Test + public void basicCRUD() { + Member member1 = new Member("member1"); + Member member2 = new Member("member2"); + memberRepository.save(member1); + memberRepository.save(member2); + + Member findMember1 = memberRepository.findById(member1.getId()).get(); + Member findMember2 = memberRepository.findById(member2.getId()).get(); + Assertions.assertThat(findMember1).isEqualTo(member1); + Assertions.assertThat(findMember2).isEqualTo(member2); + + List all = memberRepository.findAll(); + Assertions.assertThat(all.size()).isEqualTo(2); + + long count = memberRepository.count(); + Assertions.assertThat(count).isEqualTo(2); + + memberRepository.delete(member1); + memberRepository.delete(member2); + long deletedCount = memberRepository.count(); + Assertions.assertThat(deletedCount).isEqualTo(0); + } + + } \ No newline at end of file