[TEST] Better fix for missing create spec
create is a shortcut to index with op_type=create that the clients support
This commit is contained in:
parent
62b044697a
commit
8b2fe44fe3
|
@ -156,7 +156,11 @@ public class RestClient implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpRequestBuilder callApiBuilder(String apiName, Map<String, String> params, String body) {
|
private HttpRequestBuilder callApiBuilder(String apiName, Map<String, String> params, String body) {
|
||||||
RestApi restApi = restApi(apiName);
|
|
||||||
|
//create doesn't exist in the spec but is supported in the clients (index with op_type=create)
|
||||||
|
boolean indexCreateApi = "create".equals(apiName);
|
||||||
|
String api = indexCreateApi ? "index" : apiName;
|
||||||
|
RestApi restApi = restApi(api);
|
||||||
|
|
||||||
HttpRequestBuilder httpRequestBuilder = httpRequestBuilder();
|
HttpRequestBuilder httpRequestBuilder = httpRequestBuilder();
|
||||||
|
|
||||||
|
@ -186,6 +190,10 @@ public class RestClient implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (indexCreateApi) {
|
||||||
|
httpRequestBuilder.addParam("op_type", "create");
|
||||||
|
}
|
||||||
|
|
||||||
//the http method is randomized (out of the available ones with the chosen api)
|
//the http method is randomized (out of the available ones with the chosen api)
|
||||||
return httpRequestBuilder.method(RandomizedTest.randomFrom(restApi.getSupportedMethods(pathParts.keySet())))
|
return httpRequestBuilder.method(RandomizedTest.randomFrom(restApi.getSupportedMethods(pathParts.keySet())))
|
||||||
.path(RandomizedTest.randomFrom(restApi.getFinalPaths(pathParts)));
|
.path(RandomizedTest.randomFrom(restApi.getFinalPaths(pathParts)));
|
||||||
|
|
|
@ -38,22 +38,6 @@ public class RestSpec {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addApi(RestApi restApi) {
|
void addApi(RestApi restApi) {
|
||||||
if ("index".equals(restApi.getName())) {
|
|
||||||
RestApi create = new RestApi("create");
|
|
||||||
create.addPath("/{index}/{type}");
|
|
||||||
create.addPath("/{index}/{type}/{id}/_create");
|
|
||||||
create.setBodyRequired();
|
|
||||||
for (String method : restApi.getMethods()) {
|
|
||||||
create.addMethod(method);
|
|
||||||
}
|
|
||||||
for (String param : restApi.getParams()) {
|
|
||||||
create.addParam(param);
|
|
||||||
}
|
|
||||||
for (String pathPart : restApi.getPathParts()) {
|
|
||||||
create.addPathPart(pathPart);
|
|
||||||
}
|
|
||||||
restApiMap.put(create.getName(), create);
|
|
||||||
}
|
|
||||||
restApiMap.put(restApi.getName(), restApi);
|
restApiMap.put(restApi.getName(), restApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue