|
19 | 19 |
|
20 | 20 | package org.elasticsearch.client.documentation; |
21 | 21 |
|
22 | | -import org.apache.http.client.methods.HttpPost; |
23 | | -import org.apache.http.entity.ContentType; |
24 | | -import org.apache.http.nio.entity.NStringEntity; |
25 | 22 | import org.apache.http.client.methods.HttpPost; |
26 | 23 | import org.apache.http.entity.ContentType; |
27 | 24 | import org.apache.http.nio.entity.NStringEntity; |
28 | 25 | import org.elasticsearch.action.ActionListener; |
29 | 26 | import org.elasticsearch.action.LatchedActionListener; |
30 | 27 | import org.elasticsearch.client.ESRestHighLevelClientTestCase; |
31 | 28 | import org.elasticsearch.client.Request; |
32 | | -import org.elasticsearch.client.Request; |
33 | 29 | import org.elasticsearch.client.RequestOptions; |
34 | 30 | import org.elasticsearch.client.RestHighLevelClient; |
35 | 31 | import org.elasticsearch.client.security.ChangePasswordRequest; |
36 | 32 | import org.elasticsearch.client.security.DeleteRoleMappingRequest; |
37 | 33 | import org.elasticsearch.client.security.DeleteRoleMappingResponse; |
38 | 34 | import org.elasticsearch.client.security.DeleteRoleRequest; |
39 | 35 | import org.elasticsearch.client.security.DeleteRoleResponse; |
40 | | -import org.elasticsearch.client.security.DeleteRoleRequest; |
41 | | -import org.elasticsearch.client.security.DeleteRoleResponse; |
42 | 36 | import org.elasticsearch.client.security.DisableUserRequest; |
43 | 37 | import org.elasticsearch.client.security.EmptyResponse; |
44 | 38 | import org.elasticsearch.client.security.EnableUserRequest; |
|
48 | 42 | import org.elasticsearch.client.security.PutUserRequest; |
49 | 43 | import org.elasticsearch.client.security.PutUserResponse; |
50 | 44 | import org.elasticsearch.client.security.RefreshPolicy; |
51 | | -import org.elasticsearch.client.security.support.expressiondsl.RoleMapperExpression; |
52 | | -import org.elasticsearch.client.security.support.expressiondsl.fields.FieldRoleMapperExpression; |
53 | 45 | import org.elasticsearch.client.security.support.CertificateInfo; |
| 46 | +import org.elasticsearch.client.security.support.expressiondsl.RoleMapperExpression; |
54 | 47 | import org.elasticsearch.client.security.support.expressiondsl.expressions.AnyRoleMapperExpression; |
55 | 48 | import org.elasticsearch.client.security.support.expressiondsl.fields.FieldRoleMapperExpression; |
56 | 49 | import org.elasticsearch.common.Strings; |
57 | 50 | import org.elasticsearch.common.xcontent.XContentBuilder; |
58 | | -import org.elasticsearch.common.Strings; |
59 | | -import org.elasticsearch.common.xcontent.XContentBuilder; |
60 | 51 | import org.hamcrest.Matchers; |
61 | 52 |
|
62 | | -import java.io.IOException; |
63 | 53 | import java.io.IOException; |
64 | 54 | import java.util.Collections; |
65 | 55 | import java.util.Iterator; |
@@ -443,21 +433,31 @@ public void testDeleteRole() throws Exception { |
443 | 433 | addRole("testrole"); |
444 | 434 |
|
445 | 435 | { |
446 | | - //tag::delete-role-execute |
447 | | - DeleteRoleRequest deleteRoleRequest = new DeleteRoleRequest("testrole"); |
| 436 | + // tag::delete-role-request |
| 437 | + DeleteRoleRequest deleteRoleRequest = new DeleteRoleRequest( |
| 438 | + "testrole"); // <1> |
| 439 | + // end::delete-role-request |
| 440 | + |
| 441 | + // tag::delete-role-execute |
448 | 442 | DeleteRoleResponse deleteRoleResponse = client.security().deleteRole(deleteRoleRequest, RequestOptions.DEFAULT); |
449 | | - //end::delete-role-execute |
450 | | - assertTrue(deleteRoleResponse.isFound()); |
| 443 | + // end::delete-role-execute |
| 444 | + |
| 445 | + // tag::delete-role-response |
| 446 | + boolean found = deleteRoleResponse.isFound(); // <1> |
| 447 | + // end::delete-role-response |
| 448 | + assertTrue(found); |
451 | 449 |
|
452 | 450 | // check if deleting the already deleted role again will give us a different response |
453 | 451 | deleteRoleResponse = client.security().deleteRole(deleteRoleRequest, RequestOptions.DEFAULT); |
454 | 452 | assertFalse(deleteRoleResponse.isFound()); |
455 | 453 | } |
456 | 454 |
|
457 | 455 | { |
458 | | - //tag::delete-role-execute-listener |
459 | 456 | DeleteRoleRequest deleteRoleRequest = new DeleteRoleRequest("testrole"); |
460 | | - ActionListener<DeleteRoleResponse> listener = new ActionListener<DeleteRoleResponse>() { |
| 457 | + |
| 458 | + ActionListener<DeleteRoleResponse> listener; |
| 459 | + //tag::delete-role-execute-listener |
| 460 | + listener = new ActionListener<DeleteRoleResponse>() { |
461 | 461 | @Override |
462 | 462 | public void onResponse(DeleteRoleResponse deleteRoleResponse) { |
463 | 463 | // <1> |
|
0 commit comments