-
Notifications
You must be signed in to change notification settings - Fork 0
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
# 42 - Add ExtractJson method - string from json path #43
# 42 - Add ExtractJson method - string from json path #43
Conversation
- Introduced method 'string-from-json-path' in group: 'extractJson'. - Improved error message in method 'body-contains-text' in group: 'assert'
JaCoCo code coverage report - ScAPI
|
case StringFromList | StringFromJsonPath => | ||
val cacheKey = responseAction.params("cacheKey") | ||
val listIndex = responseAction.params("listIndex").toInt | ||
val jsonKey = responseAction.params("jsonKey") | ||
val cacheLevel = responseAction.params("cacheLevel") | ||
|
||
stringFromList(response, cacheKey, listIndex, jsonKey, cacheLevel) | ||
action match { | ||
case StringFromList => | ||
val jsonKey = responseAction.params("jsonKey") | ||
val listIndex = responseAction.params("listIndex").toInt | ||
stringFromList(response, cacheKey, listIndex, jsonKey, cacheLevel) | ||
|
||
case StringFromJsonPath => | ||
val jsonPath = responseAction.params("jsonPath") | ||
stringFromJsonPath(response, jsonPath, cacheKey, cacheLevel) | ||
} |
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.
case StringFromList | StringFromJsonPath => | |
val cacheKey = responseAction.params("cacheKey") | |
val listIndex = responseAction.params("listIndex").toInt | |
val jsonKey = responseAction.params("jsonKey") | |
val cacheLevel = responseAction.params("cacheLevel") | |
stringFromList(response, cacheKey, listIndex, jsonKey, cacheLevel) | |
action match { | |
case StringFromList => | |
val jsonKey = responseAction.params("jsonKey") | |
val listIndex = responseAction.params("listIndex").toInt | |
stringFromList(response, cacheKey, listIndex, jsonKey, cacheLevel) | |
case StringFromJsonPath => | |
val jsonPath = responseAction.params("jsonPath") | |
stringFromJsonPath(response, jsonPath, cacheKey, cacheLevel) | |
} | |
case StringFromList => | |
val (cacheKey, cacheLevel) = cachingFunctionYieldingTuple() | |
val jsonKey = responseAction.params("jsonKey") | |
val listIndex = responseAction.params("listIndex").toInt | |
stringFromList(response, cacheKey, listIndex, jsonKey, cacheLevel) | |
case StringFromJsonPath => | |
val (cacheKey, cacheLevel) = cachingFunctionYieldingTuple() | |
val jsonPath = responseAction.params("jsonPath") | |
stringFromJsonPath(response, jsonPath, cacheKey, cacheLevel) | |
} |
Instead of matching twice just like this, rather match once and repeat one method call common for specific cases.
// e.g. but with a more fitting name :)
def cachingFunctionYieldingTuple() = {
val cacheKey = responseAction.params("cacheKey")
val cacheLevel = responseAction.params("cacheLevel")
(cacheKey, cacheLevel)
}
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.
Thank you for an improvement idea.
Fixed in commit 66e35c3.
...rc/main/scala/africa/absa/testing/scapi/rest/response/action/ExtractJsonResponseAction.scala
Outdated
Show resolved
Hide resolved
...rc/main/scala/africa/absa/testing/scapi/rest/response/action/ExtractJsonResponseAction.scala
Show resolved
Hide resolved
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.
LGTM, just tiny suggestions
Closes #42