-
Notifications
You must be signed in to change notification settings - Fork 204
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
Step04 cucumber #418
Open
hiblue02
wants to merge
24
commits into
next-step:hiblue02
Choose a base branch
from
hiblue02:step04_cucumber_test
base: hiblue02
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
Step04 cucumber #418
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
987b5ca
test(FarePoliciesTest): ParameterizedTest 적용
hiblue02 6ac30f4
refactor(Path): apply > applyFarePolicies
hiblue02 83ea5de
refactor(FarePolicies): 정책을 확정짓는 부분을 FarePolicies 내부로 이동
hiblue02 57838b9
doc(ReadMe): 요구사항 정의
hiblue02 c7f0460
refactor(PathServiceType): 사용하지 않는 클래스 삭제
hiblue02 50548ce
refactor(PathAcceptanceTest): 로그인 추가
hiblue02 d1d286e
refactor(PathController): 로그인 추가
hiblue02 0fc1048
refactor(Line): 추가요금 생성자 추가
hiblue02 5fd68ab
refactor(PathService): 비회원 조회 기능 추가, Optional 적용
hiblue02 7e37e37
feat(CalculateConditions): 요금 정책 적용 조건 클래스 생성
hiblue02 ac66ce7
feat(FareDiscountPolicy): 연령별 요금 할인 정책 추가
hiblue02 021855a
feat(LineSurchargeFarePolicy): 노선별 추가요금 정책 추가
hiblue02 208365e
test(FarePoliciesTest): 연령별 할인 요금, 노선 추가 요금 계산 테스트 추가
hiblue02 e383dbd
test(MemberController, FavoriteController): loginMember Optional 추가
hiblue02 68d991f
doc(ReadMe): 요구사항 구현 체크
hiblue02 6a2a9dd
refactor(AuthenticationPrincipal): required 속성 추가
hiblue02 1821e84
refactor(Path): path에서 맴버를 직접 찹조하지 않도록 수정.
hiblue02 f1c5c31
refactor(FarePolicy): FareDiscountPolicies를 추가
hiblue02 01d2d7c
test(FarePoliciesTest): given,when,then 추가
hiblue02 1e9192f
feat(FareCalculatorService): FareCalculatorService 추가
hiblue02 e6b82be
8th init
boorownie 90092fe
feat(cucumber) : cucumber 지하철 경로 찾기 시나리오 추가
hiblue02 4be2f6d
Merge branch 'step04_cucumber' into step04_cucumber_test
hiblue02 ad3a62c
feat(cucumber) : PathDocumentation.java 삭제
hiblue02 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
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,23 @@ | ||
package nextstep.cucumber; | ||
|
||
import io.cucumber.spring.CucumberContextConfiguration; | ||
import org.junit.platform.suite.api.ConfigurationParameter; | ||
import org.junit.platform.suite.api.IncludeEngines; | ||
import org.junit.platform.suite.api.SelectClasspathResource; | ||
import org.junit.platform.suite.api.Suite; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; | ||
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME; | ||
|
||
@ActiveProfiles("test") | ||
@Suite | ||
@IncludeEngines("cucumber") | ||
@SelectClasspathResource("features") | ||
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "nextstep") | ||
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") | ||
@CucumberContextConfiguration | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) | ||
public class CucumberTest { | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/java/nextstep/cucumber/steps/AcceptanceContext.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,26 @@ | ||
package nextstep.cucumber.steps; | ||
|
||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
@Component | ||
public class AcceptanceContext { | ||
public Map<String, Long> store = new HashMap<>(); | ||
public ExtractableResponse<Response> response; | ||
|
||
public void add(ExtractableResponse<Response> response) { | ||
store.put(response.jsonPath().getString("name"), | ||
response.jsonPath().getLong("id")); | ||
} | ||
|
||
public Long get(String name) { | ||
return store.get(name); | ||
} | ||
} | ||
|
||
|
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,74 @@ | ||
package nextstep.cucumber.steps; | ||
|
||
import io.cucumber.datatable.DataTable; | ||
import io.cucumber.java8.En; | ||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import nextstep.subway.acceptance.PathSteps; | ||
import nextstep.subway.domain.PathRequestType; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static nextstep.subway.acceptance.LineSteps.지하철_노선_생성_요청; | ||
import static nextstep.subway.acceptance.LineSteps.지하철_노선에_지하철_구간_생성_요청; | ||
import static nextstep.subway.acceptance.StationSteps.지하철역_생성_요청; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
public class PathStepDef implements En { | ||
|
||
|
||
@Autowired | ||
private AcceptanceContext context; | ||
ExtractableResponse<Response> response; | ||
|
||
public PathStepDef() { | ||
|
||
Given("지하철역들을 생성하고", (DataTable table) -> { | ||
List<String> names = table.asList(); | ||
names.forEach(name -> context.add(지하철역_생성_요청(name))); | ||
}); | ||
|
||
Given("지하철 노선들을 생성하고", (DataTable table) -> { | ||
List<Map<String, String>> lines = table.asMaps(); | ||
lines.forEach(this::createLine); | ||
}); | ||
|
||
Given("{string}에 지하철 역을 추가하고", (String lineName, DataTable table) -> { | ||
Long lineId = context.get(lineName); | ||
table.asMaps().forEach(add -> addStationInLine(add, lineId)); | ||
}); | ||
When("{string}과 {string} 사이 경로를 조회하면", (String upStation, String downStation) | ||
-> response = PathSteps.두_역의_거리_경로_조회를_요청( | ||
context.get(upStation), context.get(downStation), PathRequestType.DISTANCE | ||
)); | ||
Comment on lines
+44
to
+47
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. 기존 스텝 메서드를 재활용 잘 해주셨네요 👍 |
||
Then("{string}-{string}-{string} 경로가 조회된다", (String upStation, String middleStation, String downStation) | ||
-> assertThat(response.jsonPath().getList("stations.name", String.class)) | ||
.containsExactly(upStation, middleStation, downStation)); | ||
} | ||
|
||
private void addStationInLine(Map<String, String> add, Long lineId) { | ||
Map<String, String> params = new HashMap<>(); | ||
params.put("upStationId", context.get(add.get("upStation")) + ""); | ||
params.put("downStationId", context.get(add.get("downStation")) + ""); | ||
params.put("distance", add.get("distance")); | ||
params.put("duration", add.get("duration")); | ||
지하철_노선에_지하철_구간_생성_요청(lineId, params); | ||
} | ||
|
||
private void createLine(Map<String, String> line) { | ||
Map<String, String> params = new HashMap<>(); | ||
params.put("name", line.get("name")); | ||
params.put("color", line.get("color")); | ||
params.put("upStationId", context.get(line.get("upStation")) + ""); | ||
params.put("downStationId", context.get(line.get("downStation")) + ""); | ||
params.put("distance", line.get("distance")); | ||
params.put("duration", line.get("duration")); | ||
params.put("surcharge", line.get("surcharge")); | ||
var response = 지하철_노선_생성_요청(params); | ||
context.add(response); | ||
} | ||
} |
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,48 @@ | ||
package nextstep.cucumber.steps; | ||
|
||
import io.cucumber.java8.En; | ||
import io.restassured.RestAssured; | ||
import io.restassured.response.ExtractableResponse; | ||
import io.restassured.response.Response; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
public class StationStepDef implements En { | ||
ExtractableResponse<Response> response; | ||
|
||
public StationStepDef() { | ||
When("지하철역을 생성하면", () -> { | ||
Map<String, String> params = new HashMap<>(); | ||
params.put("name", "강남역"); | ||
response = RestAssured.given().log().all() | ||
.body(params) | ||
.contentType(MediaType.APPLICATION_JSON_VALUE) | ||
.when() | ||
.post("/stations") | ||
.then().log().all() | ||
.extract(); | ||
}); | ||
|
||
Then("지하철역이 생성된다", () -> { | ||
assertThat(response.statusCode()).isEqualTo(HttpStatus.CREATED.value()); | ||
}); | ||
|
||
Then("지하철역 목록 조회 시 생성한 역을 찾을 수 있다", () -> { | ||
List<String> stationNames = | ||
RestAssured.given().log().all() | ||
.when().get("/stations") | ||
.then().log().all() | ||
.extract().jsonPath().getList("name", String.class); | ||
assertThat(stationNames).containsAnyOf("강남역"); | ||
}); | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
src/test/java/nextstep/subway/documentation/Documentation.java
This file was deleted.
Oops, something went wrong.
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.
@Autowired 에 컴파일 에러가 뜨다니.. 확인해봐야겠네요
제 로컬에서는 안 뜨는데 플러그인 이슈일 수 있을 것 같기도..;;
큐컴버 사용 시 의존성 관리를 스프링으로 하는 방법으로 샘플을 작성했는데
pico-container라는 도구를 사용하는 방식도 있어요.
큐컴버가 스프링에 의존적이지 않게 하려면 이런 도구를 써야할 수 도 있겠네요.