Skip to content

Commit

Permalink
fix tests: Use ToXContentObject for mock server response
Browse files Browse the repository at this point in the history
  • Loading branch information
timoninmaxim committed Jan 21, 2020
1 parent 4ccf870 commit bfa0cd9
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,22 @@
import org.elasticsearch.client.AbstractResponseTestCase;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;


import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import static org.hamcrest.CoreMatchers.equalTo;

public final class GetSourceResponseTests extends
AbstractResponseTestCase<GetSourceResponseTests.SourceOnlyResponse, GetSourceResponse> {

static class SourceOnlyResponse implements ToXContent {
static class SourceOnlyResponse implements ToXContentObject {

private final BytesReference source;

Expand Down Expand Up @@ -70,10 +68,6 @@ protected GetSourceResponse doParseToClientInstance(XContentParser parser) throw

@Override
protected void assertInstances(SourceOnlyResponse serverTestInstance, GetSourceResponse clientInstance) {
Map<String, Object> expected = new HashMap<>();
expected.put("field", "value");

assertThat(clientInstance.getSource(), equalTo(serverTestInstance.source));
assertThat(clientInstance.getSource(), equalTo(expected));
assertThat(clientInstance.getSource(), equalTo(Map.of("field", "value")));
}
}

0 comments on commit bfa0cd9

Please sign in to comment.