-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] merge 과정에서 깨지는 테스트코드 수정 및 테스트
- Loading branch information
Showing
2 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,17 @@ | |
|
||
import camp.woowak.lab.infra.date.DateTimeProvider; | ||
import camp.woowak.lab.menu.domain.MenuCategory; | ||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import camp.woowak.lab.payaccount.repository.PayAccountRepository; | ||
import camp.woowak.lab.store.domain.Store; | ||
import camp.woowak.lab.store.domain.StoreAddress; | ||
import camp.woowak.lab.store.domain.StoreCategory; | ||
import camp.woowak.lab.store.repository.StoreCategoryRepository; | ||
import camp.woowak.lab.store.repository.StoreRepository; | ||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import camp.woowak.lab.vendor.repository.VendorRepository; | ||
import camp.woowak.lab.web.authentication.NoOpPasswordEncoder; | ||
import camp.woowak.lab.web.authentication.PasswordEncoder; | ||
|
||
@DataJpaTest | ||
class MenuCategoryRepositoryTest { | ||
|
@@ -35,6 +39,9 @@ class MenuCategoryRepositoryTest { | |
@Autowired | ||
StoreCategoryRepository storeCategoryRepository; | ||
|
||
@Autowired | ||
PayAccountRepository payAccountRepository; | ||
|
||
@Nested | ||
@DisplayName("가게와 메뉴카테고리 이름으로 메뉴카테고리를 조회하는 기능은") | ||
class FindByStoreAndNameTest { | ||
|
@@ -43,7 +50,9 @@ class FindByStoreAndNameTest { | |
@DisplayName("[Success] 가게와 메뉴카테고리 이름이 있으면 조회를 성공한다") | ||
void success() { | ||
// given | ||
Vendor vendor = new Vendor(); | ||
PayAccount payAccount = payAccountRepository.save(new PayAccount()); | ||
|
||
Vendor vendor = createVendor(payAccount); | ||
String categoryName = "돈가스"; | ||
StoreCategory storeCategory = new StoreCategory(categoryName); | ||
|
||
|
@@ -77,8 +86,9 @@ void notExistMenuCategoryName() { | |
// given | ||
String categoryName = "돈가스"; | ||
String notExistCategoryName = "xxx"; | ||
PayAccount payAccount = payAccountRepository.save(new PayAccount()); | ||
|
||
Vendor vendor = new Vendor(); | ||
Vendor vendor = createVendor(payAccount); | ||
vendorRepository.saveAndFlush(vendor); | ||
|
||
StoreCategory storeCategory = new StoreCategory(categoryName); | ||
|
@@ -120,4 +130,10 @@ private Store createStore(Vendor vendor, StoreCategory storeCategory) { | |
); | ||
} | ||
|
||
private Vendor createVendor(PayAccount payAccount) { | ||
PasswordEncoder passwordEncoder = new NoOpPasswordEncoder(); | ||
return new Vendor("vendorName", "[email protected]", "vendorPassword", "010-0000-0000", payAccount, | ||
passwordEncoder); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,16 @@ | |
import camp.woowak.lab.menu.domain.MenuCategory; | ||
import camp.woowak.lab.menu.repository.MenuCategoryRepository; | ||
import camp.woowak.lab.menu.repository.MenuRepository; | ||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import camp.woowak.lab.payaccount.domain.TestPayAccount; | ||
import camp.woowak.lab.store.domain.Store; | ||
import camp.woowak.lab.store.domain.StoreAddress; | ||
import camp.woowak.lab.store.exception.NotFoundStoreException; | ||
import camp.woowak.lab.store.repository.StoreRepository; | ||
import camp.woowak.lab.store.service.dto.StoreMenuRegistrationRequest; | ||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import camp.woowak.lab.web.authentication.NoOpPasswordEncoder; | ||
import camp.woowak.lab.web.authentication.PasswordEncoder; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class StoreMenuRegistrationServiceTest { | ||
|
@@ -47,7 +51,7 @@ class StoreMenuRegistrationServiceTest { | |
@DisplayName("[Success] 메뉴 등록 성공") | ||
void storeMenuRegistrationSuccess() { | ||
// given | ||
Vendor owner = new Vendor(); | ||
Vendor owner = createVendor(); | ||
List<StoreMenuRegistrationRequest.MenuLineItem> menuItems = List.of( | ||
new StoreMenuRegistrationRequest.MenuLineItem("메뉴1", "image1.jpg", "카테고리1", 10000) | ||
); | ||
|
@@ -70,7 +74,7 @@ void storeMenuRegistrationSuccess() { | |
@DisplayName("[Exception] 존재하지 않는 가게") | ||
void storeMenuRegistrationStoreNotFound() { | ||
// given | ||
Vendor owner = new Vendor(); | ||
Vendor owner = createVendor(); | ||
List<StoreMenuRegistrationRequest.MenuLineItem> menuItems = List.of( | ||
new StoreMenuRegistrationRequest.MenuLineItem("메뉴1", "image1.jpg", "카테고리1", 10000) | ||
); | ||
|
@@ -99,4 +103,11 @@ private Store createValidStore() { | |
private MenuCategory createValidMenuCategory() { | ||
return new MenuCategory(storeFixture, "1234567890"); | ||
} | ||
|
||
private Vendor createVendor() { | ||
PayAccount payAccount = new TestPayAccount(1L); | ||
PasswordEncoder passwordEncoder = new NoOpPasswordEncoder(); | ||
return new Vendor("vendorName", "[email protected]", "vendorPassword", "010-0000-0000", payAccount, | ||
passwordEncoder); | ||
} | ||
} |