Skip to content

Commit 23aeeff

Browse files
committed
Test conversion for both typed and typeless HLRC requests.
1 parent 36dca3c commit 23aeeff

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,9 @@ public void testUpdate() throws IOException {
630630

631631
Map<String, String> expectedParams = new HashMap<>();
632632
String index = randomAlphaOfLengthBetween(3, 10);
633-
String type = randomAlphaOfLengthBetween(3, 10);
634633
String id = randomAlphaOfLengthBetween(3, 10);
635634

636-
UpdateRequest updateRequest = new UpdateRequest(index, type, id);
635+
UpdateRequest updateRequest = new UpdateRequest(index, id);
637636
updateRequest.detectNoop(randomBoolean());
638637

639638
if (randomBoolean()) {
@@ -687,7 +686,7 @@ public void testUpdate() throws IOException {
687686
}
688687

689688
Request request = RequestConverters.update(updateRequest);
690-
assertEquals("/" + index + "/" + type + "/" + id + "/_update", request.getEndpoint());
689+
assertEquals("/" + index + "/_update/" + id, request.getEndpoint());
691690
assertEquals(expectedParams, request.getParameters());
692691
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
693692

@@ -718,6 +717,23 @@ public void testUpdate() throws IOException {
718717
}
719718
}
720719

720+
public void testUpdateWithType() throws IOException {
721+
String index = randomAlphaOfLengthBetween(3, 10);
722+
String type = randomAlphaOfLengthBetween(3, 10);
723+
String id = randomAlphaOfLengthBetween(3, 10);
724+
725+
UpdateRequest updateRequest = new UpdateRequest(index, type, id);
726+
727+
XContentType xContentType = XContentType.JSON;
728+
BytesReference source = RandomObjects.randomSource(random(), xContentType);
729+
updateRequest.doc(new IndexRequest().source(source, xContentType));
730+
731+
Request request = RequestConverters.update(updateRequest);
732+
assertEquals("/" + index + "/" + type + "/" + id + "/_update", request.getEndpoint());
733+
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
734+
assertToXContentBody(updateRequest, request.getEntity());
735+
}
736+
721737
public void testUpdateWithDifferentContentTypes() {
722738
IllegalStateException exception = expectThrows(IllegalStateException.class, () -> {
723739
UpdateRequest updateRequest = new UpdateRequest();

0 commit comments

Comments
 (0)