Skip to content

Commit

Permalink
TEST: Correct the assertion arguments order (#31540)
Browse files Browse the repository at this point in the history
This commit corrects the order of the assertion arguments in HLRest client.
  • Loading branch information
olcbean authored and dnhatn committed Jun 24, 2018
1 parent b7ef75f commit e401710
Showing 1 changed file with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testIndex() throws Exception {
.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
Expand All @@ -129,7 +129,7 @@ public void testIndex() throws Exception {
.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
Expand All @@ -139,7 +139,7 @@ public void testIndex() throws Exception {
"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
Expand All @@ -158,7 +158,7 @@ public void testIndex() throws Exception {
// 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();
Expand Down Expand Up @@ -269,7 +269,7 @@ public void testUpdate() throws Exception {
{
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()
Expand All @@ -280,7 +280,7 @@ public void testUpdate() throws Exception {
.endObject()
.endObject()));
Response response = client().performRequest(request);
assertEquals(response.getStatusLine().getStatusCode(), RestStatus.OK.getStatus());
assertEquals(RestStatus.OK.getStatus(), response.getStatusLine().getStatusCode());
}
{
//tag::update-request
Expand All @@ -298,7 +298,7 @@ public void testUpdate() throws Exception {
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);
Expand All @@ -308,7 +308,7 @@ public void testUpdate() throws Exception {
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"));
}
{
Expand All @@ -320,7 +320,7 @@ public void testUpdate() throws Exception {
.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
Expand All @@ -335,7 +335,7 @@ public void testUpdate() throws Exception {
.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
Expand All @@ -344,7 +344,7 @@ public void testUpdate() throws Exception {
"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
Expand All @@ -359,7 +359,7 @@ public void testUpdate() throws Exception {
// 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();
Expand Down Expand Up @@ -434,7 +434,7 @@ public void testUpdate() throws Exception {
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());
}
Expand All @@ -446,7 +446,7 @@ public void testUpdate() throws Exception {
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"));
Expand All @@ -460,7 +460,7 @@ public void testUpdate() throws Exception {
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"));
Expand Down Expand Up @@ -538,7 +538,7 @@ public void testDelete() throws Exception {
{
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());
}

{
Expand All @@ -552,7 +552,7 @@ public void testDelete() throws Exception {
// 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();
Expand Down Expand Up @@ -605,7 +605,7 @@ public void testDelete() throws Exception {
{
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 {
Expand All @@ -621,7 +621,7 @@ public void testDelete() throws Exception {
{
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");

Expand Down Expand Up @@ -666,7 +666,7 @@ public void testBulk() throws Exception {
// 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());
}
{
Expand All @@ -679,7 +679,7 @@ public void testBulk() throws Exception {
.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
Expand Down Expand Up @@ -778,7 +778,7 @@ public void testGet() throws Exception {
"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
Expand Down

0 comments on commit e401710

Please sign in to comment.