Skip to content

Commit fe43837

Browse files
committed
Add test for parameter-less endpoints
1 parent fc0b35d commit fe43837

File tree

1 file changed

+16
-6
lines changed
  • java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end

1 file changed

+16
-6
lines changed

java-client/src/test/java/co/elastic/clients/elasticsearch/end_to_end/RequestTest.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import co.elastic.clients.elasticsearch._core.SearchResponse;
3232
import co.elastic.clients.elasticsearch._core.bulk.ResponseItem;
3333
import co.elastic.clients.elasticsearch.cat.NodesResponse;
34-
import co.elastic.clients.elasticsearch.indices.CreateResponse;
35-
import co.elastic.clients.elasticsearch.indices.GetResponse;
34+
import co.elastic.clients.elasticsearch.indices.CreateIndexResponse;
35+
import co.elastic.clients.elasticsearch.indices.GetIndexResponse;
3636
import co.elastic.clients.elasticsearch.indices.IndexState;
3737
import co.elastic.clients.elasticsearch.model.ModelTestCase;
3838
import co.elastic.clients.json.JsonpMapper;
@@ -76,6 +76,16 @@ public static void tearDown() {
7676
}
7777
}
7878

79+
@Test
80+
public void testCount() throws Exception {
81+
// Tests that a no-parameter method exists for endpoints that only have optional properties
82+
RestClient restClient = RestClient.builder(new HttpHost("localhost", container.getMappedPort(9200))).build();
83+
Transport transport = new RestClientTransport(restClient, mapper);
84+
ElasticsearchClient client = new ElasticsearchClient(transport);
85+
86+
assertTrue(client.count().count() >= 0);
87+
}
88+
7989
@Test
8090
public void testIndexCreation() throws Exception {
8191
RestClient restClient = RestClient.builder(new HttpHost("localhost", container.getMappedPort(9200))).build();
@@ -87,13 +97,13 @@ public void testIndexCreation() throws Exception {
8797
assertTrue(client.ping().value());
8898

8999
// Create an index...
90-
final CreateResponse createResponse = client.indices().create(b -> b.index("my-index"));
100+
final CreateIndexResponse createResponse = client.indices().create(b -> b.index("my-index"));
91101
assertTrue(createResponse.acknowledged());
92102
assertTrue(createResponse.shardsAcknowledged());
93103

94104
// Find info about it, using the async client
95-
CompletableFuture<GetResponse> futureResponse = asyncClient.indices().get(b -> b.index("my-index"));
96-
GetResponse response = futureResponse.get(10, TimeUnit.SECONDS);
105+
CompletableFuture<GetIndexResponse> futureResponse = asyncClient.indices().get(b -> b.index("my-index"));
106+
GetIndexResponse response = futureResponse.get(10, TimeUnit.SECONDS);
97107

98108
Map<String, IndexState> indices = response.result();
99109

@@ -113,7 +123,7 @@ public void testDataIngestion() throws Exception {
113123
String index = "ingest-test";
114124

115125
// Create an index
116-
CreateResponse createIndexResponse = client.indices().create(b -> b
126+
CreateIndexResponse createIndexResponse = client.indices().create(b -> b
117127
.index(index)
118128
);
119129

0 commit comments

Comments
 (0)