remove default `_all` for `type` and `index` if these are missing in REST tests

If a type or path is missing in the REST test yaml file, it is
automatically replaced with _all. This makes it hard to test changes
in the api, for example adding the possibility to leave the index
blank in addition to _all and * in the uri.

closes #4657
This commit is contained in:
Britta Weber 2014-01-08 17:37:35 +01:00
parent e6f83248a2
commit 216c814a7f
11 changed files with 19 additions and 19 deletions

View File

@ -18,8 +18,7 @@
},
"type": {
"type" : "string",
"required" : false,
"default" : "_all",
"required" : true,
"description" : "The type of the document (use `_all` to fetch the first document matching the ID across all types)"
}
},

View File

@ -18,8 +18,7 @@
},
"type": {
"type" : "string",
"required" : false,
"default" : "_all",
"required" : true,
"description" : "The type of the document (use `_all` to fetch the first document matching the ID across all types)"
}
},

View File

@ -18,8 +18,7 @@
},
"type": {
"type" : "string",
"required" : false,
"default" : "_all",
"required" : true,
"description" : "The type of the document; use `_all` to fetch the first document matching the ID across all types"
}
},

View File

@ -8,7 +8,6 @@
"parts": {
"index": {
"type" : "list",
"default" : "_all",
"description" : "A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices"
},
"type": {

View File

@ -11,6 +11,7 @@
- do:
exists:
index: test_1
type: _all
id: 1
- is_true: ''

View File

@ -22,6 +22,7 @@
- do:
get:
index: test_1
type: _all
id: 中文
- match: { _index: test_1 }

View File

@ -11,6 +11,7 @@
- do:
get:
index: test_1
type: _all
id: 1
- match: { _index: test_1 }

View File

@ -18,6 +18,7 @@
- do:
get_source:
index: test_1
type: _all
id: 1
- match: { '': { foo: bar } }

View File

@ -10,6 +10,7 @@
- do:
get_source:
index: test_1
type: _all
id: 1
- match: { '': { foo: bar } }

View File

@ -26,7 +26,8 @@
- do:
search:
type: test
index: _all
type: test
body:
query:
match:

View File

@ -36,8 +36,6 @@ import java.util.regex.Pattern;
*/
public class RestApi {
private static final String ALL = "_all";
private final String name;
private List<String> methods = Lists.newArrayList();
private List<String> paths = Lists.newArrayList();
@ -123,18 +121,18 @@ public class RestApi {
RestPath matchingRestPath = findMatchingRestPath(pathParams.keySet());
String path = matchingRestPath.path;
for (Map.Entry<String, String> paramEntry : matchingRestPath.params.entrySet()) {
//replace path placeholders with actual values
// replace path placeholders with actual values
String value = pathParams.get(paramEntry.getValue());
if (value == null) {
//there might be additional placeholder to replace, not available as input params
//it can only be {index} or {type} to be replaced with _all
if (paramEntry.getValue().equals("index") || paramEntry.getValue().equals("type")) {
value = ALL;
} else {
throw new IllegalArgumentException("path [" + path + "] contains placeholders that weren't replaced with proper values");
}
// if a value is missing, we got the wrong path or the test was
// specified incorrectly
// TODO: What if more than one path exists? for example: PUT
// index/type/_mapping vs. PUT index/_maping/type? Should we
// randomize?
throw new IllegalArgumentException("parameter [" + paramEntry.getValue() + "] missing");
} else {
path = path.replace(paramEntry.getKey(), value);
}
path = path.replace(paramEntry.getKey(), value);
}
return path;
}