From e5ca18a61608cbfe8763038101c95bd0252c7a83 Mon Sep 17 00:00:00 2001 From: seokjin8678 Date: Mon, 8 Apr 2024 17:44:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20AbstractMemoryRepository=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - existsById, deleteById, count --- .../artist/repository/MemoryArtistRepository.java | 10 ---------- .../repository/MemoryBookmarkRepository.java | 5 ----- .../repository/MemoryFestivalRepository.java | 10 ---------- .../member/repository/MemoryMemberRepository.java | 10 ---------- .../school/repository/MemorySchoolRepository.java | 10 ---------- .../stage/repository/MemoryStageRepository.java | 4 ---- .../festago/support/AbstractMemoryRepository.java | 12 ++++++++++++ 7 files changed, 12 insertions(+), 49 deletions(-) diff --git a/backend/src/test/java/com/festago/artist/repository/MemoryArtistRepository.java b/backend/src/test/java/com/festago/artist/repository/MemoryArtistRepository.java index 9cc92e360..1eba7e9c6 100644 --- a/backend/src/test/java/com/festago/artist/repository/MemoryArtistRepository.java +++ b/backend/src/test/java/com/festago/artist/repository/MemoryArtistRepository.java @@ -7,11 +7,6 @@ public class MemoryArtistRepository extends AbstractMemoryRepository implements ArtistRepository { - @Override - public void deleteById(Long artistId) { - memory.remove(artistId); - } - @Override public long countByIdIn(List artistIds) { return memory.values().stream() @@ -25,9 +20,4 @@ public List findByIdIn(Collection artistIds) { .filter(artist -> artistIds.contains(artist.getId())) .toList(); } - - @Override - public boolean existsById(Long id) { - return memory.containsKey(id); - } } diff --git a/backend/src/test/java/com/festago/bookmark/repository/MemoryBookmarkRepository.java b/backend/src/test/java/com/festago/bookmark/repository/MemoryBookmarkRepository.java index 64a0d6c78..d4922eca2 100644 --- a/backend/src/test/java/com/festago/bookmark/repository/MemoryBookmarkRepository.java +++ b/backend/src/test/java/com/festago/bookmark/repository/MemoryBookmarkRepository.java @@ -8,11 +8,6 @@ public class MemoryBookmarkRepository extends AbstractMemoryRepository implements BookmarkRepository { - @Override - public void deleteById(Long id) { - memory.remove(id); - } - @Override public boolean existsByBookmarkTypeAndMemberIdAndResourceId( BookmarkType bookmarkType, diff --git a/backend/src/test/java/com/festago/festival/repository/MemoryFestivalRepository.java b/backend/src/test/java/com/festago/festival/repository/MemoryFestivalRepository.java index 7f4f37b8b..9fd2ab317 100644 --- a/backend/src/test/java/com/festago/festival/repository/MemoryFestivalRepository.java +++ b/backend/src/test/java/com/festago/festival/repository/MemoryFestivalRepository.java @@ -11,14 +11,4 @@ public boolean existsBySchoolId(Long schoolId) { return memory.values().stream() .anyMatch(festival -> Objects.equals(festival.getSchool().getId(), schoolId)); } - - @Override - public void deleteById(Long festivalId) { - memory.remove(festivalId); - } - - @Override - public boolean existsById(Long festivalId) { - return memory.containsKey(festivalId); - } } diff --git a/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java b/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java index d235f137e..390854743 100644 --- a/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java +++ b/backend/src/test/java/com/festago/member/repository/MemoryMemberRepository.java @@ -13,16 +13,6 @@ public void delete(Member member) { memory.remove(member.getId()); } - @Override - public boolean existsById(Long id) { - return memory.containsKey(id); - } - - @Override - public long count() { - return memory.size(); - } - @Override public Optional findBySocialIdAndSocialType(String socialId, SocialType socialType) { return memory.values().stream() diff --git a/backend/src/test/java/com/festago/school/repository/MemorySchoolRepository.java b/backend/src/test/java/com/festago/school/repository/MemorySchoolRepository.java index 2d301641d..fa638a2a1 100644 --- a/backend/src/test/java/com/festago/school/repository/MemorySchoolRepository.java +++ b/backend/src/test/java/com/festago/school/repository/MemorySchoolRepository.java @@ -6,16 +6,6 @@ public class MemorySchoolRepository extends AbstractMemoryRepository implements SchoolRepository { - @Override - public void deleteById(Long id) { - memory.remove(id); - } - - @Override - public boolean existsById(Long id) { - return memory.get(id) != null; - } - @Override public boolean existsByDomain(String domain) { return memory.values().stream() diff --git a/backend/src/test/java/com/festago/stage/repository/MemoryStageRepository.java b/backend/src/test/java/com/festago/stage/repository/MemoryStageRepository.java index 1f67fc8d2..66067201e 100644 --- a/backend/src/test/java/com/festago/stage/repository/MemoryStageRepository.java +++ b/backend/src/test/java/com/festago/stage/repository/MemoryStageRepository.java @@ -8,10 +8,6 @@ public class MemoryStageRepository extends AbstractMemoryRepository implements StageRepository { - @Override - public void deleteById(Long stageId) { - memory.remove(stageId); - } @Override public void flush() { diff --git a/backend/src/test/java/com/festago/support/AbstractMemoryRepository.java b/backend/src/test/java/com/festago/support/AbstractMemoryRepository.java index 166ed95c6..f55b7ae14 100644 --- a/backend/src/test/java/com/festago/support/AbstractMemoryRepository.java +++ b/backend/src/test/java/com/festago/support/AbstractMemoryRepository.java @@ -31,4 +31,16 @@ final public T save(T entity) { final public Optional findById(Long id) { return Optional.ofNullable(memory.get(id)); } + + final public boolean existsById(Long id) { + return memory.containsKey(id); + } + + final public void deleteById(Long id) { + memory.remove(id); + } + + final public long count() { + return memory.size(); + } }