TEST: Correct the assertion arguments order (#31540)
This commit corrects the order of the assertion arguments in HLRest client.
This commit is contained in:
parent
27bd68862a
commit
43c2e2fed1
|
@ -113,7 +113,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
.source(jsonMap); // <1>
|
||||
//end::index-request-map
|
||||
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals(indexResponse.getResult(), DocWriteResponse.Result.CREATED);
|
||||
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::index-request-xcontent
|
||||
|
@ -129,7 +129,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
.source(builder); // <1>
|
||||
//end::index-request-xcontent
|
||||
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals(indexResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, indexResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::index-request-shortcut
|
||||
|
@ -139,7 +139,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
"message", "trying out Elasticsearch"); // <1>
|
||||
//end::index-request-shortcut
|
||||
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals(indexResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, indexResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::index-request-string
|
||||
|
@ -158,7 +158,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// tag::index-execute
|
||||
IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);
|
||||
// end::index-execute
|
||||
assertEquals(indexResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, indexResponse.getResult());
|
||||
|
||||
// tag::index-response
|
||||
String index = indexResponse.getIndex();
|
||||
|
@ -269,7 +269,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
IndexRequest indexRequest = new IndexRequest("posts", "doc", "1").source("field", 0);
|
||||
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertSame(indexResponse.status(), RestStatus.CREATED);
|
||||
assertSame(RestStatus.CREATED, indexResponse.status());
|
||||
|
||||
Request request = new Request("POST", "/_scripts/increment-field");
|
||||
request.setJsonEntity(Strings.toString(JsonXContent.contentBuilder()
|
||||
|
@ -280,7 +280,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
.endObject()
|
||||
.endObject()));
|
||||
Response response = client().performRequest(request);
|
||||
assertEquals(response.getStatusLine().getStatusCode(), RestStatus.OK.getStatus());
|
||||
assertEquals(RestStatus.OK.getStatus(), response.getStatusLine().getStatusCode());
|
||||
}
|
||||
{
|
||||
//tag::update-request
|
||||
|
@ -298,7 +298,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
request.script(inline); // <3>
|
||||
//end::update-request-with-inline-script
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
assertEquals(4, updateResponse.getGetResult().getSource().get("field"));
|
||||
|
||||
request = new UpdateRequest("posts", "doc", "1").fetchSource(true);
|
||||
|
@ -308,7 +308,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
request.script(stored); // <2>
|
||||
//end::update-request-with-stored-script
|
||||
updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
assertEquals(8, updateResponse.getGetResult().getSource().get("field"));
|
||||
}
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
.doc(jsonMap); // <1>
|
||||
//end::update-request-with-doc-as-map
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::update-request-with-doc-as-xcontent
|
||||
|
@ -335,7 +335,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
.doc(builder); // <1>
|
||||
//end::update-request-with-doc-as-xcontent
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::update-request-shortcut
|
||||
|
@ -344,7 +344,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
"reason", "daily update"); // <1>
|
||||
//end::update-request-shortcut
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::update-request-with-doc-as-string
|
||||
|
@ -359,7 +359,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// tag::update-execute
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
// end::update-execute
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
|
||||
// tag::update-response
|
||||
String index = updateResponse.getIndex();
|
||||
|
@ -434,7 +434,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
request.fetchSource(true); // <1>
|
||||
//end::update-request-no-source
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
assertNotNull(updateResponse.getGetResult());
|
||||
assertEquals(3, updateResponse.getGetResult().sourceAsMap().size());
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
request.fetchSource(new FetchSourceContext(true, includes, excludes)); // <1>
|
||||
//end::update-request-source-include
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
Map<String, Object> sourceAsMap = updateResponse.getGetResult().sourceAsMap();
|
||||
assertEquals(2, sourceAsMap.size());
|
||||
assertEquals("source includes", sourceAsMap.get("reason"));
|
||||
|
@ -460,7 +460,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
request.fetchSource(new FetchSourceContext(true, includes, excludes)); // <1>
|
||||
//end::update-request-source-exclude
|
||||
UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);
|
||||
assertEquals(updateResponse.getResult(), DocWriteResponse.Result.UPDATED);
|
||||
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
|
||||
Map<String, Object> sourceAsMap = updateResponse.getGetResult().sourceAsMap();
|
||||
assertEquals(2, sourceAsMap.size());
|
||||
assertEquals("source excludes", sourceAsMap.get("reason"));
|
||||
|
@ -538,7 +538,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
IndexRequest indexRequest = new IndexRequest("posts", "doc", "1").source("field", "value");
|
||||
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertSame(indexResponse.status(), RestStatus.CREATED);
|
||||
assertSame(RestStatus.CREATED, indexResponse.status());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -552,7 +552,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// tag::delete-execute
|
||||
DeleteResponse deleteResponse = client.delete(request, RequestOptions.DEFAULT);
|
||||
// end::delete-execute
|
||||
assertSame(deleteResponse.getResult(), DocWriteResponse.Result.DELETED);
|
||||
assertSame(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
|
||||
|
||||
// tag::delete-response
|
||||
String index = deleteResponse.getIndex();
|
||||
|
@ -605,7 +605,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
IndexResponse indexResponse = client.index(new IndexRequest("posts", "doc", "1").source("field", "value")
|
||||
, RequestOptions.DEFAULT);
|
||||
assertSame(indexResponse.status(), RestStatus.CREATED);
|
||||
assertSame(RestStatus.CREATED, indexResponse.status());
|
||||
|
||||
// tag::delete-conflict
|
||||
try {
|
||||
|
@ -621,7 +621,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
{
|
||||
IndexResponse indexResponse = client.index(new IndexRequest("posts", "doc", "async").source("field", "value"),
|
||||
RequestOptions.DEFAULT);
|
||||
assertSame(indexResponse.status(), RestStatus.CREATED);
|
||||
assertSame(RestStatus.CREATED, indexResponse.status());
|
||||
|
||||
DeleteRequest request = new DeleteRequest("posts", "doc", "async");
|
||||
|
||||
|
@ -666,7 +666,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// tag::bulk-execute
|
||||
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
|
||||
// end::bulk-execute
|
||||
assertSame(bulkResponse.status(), RestStatus.OK);
|
||||
assertSame(RestStatus.OK, bulkResponse.status());
|
||||
assertFalse(bulkResponse.hasFailures());
|
||||
}
|
||||
{
|
||||
|
@ -679,7 +679,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
.source(XContentType.JSON,"field", "baz"));
|
||||
// end::bulk-request-with-mixed-operations
|
||||
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
|
||||
assertSame(bulkResponse.status(), RestStatus.OK);
|
||||
assertSame(RestStatus.OK, bulkResponse.status());
|
||||
assertFalse(bulkResponse.hasFailures());
|
||||
|
||||
// tag::bulk-response
|
||||
|
@ -778,7 +778,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
"postDate", new Date(),
|
||||
"message", "trying out Elasticsearch");
|
||||
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
assertEquals(indexResponse.getResult(), DocWriteResponse.Result.CREATED);
|
||||
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
|
||||
}
|
||||
{
|
||||
//tag::get-request
|
||||
|
|
Loading…
Reference in New Issue