diff options
author | javanna <cavannaluca@gmail.com> | 2016-12-29 18:37:25 +0100 |
---|---|---|
committer | Luca Cavanna <javanna@users.noreply.github.com> | 2017-01-06 23:31:48 +0100 |
commit | f4aab0138d3c8d902ac19e192a310773ce828031 (patch) | |
tree | 2c6f4185f7b9461f72a9fe3512d0a5e3b030848a /core/src/test/java/org/elasticsearch/action/support | |
parent | e3546d59c454dedb85c84452797d1bd6c9e8909d (diff) |
introduce ToXContentObject interface
`ToXContentObject` extends `ToXContent` without adding new methods to it, while allowing to mark classes that output complete xcontent objects to distinguish them from classes that require starting and ending an anonymous object externally.
Ideally ToXContent would be renamed to ToXContentFragment, but that would be a huge change in our codebase, hence we simply document the fact that toXContent outputs fragments with no guarantees that the output is valid per se without an external ancestor.
Relates to #16347
Diffstat (limited to 'core/src/test/java/org/elasticsearch/action/support')
-rw-r--r-- | core/src/test/java/org/elasticsearch/action/support/replication/ReplicationResponseTests.java | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationResponseTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationResponseTests.java index 23c0d714be..658853f959 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationResponseTests.java @@ -134,7 +134,7 @@ public class ReplicationResponseTests extends ESTestCase { final XContentType xContentType = randomFrom(XContentType.values()); final ReplicationResponse.ShardInfo shardInfo = new ReplicationResponse.ShardInfo(5, 3); - final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType, true); + final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType); // Expected JSON is {"_shards":{"total":5,"successful":3,"failed":0}} try (XContentParser parser = createParser(xContentType.xContent(), shardInfoBytes)) { @@ -164,7 +164,7 @@ public class ReplicationResponseTests extends ESTestCase { final XContentType xContentType = randomFrom(XContentType.values()); final ReplicationResponse.ShardInfo shardInfo = new ReplicationResponse.ShardInfo(randomIntBetween(1, 5), randomIntBetween(1, 5)); - final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType, true); + final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType); ReplicationResponse.ShardInfo parsedShardInfo; try (XContentParser parser = createParser(xContentType.xContent(), shardInfoBytes)) { @@ -177,7 +177,7 @@ public class ReplicationResponseTests extends ESTestCase { // We can use assertEquals because the shardInfo doesn't have a failure (and exceptions) assertEquals(shardInfo, parsedShardInfo); - BytesReference parsedShardInfoBytes = XContentHelper.toXContent(parsedShardInfo, xContentType, true); + BytesReference parsedShardInfoBytes = XContentHelper.toXContent(parsedShardInfo, xContentType); assertEquals(shardInfoBytes, parsedShardInfoBytes); } @@ -185,7 +185,7 @@ public class ReplicationResponseTests extends ESTestCase { final XContentType xContentType = randomFrom(XContentType.values()); final ReplicationResponse.ShardInfo shardInfo = randomShardInfo(); - final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType, true); + final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType); try (XContentParser parser = createParser(xContentType.xContent(), shardInfoBytes)) { assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken()); @@ -226,7 +226,7 @@ public class ReplicationResponseTests extends ESTestCase { final XContentType xContentType = randomFrom(XContentType.values()); final ReplicationResponse.ShardInfo shardInfo = randomShardInfo(); - final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType, true); + final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfo, xContentType); ReplicationResponse.ShardInfo parsedShardInfo; try (XContentParser parser = createParser(xContentType.xContent(), shardInfoBytes)) { @@ -267,7 +267,7 @@ public class ReplicationResponseTests extends ESTestCase { final XContentType xContentType = randomFrom(XContentType.values()); final ReplicationResponse.ShardInfo.Failure shardInfoFailure = randomFailure(); - final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfoFailure, xContentType, false); + final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfoFailure, xContentType); try (XContentParser parser = createParser(xContentType.xContent(), shardInfoBytes)) { assertFailure(parser, shardInfoFailure); @@ -278,7 +278,7 @@ public class ReplicationResponseTests extends ESTestCase { final XContentType xContentType = randomFrom(XContentType.values()); final ReplicationResponse.ShardInfo.Failure shardInfoFailure = randomFailure(); - final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfoFailure, xContentType, false); + final BytesReference shardInfoBytes = XContentHelper.toXContent(shardInfoFailure, xContentType); ReplicationResponse.ShardInfo.Failure parsedFailure; try (XContentParser parser = createParser(xContentType.xContent(), shardInfoBytes)) { |