[TEST] parse yaml responses too through ObjectPath rather than only json responses

No need to match against yaml responses via regexes in REST tests, yaml responses can be properly parsed via ObjectPath instead. Few REST tests need to be updated accordingly.
This commit is contained in:
javanna 2016-06-26 00:04:44 +02:00 committed by Luca Cavanna
parent 34f5c50a7f
commit 60bafa5d78
4 changed files with 17 additions and 30 deletions

View File

@ -17,12 +17,8 @@
headers:
Accept: application/yaml
- match:
$body: |
/^---\n
-\s+alias:\s+"test_alias"\s+
index:\s+"test"\s+
filter:\s+"-"\s+
routing.index:\s+"-"\s+
routing.search:\s+"-"\s+$/
- match: {0.alias: test_alias}
- match: {0.index: test}
- match: {0.filter: "-"}
- match: {0.routing\.index: "-"}
- match: {0.routing\.search: "-"}

View File

@ -17,13 +17,8 @@
cat.aliases:
format: yaml
- match:
$body: |
/^---\n
-\s+alias:\s+"test_alias"\s+
index:\s+"test"\s+
filter:\s+"-"\s+
routing.index:\s+"-"\s+
routing.search:\s+"-"\s+$/
- match: {0.alias: test_alias}
- match: {0.index: test}
- match: {0.filter: "-"}
- match: {0.routing\.index: "-"}
- match: {0.routing\.search: "-"}

View File

@ -18,13 +18,9 @@
type: _all
id: 1
- match:
$body: |
/^---\n
_index:\s+\"test_1"\n
_type:\s+"test"\n
_id:\s+"1"\n
_version:\s+1\n
found:\s+true\n
_source:\n
\s+body:\s+"foo"\n$/
- match: {_index: "test_1"}
- match: {_type: "test"}
- match: {_id: "1"}
- match: {_version: 1}
- match: {found: true}
- match: { _source: { body: foo }}

View File

@ -68,7 +68,7 @@ public class RestTestResponse {
String contentType = response.getHeader("Content-Type");
XContentType xContentType = XContentType.fromMediaTypeOrFormat(contentType);
//skip parsing if we got text back (e.g. if we called _cat apis)
if (xContentType == XContentType.JSON) {
if (xContentType == XContentType.JSON || xContentType == XContentType.YAML) {
this.parsedResponse = ObjectPath.createFromXContent(xContentType.xContent(), body);
}
}