Skip to content

Commit

Permalink
[Week9][Chap3] Feat : 공통 인터페이스 적용 (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
dionisos198 committed Nov 20, 2023
1 parent 2a8b3c5 commit e030e31
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Team,Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Member> 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);
}


}

0 comments on commit e030e31

Please sign in to comment.