Skip to content

Commit

Permalink
Test conversion for both typed and typeless HLRC requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtibshirani committed Dec 12, 2018
1 parent 36dca3c commit 23aeeff
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,9 @@ public void testUpdate() throws IOException {

Map<String, String> expectedParams = new HashMap<>();
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);

UpdateRequest updateRequest = new UpdateRequest(index, type, id);
UpdateRequest updateRequest = new UpdateRequest(index, id);
updateRequest.detectNoop(randomBoolean());

if (randomBoolean()) {
Expand Down Expand Up @@ -687,7 +686,7 @@ public void testUpdate() throws IOException {
}

Request request = RequestConverters.update(updateRequest);
assertEquals("/" + index + "/" + type + "/" + id + "/_update", request.getEndpoint());
assertEquals("/" + index + "/_update/" + id, request.getEndpoint());
assertEquals(expectedParams, request.getParameters());
assertEquals(HttpPost.METHOD_NAME, request.getMethod());

Expand Down Expand Up @@ -718,6 +717,23 @@ public void testUpdate() throws IOException {
}
}

public void testUpdateWithType() throws IOException {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);

UpdateRequest updateRequest = new UpdateRequest(index, type, id);

XContentType xContentType = XContentType.JSON;
BytesReference source = RandomObjects.randomSource(random(), xContentType);
updateRequest.doc(new IndexRequest().source(source, xContentType));

Request request = RequestConverters.update(updateRequest);
assertEquals("/" + index + "/" + type + "/" + id + "/_update", request.getEndpoint());
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
assertToXContentBody(updateRequest, request.getEntity());
}

public void testUpdateWithDifferentContentTypes() {
IllegalStateException exception = expectThrows(IllegalStateException.class, () -> {
UpdateRequest updateRequest = new UpdateRequest();
Expand Down

0 comments on commit 23aeeff

Please sign in to comment.