-
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
[김대겸] Step1 PR #651
Merged
Merged
[김대겸] Step1 PR #651
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e057b10
docs(readme): 1단계 요구사항 작성
44edb0b
test(product): 상품 관련 인수테스트 작성
753867e
test(product): 상품 관련 비즈니스 로직 테스트 작성
2c6010c
test(menuGroup): 메뉴 그룹 관련 인수테스트 작성
f92af9f
test(menuGroup): 메뉴 그룹 관련 비즈니스 로직 테스트 작성
c241387
test(menu): 메뉴 관련 인수테스트 작성
939a123
test(menu): 메뉴 관련 비즈니스 로직 테스트 작성
1e8cafc
test(orderTable): 주문테이블 관련 인수테스트 작성
0ee95ee
test(orderTable): 주문테이블 관련 비즈니스 로직 테스트 작성
f4718f7
test(tableGroup): 단체 지정 관련 인수테스트 작성
d81cc58
test(tableGroup): 단체 지정 관련 비즈니스 로직 테스트 작성
e98430f
test(order): 주문 관련 인수테스트 작성
9e38a68
test(order): 주문 관련 비즈니스 로직 테스트 작성
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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
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
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
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
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,10 @@ | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
TRUNCATE TABLE TABLE_GROUP; | ||
TRUNCATE TABLE ORDERS; | ||
TRUNCATE TABLE ORDER_LINE_ITEM; | ||
TRUNCATE TABLE ORDER_TABLE; | ||
TRUNCATE TABLE MENU; | ||
TRUNCATE TABLE MENU_GROUP; | ||
TRUNCATE TABLE MENU_PRODUCT; | ||
TRUNCATE TABLE PRODUCT; | ||
SET FOREIGN_KEY_CHECKS = 1; |
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,20 @@ | ||
package kitchenpos.acceptance; | ||
|
||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.web.server.LocalServerPort; | ||
import org.springframework.test.context.jdbc.Sql; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@Sql("/sql/truncate.sql") | ||
public class AcceptanceTest { | ||
|
||
@LocalServerPort | ||
int port; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
RestAssured.port = port; | ||
} | ||
} | ||
62 changes: 62 additions & 0 deletions
62
src/test/java/kitchenpos/acceptance/MenuAcceptanceStep.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,62 @@ | ||
package kitchenpos.acceptance; | ||
|
||
import io.restassured.RestAssured; | ||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import kitchenpos.domain.Menu; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
|
||
public class MenuAcceptanceStep { | ||
|
||
public static ExtractableResponse<Response> 등록된_메뉴(Menu menu) { | ||
return 메뉴_생성_요청(menu); | ||
} | ||
|
||
public static ExtractableResponse<Response> 메뉴_생성_요청(Menu menu) { | ||
return RestAssured | ||
.given().log().all() | ||
.body(menu) | ||
.contentType(MediaType.APPLICATION_JSON_VALUE) | ||
.when().post("/api/menus") | ||
.then().log().all() | ||
.extract(); | ||
} | ||
|
||
public static ExtractableResponse<Response> 메뉴_목록_조회_요청() { | ||
return RestAssured | ||
.given().log().all() | ||
.when().get("/api/menus") | ||
.then().log().all() | ||
.extract(); | ||
} | ||
|
||
public static void 메뉴_생성됨(ExtractableResponse<Response> response) { | ||
assertAll( | ||
() -> assertThat(response.statusCode()).isEqualTo(HttpStatus.CREATED.value()), | ||
() -> assertThat(response.header("Location")).isNotBlank() | ||
); | ||
} | ||
|
||
public static void 메뉴_목록_응답됨(ExtractableResponse<Response> response) { | ||
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()); | ||
} | ||
|
||
public static void 메뉴_목록_포함됨(ExtractableResponse<Response> response, List<ExtractableResponse<Response>> createdResponses) { | ||
List<Long> expectedMenuIds = createdResponses.stream() | ||
.map(it -> Long.parseLong(it.header("Location").split("/")[3])) | ||
.collect(Collectors.toList()); | ||
|
||
List<Long> resultMenuIds = response.jsonPath().getList(".", Menu.class).stream() | ||
.map(Menu::getId) | ||
.collect(Collectors.toList()); | ||
|
||
assertThat(resultMenuIds).containsAll(expectedMenuIds); | ||
} | ||
} |
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.
인수테스트 정말 꼼꼼하게 잘 작성해주셧네요 ㅎㅎ
호출, 검증기능에 대해서도 잘 분리되어있으니 보기 편하네요!