diff --git a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java index 42473355c80f6..93a6d02a13f55 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java @@ -62,45 +62,38 @@ public class SimulatePipelineResponse extends ActionResponse implements ToXConte static { PARSER.declareObjectArray( constructorArg(), - (p, c) -> { - ensureExpectedToken(Token.START_OBJECT, p.currentToken(), p::getTokenLocation); - boolean isVerbose = false; - boolean isFirst = true; + (parser, context) -> { + ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation); SimulateDocumentResult result = null; - while (p.nextToken().equals(Token.FIELD_NAME)) { - switch (p.currentName()) { + while (parser.nextToken() != Token.END_OBJECT) { + ensureExpectedToken(parser.currentToken(), Token.FIELD_NAME, parser::getTokenLocation); + String fieldName = parser.currentName(); + parser.nextToken(); + switch(fieldName) { case SimulateDocumentVerboseResult.PROCESSOR_RESULT_FIELD: - assert isFirst || isVerbose; - isVerbose = true; - ensureExpectedToken(Token.START_ARRAY, p.nextToken(), p::getTokenLocation); + ensureExpectedToken(Token.START_ARRAY, parser.currentToken(), parser::getTokenLocation); List results = new ArrayList<>(); - while (p.nextToken().equals(Token.START_OBJECT)) { - results.add(SimulateProcessorResult.fromXContent(p)); + while (parser.nextToken().equals(Token.START_OBJECT)) { + results.add(SimulateProcessorResult.fromXContent(parser)); } - ensureExpectedToken(Token.END_ARRAY, p.currentToken(), p::getTokenLocation); + ensureExpectedToken(Token.END_ARRAY, parser.currentToken(), parser::getTokenLocation); result = new SimulateDocumentVerboseResult(results); break; case WriteableIngestDocument.DOC_FIELD: case "error": - assert !isVerbose; - if (p.currentName().equals("error")) { - p.nextToken(); - result = new SimulateDocumentBaseResult(ElasticsearchException.fromXContent(p)); + if (fieldName.equals("error")) { + result = new SimulateDocumentBaseResult(ElasticsearchException.fromXContent(parser)); } else { result = new SimulateDocumentBaseResult( - WriteableIngestDocument.INGEST_DOC_PARSER.apply(p, null).getIngestDocument() + WriteableIngestDocument.INGEST_DOC_PARSER.apply(parser, null).getIngestDocument() ); } - ensureExpectedToken(Token.END_OBJECT, p.currentToken(), p::getTokenLocation); + ensureExpectedToken(Token.END_OBJECT, parser.currentToken(), parser::getTokenLocation); break; default: - p.nextToken(); - p.skipChildren(); - break; + parser.skipChildren(); } - isFirst = false; } - ensureExpectedToken(Token.END_OBJECT, p.currentToken(), p::getTokenLocation); assert result != null; return result; }, diff --git a/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentBaseResultTests.java b/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentBaseResultTests.java index af7b3245c94b6..c31c7716eaae2 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentBaseResultTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentBaseResultTests.java @@ -22,17 +22,19 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.test.AbstractXContentTestCase; import java.io.IOException; +import java.util.StringJoiner; +import java.util.function.Predicate; +import java.util.function.Supplier; import static org.elasticsearch.ingest.IngestDocumentMatcher.assertIngestDocument; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.elasticsearch.action.ingest.WriteableIngestDocumentTests.assertEqualIngestDocs; +import static org.elasticsearch.action.ingest.WriteableIngestDocumentTests.createRandomIngestDoc; public class SimulateDocumentBaseResultTests extends AbstractXContentTestCase { @@ -55,20 +57,24 @@ public void testSerialization() throws IOException { } } - protected SimulateDocumentBaseResult createTestInstance(boolean isFailure) { + static SimulateDocumentBaseResult createTestInstance(boolean isFailure) { SimulateDocumentBaseResult simulateDocumentBaseResult; if (isFailure) { simulateDocumentBaseResult = new SimulateDocumentBaseResult(new IllegalArgumentException("test")); } else { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + IngestDocument ingestDocument = createRandomIngestDoc(); simulateDocumentBaseResult = new SimulateDocumentBaseResult(ingestDocument); } return simulateDocumentBaseResult; } + private static SimulateDocumentBaseResult createTestInstanceWithFailures() { + return createTestInstance(randomBoolean()); + } + @Override protected SimulateDocumentBaseResult createTestInstance() { - return createTestInstance(randomBoolean()); + return createTestInstance(false); } @Override @@ -78,11 +84,27 @@ protected SimulateDocumentBaseResult doParseInstance(XContentParser parser) { @Override protected boolean supportsUnknownFields() { - return false; + return true; + } + + @Override + protected Predicate getRandomFieldsExcludeFilter() { + // We cannot have random fields in the _source field and _ingest field + return field -> + field.contains( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.SOURCE_FIELD).toString() + ) || + field.contains( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.INGEST_FIELD).toString() + ); } public static void assertEqualDocs(SimulateDocumentBaseResult response, SimulateDocumentBaseResult parsedResponse) { - assertEqualIngestDocs(response.getIngestDocument(), parsedResponse.getIngestDocument()); + assertEquals(response.getIngestDocument(), parsedResponse.getIngestDocument()); if (response.getFailure() != null) { assertNotNull(parsedResponse.getFailure()); assertThat( @@ -101,6 +123,21 @@ public void assertEqualInstances(SimulateDocumentBaseResult response, SimulateDo @Override protected boolean assertToXContentEquivalence() { - return false; + return true; + } + + /** + * Test parsing {@link SimulateDocumentBaseResult} with inner failures as they don't support asserting on xcontent + * equivalence, given that exceptions are not parsed back as the same original class. We run the usual + * {@link AbstractXContentTestCase#testFromXContent()} without failures, and this other test with failures where + * we disable asserting on xcontent equivalence at the end. + */ + public void testFromXContentWithFailures() throws IOException { + Supplier instanceSupplier = SimulateDocumentBaseResultTests::createTestInstanceWithFailures; + //exceptions are not of the same type whenever parsed back + boolean assertToXContentEquivalence = false; + AbstractXContentTestCase.testFromXContent(NUMBER_OF_TEST_RUNS, instanceSupplier, supportsUnknownFields(), + getShuffleFieldsExceptions(), getRandomFieldsExcludeFilter(), this::createParser, this::doParseInstance, + this::assertEqualInstances, assertToXContentEquivalence, getToXContentParams()); } } diff --git a/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentVerboseResultTests.java b/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentVerboseResultTests.java index 363ce36ce115a..3cdd0f9f33678 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentVerboseResultTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/SimulateDocumentVerboseResultTests.java @@ -21,23 +21,38 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.AbstractXContentTestCase; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.StringJoiner; +import java.util.function.Predicate; +import java.util.function.Supplier; public class SimulateDocumentVerboseResultTests extends AbstractXContentTestCase { - @Override - protected SimulateDocumentVerboseResult createTestInstance() { + static SimulateDocumentVerboseResult createTestInstance(boolean withFailures) { int numDocs = randomIntBetween(0, 10); List results = new ArrayList<>(); for (int i = 0; i getRandomFieldsExcludeFilter() { + // We cannot have random fields in the _source field and _ingest field + return field -> + field.contains( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.SOURCE_FIELD).toString() + ) || + field.contains( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.INGEST_FIELD).toString() + ); + } + + /** + * Test parsing {@link SimulateDocumentVerboseResult} with inner failures as they don't support asserting on xcontent + * equivalence, given that exceptions are not parsed back as the same original class. We run the usual + * {@link AbstractXContentTestCase#testFromXContent()} without failures, and this other test with failures where we + * disable asserting on xcontent equivalence at the end. + */ + public void testFromXContentWithFailures() throws IOException { + Supplier instanceSupplier = SimulateDocumentVerboseResultTests::createTestInstanceWithFailures; + //exceptions are not of the same type whenever parsed back + boolean assertToXContentEquivalence = false; + AbstractXContentTestCase.testFromXContent(NUMBER_OF_TEST_RUNS, instanceSupplier, supportsUnknownFields(), + getShuffleFieldsExceptions(), getRandomFieldsExcludeFilter(), this::createParser, this::doParseInstance, + this::assertEqualInstances, assertToXContentEquivalence, getToXContentParams()); } } diff --git a/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java b/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java index e333766f401a2..60bad4aad460f 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java @@ -22,14 +22,13 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.ingest.IngestDocument; -import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.test.AbstractXContentTestCase; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.StringJoiner; import java.util.function.Predicate; import java.util.function.Supplier; @@ -94,35 +93,18 @@ public void testSerialization() throws IOException { } } - public static SimulatePipelineResponse createInstance(String pipelineId, boolean isVerbose, boolean withFailure) { + static SimulatePipelineResponse createInstance(String pipelineId, boolean isVerbose, boolean withFailure) { int numResults = randomIntBetween(1, 10); List results = new ArrayList<>(numResults); for (int i = 0; i < numResults; i++) { - boolean isFailure = withFailure && randomBoolean(); - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); if (isVerbose) { - int numProcessors = randomIntBetween(1, 10); - List processorResults = new ArrayList<>(numProcessors); - for (int j = 0; j < numProcessors; j++) { - String processorTag = randomAlphaOfLengthBetween(1, 10); - SimulateProcessorResult processorResult; - if (isFailure) { - processorResult = new SimulateProcessorResult(processorTag, new IllegalArgumentException("test")); - } else { - processorResult = new SimulateProcessorResult(processorTag, ingestDocument); - } - processorResults.add(processorResult); - } - results.add(new SimulateDocumentVerboseResult(processorResults)); + results.add( + SimulateDocumentVerboseResultTests.createTestInstance(withFailure) + ); } else { - results.add(new SimulateDocumentBaseResult(ingestDocument)); - SimulateDocumentBaseResult simulateDocumentBaseResult; - if (isFailure) { - simulateDocumentBaseResult = new SimulateDocumentBaseResult(new IllegalArgumentException("test")); - } else { - simulateDocumentBaseResult = new SimulateDocumentBaseResult(ingestDocument); - } - results.add(simulateDocumentBaseResult); + results.add( + SimulateDocumentBaseResultTests.createTestInstance(withFailure && randomBoolean()) + ); } } return new SimulatePipelineResponse(pipelineId, isVerbose, results); @@ -159,14 +141,14 @@ protected void assertEqualInstances(SimulatePipelineResponse response, assertEquals(response.getResults().size(), parsedResponse.getResults().size()); for (int i=0; i < response.getResults().size(); i++) { if (response.isVerbose()) { - assert response.getResults().get(i) instanceof SimulateDocumentVerboseResult; - assert parsedResponse.getResults().get(i) instanceof SimulateDocumentVerboseResult; + assertThat(response.getResults().get(i), instanceOf(SimulateDocumentVerboseResult.class)); + assertThat(parsedResponse.getResults().get(i), instanceOf(SimulateDocumentVerboseResult.class)); SimulateDocumentVerboseResult responseResult = (SimulateDocumentVerboseResult)response.getResults().get(i); SimulateDocumentVerboseResult parsedResult = (SimulateDocumentVerboseResult)parsedResponse.getResults().get(i); SimulateDocumentVerboseResultTests.assertEqualDocs(responseResult, parsedResult); } else { - assert response.getResults().get(i) instanceof SimulateDocumentBaseResult; - assert parsedResponse.getResults().get(i) instanceof SimulateDocumentBaseResult; + assertThat(response.getResults().get(i), instanceOf(SimulateDocumentBaseResult.class)); + assertThat(parsedResponse.getResults().get(i), instanceOf(SimulateDocumentBaseResult.class)); SimulateDocumentBaseResult responseResult = (SimulateDocumentBaseResult)response.getResults().get(i); SimulateDocumentBaseResult parsedResult = (SimulateDocumentBaseResult)parsedResponse.getResults().get(i); SimulateDocumentBaseResultTests.assertEqualDocs(responseResult, parsedResult); @@ -176,8 +158,18 @@ protected void assertEqualInstances(SimulatePipelineResponse response, @Override protected Predicate getRandomFieldsExcludeFilter() { - // We cannot have random fields in the _source field - return field -> field.contains("doc._source") || field.contains("doc._ingest"); + // We cannot have random fields in the _source field and _ingest field + return field -> + field.contains( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.SOURCE_FIELD).toString() + ) || + field.contains( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.INGEST_FIELD).toString() + ); } /** diff --git a/server/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java b/server/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java index 81db521993b7f..2e0d6a75749bb 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java @@ -22,21 +22,21 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.test.AbstractXContentTestCase; import java.io.IOException; +import java.util.StringJoiner; import java.util.function.Predicate; import java.util.function.Supplier; import static org.elasticsearch.ingest.IngestDocumentMatcher.assertIngestDocument; +import static org.elasticsearch.action.ingest.WriteableIngestDocumentTests.createRandomIngestDoc; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.elasticsearch.action.ingest.WriteableIngestDocumentTests.assertEqualIngestDocs; public class SimulateProcessorResultTests extends AbstractXContentTestCase { @@ -67,12 +67,12 @@ public void testSerialization() throws IOException { } } - protected static SimulateProcessorResult createTestInstance(boolean isSuccessful, + static SimulateProcessorResult createTestInstance(boolean isSuccessful, boolean isIgnoredException) { String processorTag = randomAlphaOfLengthBetween(1, 10); SimulateProcessorResult simulateProcessorResult; if (isSuccessful) { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + IngestDocument ingestDocument = createRandomIngestDoc(); if (isIgnoredException) { simulateProcessorResult = new SimulateProcessorResult(processorTag, ingestDocument, new IllegalArgumentException("test")); } else { @@ -109,13 +109,23 @@ protected boolean supportsUnknownFields() { @Override protected Predicate getRandomFieldsExcludeFilter() { // We cannot have random fields in the _source field and _ingest field - return field -> field.contains("doc._source") || field.contains("doc._ingest"); + return field -> + field.startsWith( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.SOURCE_FIELD).toString() + ) || + field.startsWith( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.INGEST_FIELD).toString() + ); } static void assertEqualProcessorResults(SimulateProcessorResult response, SimulateProcessorResult parsedResponse) { assertEquals(response.getProcessorTag(), parsedResponse.getProcessorTag()); - assertEqualIngestDocs(response.getIngestDocument(), parsedResponse.getIngestDocument()); + assertEquals(response.getIngestDocument(), parsedResponse.getIngestDocument()); if (response.getFailure() != null ) { assertNotNull(parsedResponse.getFailure()); assertThat( diff --git a/server/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java b/server/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java index 1f12ba82e53a8..bc4589ff5d36c 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java @@ -26,15 +26,18 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.test.AbstractXContentTestCase; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; +import org.elasticsearch.test.RandomObjects; import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.StringJoiner; +import java.util.function.Predicate; import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; import static org.elasticsearch.ingest.IngestDocumentMatcher.assertIngestDocument; @@ -150,31 +153,21 @@ public void testToXContent() throws IOException { assertThat(serializedIngestDocument, equalTo(serializedIngestDocument)); } - protected static void assertEqualIngestDocs(IngestDocument response, IngestDocument parsedResponse) { - if (response != null && parsedResponse != null) { - ElasticsearchAssertions.assertMapEquals( - response.getSourceAndMetadata(), - parsedResponse.getSourceAndMetadata(), - true - ); - assertEquals(response.getIngestMetadata(), parsedResponse.getIngestMetadata()); - } else if (response == null) { - assertNull(parsedResponse); - } else { - fail("parsed response was null but the expected was non null."); - } - + static IngestDocument createRandomIngestDoc() { + XContentType xContentType = randomFrom(XContentType.values()); + BytesReference sourceBytes = RandomObjects.randomSource(random(), xContentType); + Map randomSource = XContentHelper.convertToMap(sourceBytes, false, xContentType).v2(); + return RandomDocumentPicks.randomIngestDocument(random(), randomSource); } @Override - protected void assertEqualInstances(WriteableIngestDocument response, WriteableIngestDocument parsedResponse) { - assertEqualIngestDocs(response.getIngestDocument(), parsedResponse.getIngestDocument()); + protected boolean supportsUnknownFields() { + return true; } @Override protected WriteableIngestDocument createTestInstance() { - IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); - return new WriteableIngestDocument(new IngestDocument(ingestDocument)); + return new WriteableIngestDocument(createRandomIngestDoc()); } @Override @@ -183,8 +176,18 @@ protected WriteableIngestDocument doParseInstance(XContentParser parser) { } @Override - protected boolean supportsUnknownFields() { - // Cannot support unknown fields because equality changes if new keys are added to _source - return false; + protected Predicate getRandomFieldsExcludeFilter() { + // We cannot have random fields in the _source field and _ingest field + return field -> + field.startsWith( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.SOURCE_FIELD).toString() + ) || + field.startsWith( + new StringJoiner(".") + .add(WriteableIngestDocument.DOC_FIELD) + .add(WriteableIngestDocument.INGEST_FIELD).toString() + ); } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java index a969461554648..cf3cc39d34d88 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java @@ -64,7 +64,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Base64; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -670,10 +669,6 @@ public static void assertToXContentEquivalent(BytesReference expected, BytesRefe * Compares two maps recursively, using arrays comparisons for byte[] through Arrays.equals(byte[], byte[]) */ private static void assertMapEquals(Map expected, Map actual) { - assertMapEquals(expected, actual, false); - } - - public static void assertMapEquals(Map expected, Map actual, boolean convertBase64Strings) { assertEquals(expected.size(), actual.size()); for (Map.Entry expectedEntry : expected.entrySet()) { String expectedKey = expectedEntry.getKey(); @@ -682,7 +677,7 @@ public static void assertMapEquals(Map expected, Map expected, Map expected, List actual, boolean convertBase64Strings) { + private static void assertListEquals(List expected, List actual) { assertEquals(expected.size(), actual.size()); Iterator actualIterator = actual.iterator(); for (Object expectedValue : expected) { Object actualValue = actualIterator.next(); - assertObjectEquals(expectedValue, actualValue, convertBase64Strings); + assertObjectEquals(expectedValue, actualValue); } } @@ -705,21 +700,15 @@ private static void assertListEquals(List expected, List actual, * for byte[] through Arrays.equals(byte[], byte[]) */ @SuppressWarnings("unchecked") - private static void assertObjectEquals(Object expected, Object actual, boolean convertBase64Strings) { + private static void assertObjectEquals(Object expected, Object actual) { if (expected instanceof Map) { assertThat(actual, instanceOf(Map.class)); - assertMapEquals((Map) expected, (Map) actual, convertBase64Strings); + assertMapEquals((Map) expected, (Map) actual); } else if (expected instanceof List) { - assertListEquals((List) expected, (List) actual, convertBase64Strings); + assertListEquals((List) expected, (List) actual); } else if (expected instanceof byte[]) { //byte[] is really a special case for binary values when comparing SMILE and CBOR, arrays of other types //don't need to be handled. Ordinary arrays get parsed as lists. - if (convertBase64Strings && actual instanceof String) { - // for objects deserialized from XContent the content might be a Base64 encoded string - actual = Base64.getDecoder().decode((String)actual); - } else { - assertTrue(actual instanceof byte[]); - } assertArrayEquals((byte[]) expected, (byte[]) actual); } else { assertEquals(expected, actual);