-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 아이템 적용 기능 구현 #45
Changes from 25 commits
2d0f4ef
c8d07a4
8555fb8
b6703af
fbfa925
6f939a5
f502897
d4f60dc
e77c284
a0a7c3e
2b88546
9e50a2b
abbb40f
c5000ad
e1cd9fd
344d99e
b1524f5
73bc05f
2ba7aaf
2d008d8
42c13bb
d4d5e71
7f5255e
dcd87fd
e132a0b
1f1f5b5
a1362d7
051f695
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
package com.moabam.api.application; | ||
|
||
import static com.moabam.fixture.ItemFixture.*; | ||
import static com.moabam.support.fixture.ItemFixture.*; | ||
import static java.util.Collections.*; | ||
import static org.assertj.core.api.Assertions.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.BDDMockito.*; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import com.moabam.api.domain.entity.Inventory; | ||
import com.moabam.api.domain.entity.Item; | ||
import com.moabam.api.domain.entity.enums.ItemType; | ||
import com.moabam.api.domain.repository.InventorySearchRepository; | ||
import com.moabam.api.domain.repository.ItemSearchRepository; | ||
import com.moabam.api.dto.ItemResponse; | ||
import com.moabam.api.dto.ItemsResponse; | ||
import com.moabam.global.common.util.StreamUtils; | ||
import com.moabam.global.error.exception.NotFoundException; | ||
import com.moabam.support.fixture.InventoryFixture; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ItemServiceTest { | ||
|
@@ -54,4 +60,45 @@ void get_products_success() { | |
assertThat(purchasedItemNames).containsExactly(MORNING_SANTA_SKIN_NAME, MORNING_KILLER_SKIN_NAME); | ||
assertThat(response.notPurchasedItems()).isEmpty(); | ||
} | ||
|
||
@DisplayName("아이템을 적용한다.") | ||
@Nested | ||
class SelectItem { | ||
|
||
@DisplayName("성공한다.") | ||
@Test | ||
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C: 뭔가.. 뭔가... 쪼... 쪼끔만더 DisplayName을 신경써준다면,,, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 위에 Nested로 묶어서 괜찮지 않을까한..? |
||
void success() { | ||
// given | ||
Long memberId = 1L; | ||
Long itemId = 1L; | ||
Inventory inventory = InventoryFixture.inventory(memberId, nightMageSkin()); | ||
Inventory defaultInventory = InventoryFixture.inventory(memberId, nightMageSkin()); | ||
ItemType itemType = inventory.getItemType(); | ||
when(inventorySearchRepository.findOne(memberId, itemId)).thenReturn(Optional.of(inventory)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given으로 바꾸는건 어떻게 생각하시나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 머야 왜 이거 이렇게 했지 ㅋㅋ 감사요 |
||
when(inventorySearchRepository.findDefault(memberId, itemType)).thenReturn(Optional.of(defaultInventory)); | ||
|
||
// when | ||
itemService.selectItem(memberId, itemId); | ||
|
||
// then | ||
verify(inventorySearchRepository).findOne(memberId, itemId); | ||
verify(inventorySearchRepository).findDefault(memberId, itemType); | ||
assertFalse(defaultInventory.isDefault()); | ||
assertTrue(inventory.isDefault()); | ||
} | ||
|
||
@DisplayName("인벤토리 아이템이 아니면 예외가 발생한다.") | ||
@Test | ||
void exception() { | ||
// given | ||
Long memberId = 1L; | ||
Long itemId = 1L; | ||
when(inventorySearchRepository.findOne(memberId, itemId)).thenReturn(Optional.empty()); | ||
|
||
// when, then | ||
assertThatThrownBy(() -> itemService.selectItem(memberId, itemId)) | ||
.isInstanceOf(NotFoundException.class) | ||
.hasMessage("구매하지 않은 아이템은 적용할 수 없습니다."); | ||
Comment on lines
+99
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. R: 텍스트를 그대로 박는 것보다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 실제 값을 박아야 INVENTORY_NOT_FOUND에 잘못된 메세지가 적용되었을 경우에 에러를 잡을 수 있다고 생각했슴니다~ |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C: (김앵맹) unset은 공식 영어가 아님 히히
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아놔 ㅋㅋ 네이밍 추천해주고가
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(김앵맹) ㅋㅋ 수고