From 16edc399a6769a5007345305c39584e6fc16a489 Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Sun, 8 Dec 2024 16:22:46 +0900 Subject: [PATCH 1/6] =?UTF-8?q?refactor:=20=EC=84=A0=ED=98=B8=20=EB=AC=BC?= =?UTF-8?q?=ED=92=88=20=EC=98=81=EC=86=8D=EC=84=B1=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=96=B4=20=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4?= =?UTF-8?q?=ED=99=94=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존 Jpa 단일 레포지토리에서 인터페이스, 구현체 Jpa 레포지토리로 분할 - 분할에 따른 의존성 경로 수 --- .../repository/{ => center}/CenterJpaRepository.java | 2 +- .../repository/{ => center}/CenterRepository.java | 2 +- .../repository/{ => center}/CenterRepositoryImpl.java | 2 +- .../{ => preferitem}/PreferItemRepository.java | 8 +++----- .../service/command/CreatePreferItemService.java | 2 +- .../service/command/UpdateCenterProfileService.java | 2 +- .../center/service/query/CenterQueryService.java | 2 +- .../center/service/query/CenterSignService.java | 2 +- .../center/service/query/PreferItemQueryService.java | 2 +- .../center/repository/CenterRepositoryTest.java | 1 + .../center/repository/PreferItemRepositoryTest.java | 6 +++++- .../service/command/CreatePreferItemServiceTest.java | 10 +++++++--- .../command/UpdateCenterProfileServiceTest.java | 2 +- .../center/service/query/CenterQueryServiceTest.java | 8 ++++---- .../center/service/query/CenterSignServiceTest.java | 2 +- .../service/query/PreferItemQueryServiceTest.java | 2 +- .../service/board/CommunityBoardQueryServiceTest.java | 2 +- .../service/CancelInterestCenterServiceTest.java | 2 +- .../service/InterestCenterQueryServiceTest.java | 2 +- .../service/RegisterInterestCenterServiceTest.java | 2 +- .../note/repository/NoteRepositoryImplTest.java | 2 +- .../somemore/note/service/NoteQueryServiceTest.java | 2 +- .../note/service/SendNoteToCenterServiceTest.java | 2 +- .../repository/RecruitBoardRepositoryImplTest.java | 2 +- .../service/query/RecruitBoardQueryServiceTest.java | 2 +- .../review/repository/ReviewRepositoryImplTest.java | 2 +- .../review/service/ReviewQueryServiceTest.java | 2 +- 27 files changed, 42 insertions(+), 35 deletions(-) rename src/main/java/com/somemore/center/repository/{ => center}/CenterJpaRepository.java (89%) rename src/main/java/com/somemore/center/repository/{ => center}/CenterRepository.java (93%) rename src/main/java/com/somemore/center/repository/{ => center}/CenterRepositoryImpl.java (98%) rename src/main/java/com/somemore/center/repository/{ => preferitem}/PreferItemRepository.java (53%) diff --git a/src/main/java/com/somemore/center/repository/CenterJpaRepository.java b/src/main/java/com/somemore/center/repository/center/CenterJpaRepository.java similarity index 89% rename from src/main/java/com/somemore/center/repository/CenterJpaRepository.java rename to src/main/java/com/somemore/center/repository/center/CenterJpaRepository.java index 9d344598f..8601f2305 100644 --- a/src/main/java/com/somemore/center/repository/CenterJpaRepository.java +++ b/src/main/java/com/somemore/center/repository/center/CenterJpaRepository.java @@ -1,4 +1,4 @@ -package com.somemore.center.repository; +package com.somemore.center.repository.center; import com.somemore.center.domain.Center; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/com/somemore/center/repository/CenterRepository.java b/src/main/java/com/somemore/center/repository/center/CenterRepository.java similarity index 93% rename from src/main/java/com/somemore/center/repository/CenterRepository.java rename to src/main/java/com/somemore/center/repository/center/CenterRepository.java index 386700099..a0798bec3 100644 --- a/src/main/java/com/somemore/center/repository/CenterRepository.java +++ b/src/main/java/com/somemore/center/repository/center/CenterRepository.java @@ -1,4 +1,4 @@ -package com.somemore.center.repository; +package com.somemore.center.repository.center; import com.somemore.center.domain.Center; import com.somemore.center.repository.mapper.CenterOverviewInfo; diff --git a/src/main/java/com/somemore/center/repository/CenterRepositoryImpl.java b/src/main/java/com/somemore/center/repository/center/CenterRepositoryImpl.java similarity index 98% rename from src/main/java/com/somemore/center/repository/CenterRepositoryImpl.java rename to src/main/java/com/somemore/center/repository/center/CenterRepositoryImpl.java index ac1ff10a6..fdde55c54 100644 --- a/src/main/java/com/somemore/center/repository/CenterRepositoryImpl.java +++ b/src/main/java/com/somemore/center/repository/center/CenterRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.somemore.center.repository; +package com.somemore.center.repository.center; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; diff --git a/src/main/java/com/somemore/center/repository/PreferItemRepository.java b/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java similarity index 53% rename from src/main/java/com/somemore/center/repository/PreferItemRepository.java rename to src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java index 8f3f4eecb..73d938fa8 100644 --- a/src/main/java/com/somemore/center/repository/PreferItemRepository.java +++ b/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java @@ -1,15 +1,13 @@ -package com.somemore.center.repository; +package com.somemore.center.repository.preferitem; import com.somemore.center.domain.PreferItem; -import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.List; import java.util.UUID; @Repository -public interface PreferItemRepository extends JpaRepository { - +public interface PreferItemRepository { + void save(PreferItem preferItem); List findByCenterId(UUID centerId); - } diff --git a/src/main/java/com/somemore/center/service/command/CreatePreferItemService.java b/src/main/java/com/somemore/center/service/command/CreatePreferItemService.java index d9565837c..e1bb20a2b 100644 --- a/src/main/java/com/somemore/center/service/command/CreatePreferItemService.java +++ b/src/main/java/com/somemore/center/service/command/CreatePreferItemService.java @@ -3,7 +3,7 @@ import com.somemore.center.domain.PreferItem; import com.somemore.center.dto.request.PreferItemCreateRequestDto; import com.somemore.center.dto.response.PreferItemCreateResponseDto; -import com.somemore.center.repository.PreferItemRepository; +import com.somemore.center.repository.preferitem.PreferItemRepository; import com.somemore.center.usecase.command.CreatePreferItemUseCase; import com.somemore.center.usecase.query.CenterQueryUseCase; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/somemore/center/service/command/UpdateCenterProfileService.java b/src/main/java/com/somemore/center/service/command/UpdateCenterProfileService.java index cdd35e4d6..48e3d1de7 100644 --- a/src/main/java/com/somemore/center/service/command/UpdateCenterProfileService.java +++ b/src/main/java/com/somemore/center/service/command/UpdateCenterProfileService.java @@ -2,7 +2,7 @@ import com.somemore.center.domain.Center; import com.somemore.center.dto.request.CenterProfileUpdateRequestDto; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.center.usecase.command.UpdateCenterProfileUseCase; import com.somemore.global.exception.BadRequestException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/somemore/center/service/query/CenterQueryService.java b/src/main/java/com/somemore/center/service/query/CenterQueryService.java index 81a19f21b..71c89dae4 100644 --- a/src/main/java/com/somemore/center/service/query/CenterQueryService.java +++ b/src/main/java/com/somemore/center/service/query/CenterQueryService.java @@ -4,7 +4,7 @@ import com.somemore.center.repository.mapper.CenterOverviewInfo; import com.somemore.center.dto.response.CenterProfileResponseDto; import com.somemore.center.dto.response.PreferItemResponseDto; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.center.usecase.query.CenterQueryUseCase; import com.somemore.center.usecase.query.PreferItemQueryUseCase; import com.somemore.global.exception.BadRequestException; diff --git a/src/main/java/com/somemore/center/service/query/CenterSignService.java b/src/main/java/com/somemore/center/service/query/CenterSignService.java index 56df896dd..0c71a334d 100644 --- a/src/main/java/com/somemore/center/service/query/CenterSignService.java +++ b/src/main/java/com/somemore/center/service/query/CenterSignService.java @@ -1,6 +1,6 @@ package com.somemore.center.service.query; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.center.usecase.query.CenterSignUseCase; import com.somemore.global.exception.BadRequestException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/somemore/center/service/query/PreferItemQueryService.java b/src/main/java/com/somemore/center/service/query/PreferItemQueryService.java index 46074e0a5..b46c0a445 100644 --- a/src/main/java/com/somemore/center/service/query/PreferItemQueryService.java +++ b/src/main/java/com/somemore/center/service/query/PreferItemQueryService.java @@ -2,7 +2,7 @@ import com.somemore.center.domain.PreferItem; import com.somemore.center.dto.response.PreferItemResponseDto; -import com.somemore.center.repository.PreferItemRepository; +import com.somemore.center.repository.preferitem.PreferItemRepository; import com.somemore.center.usecase.query.PreferItemQueryUseCase; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/test/java/com/somemore/center/repository/CenterRepositoryTest.java b/src/test/java/com/somemore/center/repository/CenterRepositoryTest.java index 3168e2374..f504ac50d 100644 --- a/src/test/java/com/somemore/center/repository/CenterRepositoryTest.java +++ b/src/test/java/com/somemore/center/repository/CenterRepositoryTest.java @@ -2,6 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; +import com.somemore.center.repository.center.CenterRepository; import jakarta.transaction.Transactional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/somemore/center/repository/PreferItemRepositoryTest.java b/src/test/java/com/somemore/center/repository/PreferItemRepositoryTest.java index cf7fcc9d5..eec39c197 100644 --- a/src/test/java/com/somemore/center/repository/PreferItemRepositoryTest.java +++ b/src/test/java/com/somemore/center/repository/PreferItemRepositoryTest.java @@ -2,6 +2,8 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.PreferItem; +import com.somemore.center.repository.preferitem.PreferItemJpaRepository; +import com.somemore.center.repository.preferitem.PreferItemRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,8 @@ class PreferItemRepositoryTest extends IntegrationTestSupport { @Autowired private PreferItemRepository preferItemRepository; + @Autowired + private PreferItemJpaRepository preferItemJpaRepository; private UUID centerId = UUID.fromString("1a1a1a1a-1a1a-1a1a-1a1a-1a1a1a1a1a1"); private UUID centerId1 = UUID.fromString("1a1a1a1a-1a1a-1a1a-1a1a-1a1a1a1a1a1"); @@ -32,7 +36,7 @@ void findByCenterId() { PreferItem preferItem1 = PreferItem.create(centerId1, "간식"); PreferItem preferItem2 = PreferItem.create(centerId2, "수건"); PreferItem preferItem3 = PreferItem.create(centerId3, "식재료"); - preferItemRepository.saveAll(List.of(preferItem, preferItem1, preferItem2, preferItem3)); + preferItemJpaRepository.saveAll(List.of(preferItem, preferItem1, preferItem2, preferItem3)); //when List preferItems = preferItemRepository.findByCenterId(UUID.fromString("1a1a1a1a-1a1a-1a1a-1a1a-1a1a1a1a1a2")); diff --git a/src/test/java/com/somemore/center/service/command/CreatePreferItemServiceTest.java b/src/test/java/com/somemore/center/service/command/CreatePreferItemServiceTest.java index ca56042d5..ec875bff9 100644 --- a/src/test/java/com/somemore/center/service/command/CreatePreferItemServiceTest.java +++ b/src/test/java/com/somemore/center/service/command/CreatePreferItemServiceTest.java @@ -4,8 +4,9 @@ import com.somemore.center.domain.Center; import com.somemore.center.domain.PreferItem; import com.somemore.center.dto.request.PreferItemCreateRequestDto; -import com.somemore.center.repository.CenterRepository; -import com.somemore.center.repository.PreferItemRepository; +import com.somemore.center.repository.center.CenterRepository; +import com.somemore.center.repository.preferitem.PreferItemJpaRepository; +import com.somemore.center.repository.preferitem.PreferItemRepository; import com.somemore.global.exception.BadRequestException; import jakarta.transaction.Transactional; import org.junit.jupiter.api.DisplayName; @@ -26,6 +27,9 @@ class CreatePreferItemServiceTest extends IntegrationTestSupport { @Autowired private PreferItemRepository preferItemRepository; + @Autowired + private PreferItemJpaRepository preferItemJpaRepository; + @Autowired private CenterRepository centerRepository; @@ -45,7 +49,7 @@ void createPreferItem() { createPreferItemService.createPreferItem(center.getId(), requestDto); //then - PreferItem savedItem = preferItemRepository.findAll().stream() + PreferItem savedItem = preferItemJpaRepository.findAll().stream() .filter(item -> item.getCenterId().equals(center.getId()) && item.getItemName().equals(itemName)) .findFirst() diff --git a/src/test/java/com/somemore/center/service/command/UpdateCenterProfileServiceTest.java b/src/test/java/com/somemore/center/service/command/UpdateCenterProfileServiceTest.java index a477f83d0..18a4322a8 100644 --- a/src/test/java/com/somemore/center/service/command/UpdateCenterProfileServiceTest.java +++ b/src/test/java/com/somemore/center/service/command/UpdateCenterProfileServiceTest.java @@ -3,7 +3,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; import com.somemore.center.dto.request.CenterProfileUpdateRequestDto; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import org.assertj.core.api.ThrowableAssert; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/com/somemore/center/service/query/CenterQueryServiceTest.java b/src/test/java/com/somemore/center/service/query/CenterQueryServiceTest.java index d21a9f8a4..a95b94ce5 100644 --- a/src/test/java/com/somemore/center/service/query/CenterQueryServiceTest.java +++ b/src/test/java/com/somemore/center/service/query/CenterQueryServiceTest.java @@ -5,9 +5,9 @@ import com.somemore.center.domain.PreferItem; import com.somemore.center.repository.mapper.CenterOverviewInfo; import com.somemore.center.dto.response.CenterProfileResponseDto; -import com.somemore.center.repository.CenterJpaRepository; -import com.somemore.center.repository.CenterRepository; -import com.somemore.center.repository.PreferItemRepository; +import com.somemore.center.repository.center.CenterJpaRepository; +import com.somemore.center.repository.center.CenterRepository; +import com.somemore.center.repository.preferitem.PreferItemJpaRepository; import com.somemore.global.exception.BadRequestException; import com.somemore.global.exception.ExceptionMessage; import jakarta.transaction.Transactional; @@ -34,7 +34,7 @@ class CenterQueryServiceTest extends IntegrationTestSupport { private CenterJpaRepository centerJpaRepository; @Autowired - private PreferItemRepository preferItemRepository; + private PreferItemJpaRepository preferItemRepository; @DisplayName("기관 Id로 기관 프로필을 조회할 수 있다. (service)") @Test diff --git a/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java b/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java index 44cf91624..622aec38e 100644 --- a/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java +++ b/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/somemore/center/service/query/PreferItemQueryServiceTest.java b/src/test/java/com/somemore/center/service/query/PreferItemQueryServiceTest.java index 4f7475f93..fe865312d 100644 --- a/src/test/java/com/somemore/center/service/query/PreferItemQueryServiceTest.java +++ b/src/test/java/com/somemore/center/service/query/PreferItemQueryServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.center.domain.PreferItem; import com.somemore.center.dto.response.PreferItemResponseDto; -import com.somemore.center.repository.PreferItemRepository; +import com.somemore.center.repository.preferitem.PreferItemRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; diff --git a/src/test/java/com/somemore/community/service/board/CommunityBoardQueryServiceTest.java b/src/test/java/com/somemore/community/service/board/CommunityBoardQueryServiceTest.java index abd61b790..44c05fe98 100644 --- a/src/test/java/com/somemore/community/service/board/CommunityBoardQueryServiceTest.java +++ b/src/test/java/com/somemore/community/service/board/CommunityBoardQueryServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.auth.oauth.OAuthProvider; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.community.domain.CommunityBoard; import com.somemore.community.dto.response.CommunityBoardDetailResponseDto; import com.somemore.community.dto.response.CommunityBoardResponseDto; diff --git a/src/test/java/com/somemore/interestcenter/service/CancelInterestCenterServiceTest.java b/src/test/java/com/somemore/interestcenter/service/CancelInterestCenterServiceTest.java index e89946ffc..b756865fd 100644 --- a/src/test/java/com/somemore/interestcenter/service/CancelInterestCenterServiceTest.java +++ b/src/test/java/com/somemore/interestcenter/service/CancelInterestCenterServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import com.somemore.interestcenter.domain.InterestCenter; import com.somemore.interestcenter.dto.request.RegisterInterestCenterRequestDto; diff --git a/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java b/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java index 98aef2aa0..7a439fae2 100644 --- a/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java +++ b/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterJpaRepository; +import com.somemore.center.repository.center.CenterJpaRepository; import com.somemore.interestcenter.domain.InterestCenter; import com.somemore.interestcenter.dto.response.InterestCentersResponseDto; import com.somemore.interestcenter.repository.InterestCenterJpaRepository; diff --git a/src/test/java/com/somemore/interestcenter/service/RegisterInterestCenterServiceTest.java b/src/test/java/com/somemore/interestcenter/service/RegisterInterestCenterServiceTest.java index 4546f5dd7..a979c37d5 100644 --- a/src/test/java/com/somemore/interestcenter/service/RegisterInterestCenterServiceTest.java +++ b/src/test/java/com/somemore/interestcenter/service/RegisterInterestCenterServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import com.somemore.global.exception.DuplicateException; import com.somemore.interestcenter.dto.request.RegisterInterestCenterRequestDto; diff --git a/src/test/java/com/somemore/note/repository/NoteRepositoryImplTest.java b/src/test/java/com/somemore/note/repository/NoteRepositoryImplTest.java index 54dc00a33..4ff096cff 100644 --- a/src/test/java/com/somemore/note/repository/NoteRepositoryImplTest.java +++ b/src/test/java/com/somemore/note/repository/NoteRepositoryImplTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterJpaRepository; +import com.somemore.center.repository.center.CenterJpaRepository; import com.somemore.note.domain.Note; import com.somemore.note.repository.mapper.NoteDetailViewForCenter; import com.somemore.note.repository.mapper.NoteDetailViewForVolunteer; diff --git a/src/test/java/com/somemore/note/service/NoteQueryServiceTest.java b/src/test/java/com/somemore/note/service/NoteQueryServiceTest.java index 2c6c8696f..43418f685 100644 --- a/src/test/java/com/somemore/note/service/NoteQueryServiceTest.java +++ b/src/test/java/com/somemore/note/service/NoteQueryServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterJpaRepository; +import com.somemore.center.repository.center.CenterJpaRepository; import com.somemore.global.exception.NoSuchElementException; import com.somemore.note.domain.Note; import com.somemore.note.repository.NoteRepository; diff --git a/src/test/java/com/somemore/note/service/SendNoteToCenterServiceTest.java b/src/test/java/com/somemore/note/service/SendNoteToCenterServiceTest.java index db66ee6fb..69e8cea45 100644 --- a/src/test/java/com/somemore/note/service/SendNoteToCenterServiceTest.java +++ b/src/test/java/com/somemore/note/service/SendNoteToCenterServiceTest.java @@ -2,7 +2,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import com.somemore.note.domain.Note; import com.somemore.note.dto.SendNoteToCenterRequestDto; diff --git a/src/test/java/com/somemore/recruitboard/repository/RecruitBoardRepositoryImplTest.java b/src/test/java/com/somemore/recruitboard/repository/RecruitBoardRepositoryImplTest.java index 614f89129..1b0268c59 100644 --- a/src/test/java/com/somemore/recruitboard/repository/RecruitBoardRepositoryImplTest.java +++ b/src/test/java/com/somemore/recruitboard/repository/RecruitBoardRepositoryImplTest.java @@ -11,7 +11,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.location.domain.Location; import com.somemore.location.repository.LocationRepository; import com.somemore.recruitboard.domain.RecruitBoard; diff --git a/src/test/java/com/somemore/recruitboard/service/query/RecruitBoardQueryServiceTest.java b/src/test/java/com/somemore/recruitboard/service/query/RecruitBoardQueryServiceTest.java index 0da7cbe3a..7cdcc6b2c 100644 --- a/src/test/java/com/somemore/recruitboard/service/query/RecruitBoardQueryServiceTest.java +++ b/src/test/java/com/somemore/recruitboard/service/query/RecruitBoardQueryServiceTest.java @@ -12,7 +12,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import com.somemore.location.domain.Location; import com.somemore.location.repository.LocationRepository; diff --git a/src/test/java/com/somemore/review/repository/ReviewRepositoryImplTest.java b/src/test/java/com/somemore/review/repository/ReviewRepositoryImplTest.java index f98ee5ed9..2f3949c87 100644 --- a/src/test/java/com/somemore/review/repository/ReviewRepositoryImplTest.java +++ b/src/test/java/com/somemore/review/repository/ReviewRepositoryImplTest.java @@ -11,7 +11,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.recruitboard.domain.RecruitBoard; import com.somemore.recruitboard.domain.VolunteerCategory; import com.somemore.recruitboard.repository.RecruitBoardRepository; diff --git a/src/test/java/com/somemore/review/service/ReviewQueryServiceTest.java b/src/test/java/com/somemore/review/service/ReviewQueryServiceTest.java index 7cb0c3c09..943df8c0d 100644 --- a/src/test/java/com/somemore/review/service/ReviewQueryServiceTest.java +++ b/src/test/java/com/somemore/review/service/ReviewQueryServiceTest.java @@ -14,7 +14,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; -import com.somemore.center.repository.CenterRepository; +import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; import com.somemore.recruitboard.domain.RecruitBoard; import com.somemore.recruitboard.domain.VolunteerCategory; From 45dffafc8b4c9c04a79c89c9284ead9eec09baed Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:51:02 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=EC=84=A0=ED=98=B8=20=EB=AC=BC?= =?UTF-8?q?=ED=92=88=20=EC=82=AD=EC=A0=9C=20=EA=B4=80=EB=A0=A8=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 권한, 파일 없음에 대한 예외 메세지 추가 --- .../java/com/somemore/global/exception/ExceptionMessage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/somemore/global/exception/ExceptionMessage.java b/src/main/java/com/somemore/global/exception/ExceptionMessage.java index ab4897ae4..9631eee29 100644 --- a/src/main/java/com/somemore/global/exception/ExceptionMessage.java +++ b/src/main/java/com/somemore/global/exception/ExceptionMessage.java @@ -37,7 +37,9 @@ public enum ExceptionMessage { UNAUTHORIZED_NOTIFICATION("해당 알림에 권한이 없습니다."), VOLUNTEER_APPLY_LIST_MISMATCH("봉사 지원 목록과 요청된 봉사 지원 목록이 일치하지 않습니다."), RECRUIT_BOARD_ID_MISMATCH("모든 봉사 신청이 동일한 모집글 ID를 가져야 합니다."), - NOT_EXISTS_NOTE("존재하지 않는 쪽지입니다.") + NOT_EXISTS_NOTE("존재하지 않는 쪽지입니다."), + NOT_EXISTS_PREFER_ITEM("존재하지 않는 선호물품 Id입니다"), + UNAUTHORIZED_PREFER_ITEM("해당 선호물품에 대한 권한이 없습니다.") ; private final String message; From b0d3b3f0a6009401a213786683f8356bfd3a919e Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:51:41 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EC=84=A0=ED=98=B8=20=EB=AC=BC?= =?UTF-8?q?=ED=92=88=20=EC=82=AD=EC=A0=9C=20=EA=B4=80=EB=A0=A8=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EB=A0=88=EC=9D=B4=EC=96=B4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 서비스 메서드 구현 - 예외처리 추가 - 예외 처리를 위한 쿼리 메서드 추가 --- .../preferitem/PreferItemJpaRepository.java | 11 ++ .../preferitem/PreferItemRepository.java | 3 + .../preferitem/PreferItemRepositoryImpl.java | 37 ++++++ .../command/DeletePreferItemService.java | 36 ++++++ .../command/DeletePreferItemUseCase.java | 7 ++ .../command/DeletePreferItemServiceTest.java | 105 ++++++++++++++++++ 6 files changed, 199 insertions(+) create mode 100644 src/main/java/com/somemore/center/repository/preferitem/PreferItemJpaRepository.java create mode 100644 src/main/java/com/somemore/center/repository/preferitem/PreferItemRepositoryImpl.java create mode 100644 src/main/java/com/somemore/center/service/command/DeletePreferItemService.java create mode 100644 src/main/java/com/somemore/center/usecase/command/DeletePreferItemUseCase.java create mode 100644 src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java diff --git a/src/main/java/com/somemore/center/repository/preferitem/PreferItemJpaRepository.java b/src/main/java/com/somemore/center/repository/preferitem/PreferItemJpaRepository.java new file mode 100644 index 000000000..dbab23583 --- /dev/null +++ b/src/main/java/com/somemore/center/repository/preferitem/PreferItemJpaRepository.java @@ -0,0 +1,11 @@ +package com.somemore.center.repository.preferitem; + +import com.somemore.center.domain.PreferItem; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; +import java.util.UUID; + +public interface PreferItemJpaRepository extends JpaRepository { + List findByCenterId(UUID centerId); +} diff --git a/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java b/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java index 73d938fa8..3a89d9234 100644 --- a/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java +++ b/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepository.java @@ -4,10 +4,13 @@ import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Optional; import java.util.UUID; @Repository public interface PreferItemRepository { void save(PreferItem preferItem); + void deleteById(Long preferItemId); + Optional findById(Long preferItemId); List findByCenterId(UUID centerId); } diff --git a/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepositoryImpl.java b/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepositoryImpl.java new file mode 100644 index 000000000..8ca805b81 --- /dev/null +++ b/src/main/java/com/somemore/center/repository/preferitem/PreferItemRepositoryImpl.java @@ -0,0 +1,37 @@ +package com.somemore.center.repository.preferitem; + +import com.somemore.center.domain.PreferItem; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@RequiredArgsConstructor +@Repository +public class PreferItemRepositoryImpl implements PreferItemRepository{ + + private final PreferItemJpaRepository preferItemJpaRepository; + + @Override + public void save(PreferItem preferItem) { + preferItemJpaRepository.save(preferItem); + } + + @Override + public void deleteById(Long preferItemId) { + preferItemJpaRepository.deleteById(preferItemId); + } + + @Override + public Optional findById(Long preferItemId) { + return preferItemJpaRepository.findById(preferItemId); + } + + @Override + public List findByCenterId(UUID centerId) { + return preferItemJpaRepository.findByCenterId(centerId); + } + +} diff --git a/src/main/java/com/somemore/center/service/command/DeletePreferItemService.java b/src/main/java/com/somemore/center/service/command/DeletePreferItemService.java new file mode 100644 index 000000000..246c1aef8 --- /dev/null +++ b/src/main/java/com/somemore/center/service/command/DeletePreferItemService.java @@ -0,0 +1,36 @@ +package com.somemore.center.service.command; + +import com.somemore.center.domain.PreferItem; +import com.somemore.center.repository.preferitem.PreferItemRepository; +import com.somemore.center.usecase.command.DeletePreferItemUseCase; +import com.somemore.global.exception.BadRequestException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.UUID; + +import static com.somemore.global.exception.ExceptionMessage.*; + +@RequiredArgsConstructor +@Service +public class DeletePreferItemService implements DeletePreferItemUseCase { + + private final PreferItemRepository preferItemRepository; + + @Override + public void deletePreferItem(UUID centerId, Long preferItemId) { + PreferItem preferItem = preferItemRepository.findById(preferItemId) + .orElseThrow(() -> new BadRequestException(NOT_EXISTS_PREFER_ITEM)); + + validatePreferItemOwnership(centerId, preferItem); + + preferItemRepository.deleteById(preferItemId); + } + + private void validatePreferItemOwnership(UUID centerId, PreferItem preferItem) { + if (preferItem.getCenterId().equals(centerId)) { + return; + } + throw new BadRequestException(UNAUTHORIZED_PREFER_ITEM); + } +} diff --git a/src/main/java/com/somemore/center/usecase/command/DeletePreferItemUseCase.java b/src/main/java/com/somemore/center/usecase/command/DeletePreferItemUseCase.java new file mode 100644 index 000000000..6458c7daa --- /dev/null +++ b/src/main/java/com/somemore/center/usecase/command/DeletePreferItemUseCase.java @@ -0,0 +1,7 @@ +package com.somemore.center.usecase.command; + +import java.util.UUID; + +public interface DeletePreferItemUseCase { + void deletePreferItem(UUID centerId, Long preferItemId); +} diff --git a/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java b/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java new file mode 100644 index 000000000..a5e634737 --- /dev/null +++ b/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java @@ -0,0 +1,105 @@ +package com.somemore.center.service.command; + +import com.somemore.IntegrationTestSupport; +import com.somemore.center.domain.Center; +import com.somemore.center.domain.PreferItem; +import com.somemore.center.dto.request.PreferItemCreateRequestDto; +import com.somemore.center.repository.center.CenterRepository; +import com.somemore.center.repository.preferitem.PreferItemJpaRepository; +import com.somemore.center.repository.preferitem.PreferItemRepository; +import com.somemore.global.exception.BadRequestException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +import static com.somemore.global.exception.ExceptionMessage.UNAUTHORIZED_PREFER_ITEM; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.BDDAssertions.catchThrowable; + +class DeletePreferItemServiceTest extends IntegrationTestSupport { + + @Autowired + private CreatePreferItemService createPreferItemService; + + @Autowired + private DeletePreferItemService deletePreferItemService; + + @Autowired + private PreferItemRepository preferItemRepository; + + @Autowired + private PreferItemJpaRepository preferItemJpaRepository; + + @Autowired + private CenterRepository centerRepository; + + @DisplayName("기관은 자신의 선호 물품을 삭제할 수 있다.") + @Test + void deletePreferItem() { + //given + Center center = createCenter(); + String itemName = "어린이 도서"; + PreferItemCreateRequestDto createRequestDto = new PreferItemCreateRequestDto(itemName); + createPreferItemService.createPreferItem(center.getId(), createRequestDto); + + PreferItem savedItem = preferItemJpaRepository.findAll().stream() + .filter(item -> item.getCenterId().equals(center.getId()) + && item.getItemName().equals(itemName)) + .findFirst() + .orElseThrow(() -> new AssertionError("저장된 선호물품을 찾을 수 없습니다.")); + + //when + deletePreferItemService.deletePreferItem(center.getId(), savedItem.getId()); + + //then + List remainingItems = preferItemJpaRepository.findAll().stream() + .filter(item -> item.getCenterId().equals(center.getId())) + .toList(); + + assertThat(remainingItems).isEmpty(); + } + + @DisplayName("선호 물품을 등록한 기관이 아니라면 선호 물품을 삭제할 수 없다") + @Test + void deletePreferItemUnauthorized() { + //given + Center center1 = createCenter(); + Center center2 = createCenter(); + String itemName = "어린이 도서"; + PreferItemCreateRequestDto createRequestDto = new PreferItemCreateRequestDto(itemName); + createPreferItemService.createPreferItem(center1.getId(), createRequestDto); + + PreferItem savedItem = preferItemJpaRepository.findAll().stream() + .filter(item -> item.getCenterId().equals(center1.getId()) + && item.getItemName().equals(itemName)) + .findFirst() + .orElseThrow(() -> new AssertionError("저장된 선호물품을 찾을 수 없습니다.")); + + // when + Throwable thrown = catchThrowable(() -> deletePreferItemService.deletePreferItem(center2.getId(), savedItem.getId())); + + // then + assertThat(thrown) + .isInstanceOf(BadRequestException.class) + .hasMessage(UNAUTHORIZED_PREFER_ITEM.getMessage()); + } + + private Center createCenter() { + Center center = Center.create( + "기본 기관 이름", + "010-1234-5678", + "http://example.com/image.jpg", + "기관 소개 내용", + "http://example.com", + "account123", + "password123" + ); + + centerRepository.save(center); + + return center; + } + +} \ No newline at end of file From ec93f2926802c985f7de1e6706fade0b9e03895d Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:05:02 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=EC=84=A0=ED=98=B8=20=EB=AC=BC?= =?UTF-8?q?=ED=92=88=20=EC=82=AD=EC=A0=9C=20=EA=B4=80=EB=A0=A8=20=ED=94=84?= =?UTF-8?q?=EB=A0=88=EC=A0=A0=ED=85=8C=EC=9D=B4=EC=85=98=20=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컨트롤러 구현 - 테스트 코드 작성및 검증 완료 --- .../PreferItemCommandApiController.java | 17 +++-- .../PreferItemCommandApiControllerTest.java | 71 +++++++++++++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/somemore/center/controller/PreferItemCommandApiController.java b/src/main/java/com/somemore/center/controller/PreferItemCommandApiController.java index 776f03389..416cb9b1a 100644 --- a/src/main/java/com/somemore/center/controller/PreferItemCommandApiController.java +++ b/src/main/java/com/somemore/center/controller/PreferItemCommandApiController.java @@ -4,6 +4,7 @@ import com.somemore.center.dto.request.PreferItemCreateRequestDto; import com.somemore.center.dto.response.PreferItemCreateResponseDto; import com.somemore.center.usecase.command.CreatePreferItemUseCase; +import com.somemore.center.usecase.command.DeletePreferItemUseCase; import com.somemore.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -11,10 +12,7 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.security.access.annotation.Secured; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RequiredArgsConstructor @RestController @@ -23,6 +21,7 @@ public class PreferItemCommandApiController { private final CreatePreferItemUseCase createPreferItemUseCase; + private final DeletePreferItemUseCase deletePreferItemUseCase; @Secured("ROLE_CENTER") @Operation(summary = "기관 선호물품 등록 API") @@ -36,4 +35,14 @@ public ApiResponse registerPreferItem( return ApiResponse.ok(200, responseDto, "관심 기관 등록 성공"); } + + @Secured("ROLE_CENTER") + @Operation(summary = "기관 선호물품 삭제 API") + @DeleteMapping("/{preferItemId}") + public ApiResponse deletePreferItem(@CurrentUser UUID centerId, @PathVariable Long preferItemId) { + + deletePreferItemUseCase.deletePreferItem(centerId, preferItemId); + + return ApiResponse.ok("선호 물품 삭제 성공"); + } } diff --git a/src/test/java/com/somemore/center/controller/PreferItemCommandApiControllerTest.java b/src/test/java/com/somemore/center/controller/PreferItemCommandApiControllerTest.java index eac612b02..e683fa27e 100644 --- a/src/test/java/com/somemore/center/controller/PreferItemCommandApiControllerTest.java +++ b/src/test/java/com/somemore/center/controller/PreferItemCommandApiControllerTest.java @@ -5,6 +5,7 @@ import com.somemore.center.dto.request.PreferItemCreateRequestDto; import com.somemore.center.dto.response.PreferItemCreateResponseDto; import com.somemore.center.usecase.command.CreatePreferItemUseCase; +import com.somemore.center.usecase.command.DeletePreferItemUseCase; import com.somemore.global.exception.BadRequestException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -14,7 +15,9 @@ import java.util.UUID; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.verify; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -24,6 +27,9 @@ class PreferItemCommandApiControllerTest extends ControllerTestSupport { @MockBean private CreatePreferItemUseCase createPreferItemUseCase; + @MockBean + private DeletePreferItemUseCase deletePreferItemUseCase; + @DisplayName("기관은 선호물품을 등록할 수 있다. (controller)") @Test @@ -80,4 +86,69 @@ void registerPreferItem_Fail_WhenCenterNotExists() throws Exception { // verify verify(createPreferItemUseCase).createPreferItem(userId, requestDto); } + + @DisplayName("기관은 등록한 선호물품을 삭제할 수 있다. (controller)") + @Test + @WithMockCustomUser(role = "CENTER") + void deletePreferItem() throws Exception { + // given + UUID userId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); + Long preferItemId = 1L; + + // when & then + mockMvc.perform(delete("/api/preferItem/{preferItemId}", preferItemId) + .principal(userId::toString)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.message").value("선호 물품 삭제 성공")); + + // verify + verify(deletePreferItemUseCase).deletePreferItem(userId, preferItemId); + } + + @DisplayName("선호물품을 등록한 기관이 아니라면 선호물품을 삭제할 수 없다. (controller)") + @Test + @WithMockCustomUser(role = "CENTER") + void deletePreferItem_Fail_WhenUnauthorized() throws Exception { + // given + UUID userId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); + Long preferItemId = 1L; + + doThrow(new BadRequestException("다른 기관의 선호 물품은 삭제할 수 없습니다.")) + .when(deletePreferItemUseCase) + .deletePreferItem(userId, preferItemId); + + // when & then + mockMvc.perform(delete("/api/preferItem/{preferItemId}", preferItemId) + .principal(userId::toString)) + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.status").value(400)) + .andExpect(jsonPath("$.detail").value("다른 기관의 선호 물품은 삭제할 수 없습니다.")); + + // verify + verify(deletePreferItemUseCase).deletePreferItem(userId, preferItemId); + } + + @DisplayName("존재하지 않는 선호물품을 삭제할 수 없다. (controller)") + @Test + @WithMockCustomUser(role = "CENTER") + void deletePreferItem_Fail_WhenPreferItemNotExists() throws Exception { + // given + UUID userId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); + Long preferItemId = 1L; + + doThrow(new BadRequestException("존재하지 않는 선호 물품입니다.")) + .when(deletePreferItemUseCase) + .deletePreferItem(userId, preferItemId); + + // when & then + mockMvc.perform(delete("/api/preferItem/{preferItemId}", preferItemId) + .principal(userId::toString)) + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.status").value(400)) + .andExpect(jsonPath("$.detail").value("존재하지 않는 선호 물품입니다.")); + + // verify + verify(deletePreferItemUseCase).deletePreferItem(userId, preferItemId); + } } From f57b577de6b8a95a447ca2e5bf49c7f5faa9b3d1 Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:15:16 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=EA=B8=B0=EA=B4=80=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 중복 아이디 사용으로 인한 테스트 실패를 수정하기 위해 @BeforeEach를 이용한 테스트 실행전 데이터 클렌징 작업 수행 추 --- .../center/service/query/CenterSignServiceTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java b/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java index 622aec38e..16a771e35 100644 --- a/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java +++ b/src/test/java/com/somemore/center/service/query/CenterSignServiceTest.java @@ -2,8 +2,10 @@ import com.somemore.IntegrationTestSupport; import com.somemore.center.domain.Center; +import com.somemore.center.repository.center.CenterJpaRepository; import com.somemore.center.repository.center.CenterRepository; import com.somemore.global.exception.BadRequestException; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +26,14 @@ class CenterSignServiceTest extends IntegrationTestSupport { @Autowired private CenterRepository centerRepository; + @Autowired + private CenterJpaRepository centerJpaRepository; + + @BeforeEach + void cleanUp() { + centerJpaRepository.deleteAll(); + } + @DisplayName("계정 ID로 센터 ID를 조회할 수 있다.") @Test void getIdByAccountId() { From 12d935af584525c772aab6c57d06c07129decc04 Mon Sep 17 00:00:00 2001 From: seojin Yoon <90759319+7zrv@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:08:13 +0900 Subject: [PATCH 6/6] =?UTF-8?q?chore:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 잠재적 에러 예방을 위한 개행 추가 --- .../center/service/command/DeletePreferItemServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java b/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java index a5e634737..4c6558599 100644 --- a/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java +++ b/src/test/java/com/somemore/center/service/command/DeletePreferItemServiceTest.java @@ -102,4 +102,4 @@ private Center createCenter() { return center; } -} \ No newline at end of file +}