-
Notifications
You must be signed in to change notification settings - Fork 243
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
[OptimistLabyrinth] ๐ 1๋จ๊ณ - ํ ์คํธ๋ฅผ ํตํ ์ฝ๋ ๋ณดํธ #641
Open
OptimistLabyrinth
wants to merge
10
commits into
next-step:optimistlabyrinth
Choose a base branch
from
OptimistLabyrinth:feature/first_phase
base: optimistlabyrinth
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f14886a
feat: ์๊ตฌ์ฌํญ ๋ฌธ์ํ
OptimistLabyrinth d2529c2
docs: ๋ฌธ์ ๋ด์ฉ์ ๊ฐ๋ฐ์๊ฐ ์๋ ๊ตฌ์ฑ์๋ ์ดํดํ๊ธฐ ์ฌ์ด ์ธ์ด๋ก ํํํ๊ธฐ
OptimistLabyrinth 447ea40
feat: ์ด๋ค ๋จธ์ ์์ ์คํํ๋ h2 ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฌ์ฉํ๋๋ก application.prop ์์
OptimistLabyrinth cfb03ff
test: ProductRestController, ProductService ์ ๋ํ ํ
์คํธ ์ฝ๋ ์์ฑ
OptimistLabyrinth 8f10335
test: MenuGroupRestController, MenuGroupService ์ ๋ํ ํ
์คํธ ์ถ๊ฐ
OptimistLabyrinth 1f49518
test: ํ
์คํธ ์ฝ๋์ ๋ํ ์ค๋ช
(display name) ์๋ชป๋ ๋ถ๋ถ ๊ณ ์น๊ธฐ
OptimistLabyrinth 805ad80
test: MenuRestController, MenuService ์ ๋ํ ํ
์คํธ ์ฝ๋ ์์ฑ
OptimistLabyrinth 23d9850
test: TableGroupRestController, TableGroupService ์ ๋ํ ํ
์คํธ ์ฝ๋ ์์ฑ
OptimistLabyrinth a1bf634
test: OrderRestController, OrderService ์ ๋ํ ํ
์คํธ ์ฝ๋ ์์ฑ
OptimistLabyrinth 8647a96
test: TableRestController, TableService ์ ๋ํ ํ
์คํธ ์ฝ๋ ์ถ๊ฐ
OptimistLabyrinth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
logging.level.org.springframework.jdbc.core=TRACE | ||
spring.datasource.url=jdbc:h2:~/kitchenpos;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE | ||
spring.datasource.driverClassName=org.h2.Driver | ||
spring.datasource.username=sa | ||
spring.h2.console.enabled=true |
73 changes: 73 additions & 0 deletions
73
src/test/java/kitchenpos/application/MenuGroupServiceTest.java
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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,73 @@ | ||||||
package kitchenpos.application; | ||||||
|
||||||
import kitchenpos.dao.MenuGroupDao; | ||||||
import kitchenpos.domain.MenuGroup; | ||||||
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.Mockito; | ||||||
import org.mockito.junit.jupiter.MockitoExtension; | ||||||
|
||||||
import java.util.Arrays; | ||||||
import java.util.List; | ||||||
|
||||||
import static org.assertj.core.api.Assertions.assertThat; | ||||||
|
||||||
@ExtendWith(MockitoExtension.class) | ||||||
@DisplayName("MenuGroupService ํด๋์ค ํ ์คํธ") | ||||||
public class MenuGroupServiceTest { | ||||||
@Mock | ||||||
private MenuGroupDao menuGroupDao; | ||||||
@InjectMocks | ||||||
private MenuGroupService menuGroupService; | ||||||
|
||||||
@Nested | ||||||
@DisplayName("create ๋ฉ์๋ ํ ์คํธ") | ||||||
public class CreateMethod { | ||||||
@Test | ||||||
@DisplayName("๋ฉ๋ด๊ทธ๋ฃน ์์ฑ ์ฑ๊ณต") | ||||||
public void success() { | ||||||
// given | ||||||
final MenuGroup mockMenuGroup = setupSuccess("test menu group"); | ||||||
|
||||||
// when | ||||||
final MenuGroup createdMenuGroup = menuGroupService.create(mockMenuGroup); | ||||||
|
||||||
// then | ||||||
assertThat(createdMenuGroup.getName()).isEqualTo(mockMenuGroup.getName()); | ||||||
} | ||||||
|
||||||
private MenuGroup setupSuccess(String name) { | ||||||
final MenuGroup mockMenuGroup = new MenuGroup(); | ||||||
mockMenuGroup.setName("test menu group"); | ||||||
Mockito.when(menuGroupDao.save(Mockito.any())).thenReturn(mockMenuGroup); | ||||||
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.
Suggested change
BDDMockito๋ฅผ ์ฌ์ฉํ๋ฉด given when then ์คํ์ผ์ ๋ง๊ฒ ์์ฑํ ์ ์์ด์ ๐ |
||||||
return mockMenuGroup; | ||||||
} | ||||||
} | ||||||
|
||||||
@Nested | ||||||
@DisplayName("list ๋ฉ์๋ ํ ์คํธ") | ||||||
public class ListMethod { | ||||||
@Test | ||||||
@DisplayName("๋ฉ๋ด๊ทธ๋ฃน ์์ฑ ์ฑ๊ณต") | ||||||
public void success() { | ||||||
// given | ||||||
final List<MenuGroup> mockMenuGroups = setupSuccess(); | ||||||
|
||||||
// when | ||||||
final List<MenuGroup> createdMenuGroups = menuGroupService.list(); | ||||||
|
||||||
// then | ||||||
assertThat(createdMenuGroups.size()).isEqualTo(mockMenuGroups.size()); | ||||||
} | ||||||
|
||||||
private List<MenuGroup> setupSuccess() { | ||||||
final List<MenuGroup> mockMenuGroups = Arrays.asList(new MenuGroup(), new MenuGroup(), new MenuGroup()); | ||||||
Mockito.when(menuGroupDao.findAll()).thenReturn(mockMenuGroups); | ||||||
return mockMenuGroups; | ||||||
} | ||||||
} | ||||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
๋น ํธ๋ฆฌ์ ๊ฒ ๊ฐ์์ ๐