File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
playtest-http/src/main/kotlin/com/uzabase/playtest2/http Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ package com.uzabase.playtest2.http
33import com.thoughtworks.gauge.Step
44import com.thoughtworks.gauge.datastore.ScenarioDataStore
55import com.uzabase.playtest2.core.K
6- import com.uzabase.playtest2.core.ScenarioDataStoreExt.ensureGet
76import com.uzabase.playtest2.http.proxy.JsonPathProxy
7+ import java.nio.file.Path
88
99class ZoomJsonSteps {
1010 @Step(" JSONのパス<jsonPath>に対応する値が" )
1111 fun zoomJson (jsonPath : String ): Any =
12- ensureGet<String >(K .AssertionTarget )
13- .let { JsonPathProxy .of(it, jsonPath) }
12+ ScenarioDataStore .get(K .AssertionTarget )
13+ .let {
14+ when (it) {
15+ is Path -> JsonPathProxy .of(it, jsonPath);
16+ is String -> JsonPathProxy .of(it, jsonPath);
17+ else -> throw IllegalArgumentException (" AssertionTarget is not a Path or a String" )
18+ }
19+ }
1420 .let { ScenarioDataStore .put(K .AssertionTarget , it) }
1521}
Original file line number Diff line number Diff line change @@ -2,12 +2,16 @@ package com.uzabase.playtest2.http.proxy
22
33import com.jayway.jsonpath.JsonPath
44import com.uzabase.playtest2.core.assertion.Assertable
5+ import java.nio.file.Path
56
67class JsonPathProxy private constructor(val json : String , val path : String ) : Assertable<Any> {
78 companion object {
89 fun of (json : String , path : String ): JsonPathProxy {
910 return JsonPathProxy (json, path)
1011 }
12+ fun of (jsonFilePath : Path , path : String ): JsonPathProxy {
13+ return JsonPathProxy .of(jsonFilePath.toFile().readText(Charsets .UTF_8 ), path)
14+ }
1115 }
1216
1317 override fun shouldBe (expected : Long ): Boolean = JsonPath .read<Long >(json, path) == expected
You can’t perform that action at this time.
0 commit comments