Rename Data leftovers

This commit is contained in:
javanna 2015-11-24 15:49:25 +01:00 committed by Luca Cavanna
parent 8f1f5d4da0
commit 49bfe6410e
10 changed files with 60 additions and 61 deletions

View File

@ -35,31 +35,31 @@ import static org.elasticsearch.ingest.IngestDocument.MetaData.ID;
import static org.elasticsearch.ingest.IngestDocument.MetaData.INDEX; import static org.elasticsearch.ingest.IngestDocument.MetaData.INDEX;
import static org.elasticsearch.ingest.IngestDocument.MetaData.TYPE; import static org.elasticsearch.ingest.IngestDocument.MetaData.TYPE;
public class TransportData implements Writeable<TransportData>, ToXContent { public class WriteableIngestDocument implements Writeable<WriteableIngestDocument>, ToXContent {
private static final TransportData PROTOTYPE = new TransportData(null); private static final WriteableIngestDocument PROTOTYPE = new WriteableIngestDocument(null);
private final IngestDocument ingestDocument; private final IngestDocument ingestDocument;
public TransportData(IngestDocument ingestDocument) { public WriteableIngestDocument(IngestDocument ingestDocument) {
this.ingestDocument = ingestDocument; this.ingestDocument = ingestDocument;
} }
public IngestDocument get() { public IngestDocument getIngestDocument() {
return ingestDocument; return ingestDocument;
} }
public static TransportData readTransportDataFrom(StreamInput in) throws IOException { public static WriteableIngestDocument readWriteableIngestDocumentFrom(StreamInput in) throws IOException {
return PROTOTYPE.readFrom(in); return PROTOTYPE.readFrom(in);
} }
@Override @Override
public TransportData readFrom(StreamInput in) throws IOException { public WriteableIngestDocument readFrom(StreamInput in) throws IOException {
String index = in.readString(); String index = in.readString();
String type = in.readString(); String type = in.readString();
String id = in.readString(); String id = in.readString();
Map<String, Object> doc = in.readMap(); Map<String, Object> doc = in.readMap();
return new TransportData(new IngestDocument(index, type, id, doc)); return new WriteableIngestDocument(new IngestDocument(index, type, id, doc));
} }
@Override @Override
@ -90,7 +90,7 @@ public class TransportData implements Writeable<TransportData>, ToXContent {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
TransportData that = (TransportData) o; WriteableIngestDocument that = (WriteableIngestDocument) o;
return Objects.equals(ingestDocument, that.ingestDocument); return Objects.equals(ingestDocument, that.ingestDocument);
} }

View File

@ -23,7 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.plugin.ingest.transport.TransportData; import org.elasticsearch.plugin.ingest.transport.WriteableIngestDocument;
import java.io.IOException; import java.io.IOException;
@ -31,26 +31,26 @@ public class SimulateDocumentSimpleResult implements SimulateDocumentResult<Simu
private static final SimulateDocumentSimpleResult PROTOTYPE = new SimulateDocumentSimpleResult((IngestDocument)null); private static final SimulateDocumentSimpleResult PROTOTYPE = new SimulateDocumentSimpleResult((IngestDocument)null);
private TransportData data; private WriteableIngestDocument ingestDocument;
private Exception failure; private Exception failure;
public SimulateDocumentSimpleResult(IngestDocument ingestDocument) { public SimulateDocumentSimpleResult(IngestDocument ingestDocument) {
this.data = new TransportData(ingestDocument); this.ingestDocument = new WriteableIngestDocument(ingestDocument);
} }
private SimulateDocumentSimpleResult(TransportData data) { private SimulateDocumentSimpleResult(WriteableIngestDocument ingestDocument) {
this.data = data; this.ingestDocument = ingestDocument;
} }
public SimulateDocumentSimpleResult(Exception failure) { public SimulateDocumentSimpleResult(Exception failure) {
this.failure = failure; this.failure = failure;
} }
public IngestDocument getData() { public IngestDocument getIngestDocument() {
if (data == null) { if (ingestDocument == null) {
return null; return null;
} }
return data.get(); return ingestDocument.getIngestDocument();
} }
public Exception getFailure() { public Exception getFailure() {
@ -67,14 +67,14 @@ public class SimulateDocumentSimpleResult implements SimulateDocumentResult<Simu
Exception exception = in.readThrowable(); Exception exception = in.readThrowable();
return new SimulateDocumentSimpleResult(exception); return new SimulateDocumentSimpleResult(exception);
} }
return new SimulateDocumentSimpleResult(TransportData.readTransportDataFrom(in)); return new SimulateDocumentSimpleResult(WriteableIngestDocument.readWriteableIngestDocumentFrom(in));
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
if (failure == null) { if (failure == null) {
out.writeBoolean(false); out.writeBoolean(false);
data.writeTo(out); ingestDocument.writeTo(out);
} else { } else {
out.writeBoolean(true); out.writeBoolean(true);
out.writeThrowable(failure); out.writeThrowable(failure);
@ -85,7 +85,7 @@ public class SimulateDocumentSimpleResult implements SimulateDocumentResult<Simu
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(); builder.startObject();
if (failure == null) { if (failure == null) {
data.toXContent(builder, params); ingestDocument.toXContent(builder, params);
} else { } else {
ElasticsearchException.renderThrowable(builder, params, failure); ElasticsearchException.renderThrowable(builder, params, failure);
} }

View File

@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.plugin.ingest.transport.TransportData; import org.elasticsearch.plugin.ingest.transport.WriteableIngestDocument;
import java.io.IOException; import java.io.IOException;
@ -35,17 +35,17 @@ public class SimulateProcessorResult implements Writeable<SimulateProcessorResul
private static final SimulateProcessorResult PROTOTYPE = new SimulateProcessorResult(null, (IngestDocument)null); private static final SimulateProcessorResult PROTOTYPE = new SimulateProcessorResult(null, (IngestDocument)null);
private String processorId; private String processorId;
private TransportData data; private WriteableIngestDocument ingestDocument;
private Exception failure; private Exception failure;
public SimulateProcessorResult(String processorId, IngestDocument ingestDocument) { public SimulateProcessorResult(String processorId, IngestDocument ingestDocument) {
this.processorId = processorId; this.processorId = processorId;
this.data = new TransportData(ingestDocument); this.ingestDocument = new WriteableIngestDocument(ingestDocument);
} }
private SimulateProcessorResult(String processorId, TransportData data) { private SimulateProcessorResult(String processorId, WriteableIngestDocument ingestDocument) {
this.processorId = processorId; this.processorId = processorId;
this.data = data; this.ingestDocument = ingestDocument;
} }
public SimulateProcessorResult(String processorId, Exception failure) { public SimulateProcessorResult(String processorId, Exception failure) {
@ -53,11 +53,11 @@ public class SimulateProcessorResult implements Writeable<SimulateProcessorResul
this.failure = failure; this.failure = failure;
} }
public IngestDocument getData() { public IngestDocument getIngestDocument() {
if (data == null) { if (ingestDocument == null) {
return null; return null;
} }
return data.get(); return ingestDocument.getIngestDocument();
} }
public String getProcessorId() { public String getProcessorId() {
@ -79,7 +79,7 @@ public class SimulateProcessorResult implements Writeable<SimulateProcessorResul
Exception exception = in.readThrowable(); Exception exception = in.readThrowable();
return new SimulateProcessorResult(processorId, exception); return new SimulateProcessorResult(processorId, exception);
} }
return new SimulateProcessorResult(processorId, TransportData.readTransportDataFrom(in)); return new SimulateProcessorResult(processorId, WriteableIngestDocument.readWriteableIngestDocumentFrom(in));
} }
@Override @Override
@ -87,7 +87,7 @@ public class SimulateProcessorResult implements Writeable<SimulateProcessorResul
out.writeString(processorId); out.writeString(processorId);
if (failure == null) { if (failure == null) {
out.writeBoolean(false); out.writeBoolean(false);
data.writeTo(out); ingestDocument.writeTo(out);
} else { } else {
out.writeBoolean(true); out.writeBoolean(true);
out.writeThrowable(failure); out.writeThrowable(failure);
@ -99,7 +99,7 @@ public class SimulateProcessorResult implements Writeable<SimulateProcessorResul
builder.startObject(); builder.startObject();
builder.field(Fields.PROCESSOR_ID, processorId); builder.field(Fields.PROCESSOR_ID, processorId);
if (failure == null) { if (failure == null) {
data.toXContent(builder, params); ingestDocument.toXContent(builder, params);
} else { } else {
ElasticsearchException.renderThrowable(builder, params, failure); ElasticsearchException.renderThrowable(builder, params, failure);
} }

View File

@ -24,7 +24,6 @@ import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.action.update.UpdateResponse;
@ -116,7 +115,7 @@ public class IngestClientIT extends ESIntegTestCase {
assertThat(response.getResults().get(0), instanceOf(SimulateDocumentSimpleResult.class)); assertThat(response.getResults().get(0), instanceOf(SimulateDocumentSimpleResult.class));
SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) response.getResults().get(0); SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) response.getResults().get(0);
IngestDocument expectedIngestDocument = new IngestDocument("index", "type", "id", Collections.singletonMap("foo", "bar")); IngestDocument expectedIngestDocument = new IngestDocument("index", "type", "id", Collections.singletonMap("foo", "bar"));
assertThat(simulateDocumentSimpleResult.getData(), equalTo(expectedIngestDocument)); assertThat(simulateDocumentSimpleResult.getIngestDocument(), equalTo(expectedIngestDocument));
assertThat(simulateDocumentSimpleResult.getFailure(), nullValue()); assertThat(simulateDocumentSimpleResult.getFailure(), nullValue());
} }

View File

@ -28,12 +28,12 @@ import java.util.Map;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
public class DataTests extends ESTestCase { public class IngestDocumentTests extends ESTestCase {
private IngestDocument ingestDocument; private IngestDocument ingestDocument;
@Before @Before
public void setData() { public void setIngestDocument() {
Map<String, Object> document = new HashMap<>(); Map<String, Object> document = new HashMap<>();
document.put("foo", "bar"); document.put("foo", "bar");
document.put("int", 123); document.put("int", 123);

View File

@ -31,7 +31,7 @@ import java.util.Map;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
public class TransportDataTests extends ESTestCase { public class WriteableIngestDocumentTests extends ESTestCase {
public void testEqualsAndHashcode() throws Exception { public void testEqualsAndHashcode() throws Exception {
String index = randomAsciiOfLengthBetween(1, 10); String index = randomAsciiOfLengthBetween(1, 10);
@ -39,7 +39,7 @@ public class TransportDataTests extends ESTestCase {
String id = randomAsciiOfLengthBetween(1, 10); String id = randomAsciiOfLengthBetween(1, 10);
String fieldName = randomAsciiOfLengthBetween(1, 10); String fieldName = randomAsciiOfLengthBetween(1, 10);
String fieldValue = randomAsciiOfLengthBetween(1, 10); String fieldValue = randomAsciiOfLengthBetween(1, 10);
TransportData transportData = new TransportData(new IngestDocument(index, type, id, Collections.singletonMap(fieldName, fieldValue))); WriteableIngestDocument writeableIngestDocument = new WriteableIngestDocument(new IngestDocument(index, type, id, Collections.singletonMap(fieldName, fieldValue)));
boolean changed = false; boolean changed = false;
String otherIndex; String otherIndex;
@ -71,28 +71,28 @@ public class TransportDataTests extends ESTestCase {
document = Collections.singletonMap(fieldName, fieldValue); document = Collections.singletonMap(fieldName, fieldValue);
} }
TransportData otherTransportData = new TransportData(new IngestDocument(otherIndex, otherType, otherId, document)); WriteableIngestDocument otherWriteableIngestDocument = new WriteableIngestDocument(new IngestDocument(otherIndex, otherType, otherId, document));
if (changed) { if (changed) {
assertThat(transportData, not(equalTo(otherTransportData))); assertThat(writeableIngestDocument, not(equalTo(otherWriteableIngestDocument)));
assertThat(otherTransportData, not(equalTo(transportData))); assertThat(otherWriteableIngestDocument, not(equalTo(writeableIngestDocument)));
} else { } else {
assertThat(transportData, equalTo(otherTransportData)); assertThat(writeableIngestDocument, equalTo(otherWriteableIngestDocument));
assertThat(otherTransportData, equalTo(transportData)); assertThat(otherWriteableIngestDocument, equalTo(writeableIngestDocument));
TransportData thirdTransportData = new TransportData(new IngestDocument(index, type, id, Collections.singletonMap(fieldName, fieldValue))); WriteableIngestDocument thirdWriteableIngestDocument = new WriteableIngestDocument(new IngestDocument(index, type, id, Collections.singletonMap(fieldName, fieldValue)));
assertThat(thirdTransportData, equalTo(transportData)); assertThat(thirdWriteableIngestDocument, equalTo(writeableIngestDocument));
assertThat(transportData, equalTo(thirdTransportData)); assertThat(writeableIngestDocument, equalTo(thirdWriteableIngestDocument));
} }
} }
public void testSerialization() throws IOException { public void testSerialization() throws IOException {
IngestDocument ingestDocument = new IngestDocument(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10), IngestDocument ingestDocument = new IngestDocument(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10),
Collections.singletonMap(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10))); Collections.singletonMap(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10)));
TransportData transportData = new TransportData(ingestDocument); WriteableIngestDocument writeableIngestDocument = new WriteableIngestDocument(ingestDocument);
BytesStreamOutput out = new BytesStreamOutput(); BytesStreamOutput out = new BytesStreamOutput();
transportData.writeTo(out); writeableIngestDocument.writeTo(out);
StreamInput streamInput = StreamInput.wrap(out.bytes()); StreamInput streamInput = StreamInput.wrap(out.bytes());
TransportData otherTransportData = TransportData.readTransportDataFrom(streamInput); WriteableIngestDocument otherWriteableIngestDocument = WriteableIngestDocument.readWriteableIngestDocumentFrom(streamInput);
assertThat(otherTransportData, equalTo(transportData)); assertThat(otherWriteableIngestDocument, equalTo(writeableIngestDocument));
} }
} }

View File

@ -48,7 +48,7 @@ public class SimulateDocumentSimpleResultTests extends ESTestCase {
StreamInput streamInput = StreamInput.wrap(out.bytes()); StreamInput streamInput = StreamInput.wrap(out.bytes());
SimulateDocumentSimpleResult otherSimulateDocumentSimpleResult = SimulateDocumentSimpleResult.readSimulateDocumentSimpleResult(streamInput); SimulateDocumentSimpleResult otherSimulateDocumentSimpleResult = SimulateDocumentSimpleResult.readSimulateDocumentSimpleResult(streamInput);
assertThat(otherSimulateDocumentSimpleResult.getData(), equalTo(simulateDocumentSimpleResult.getData())); assertThat(otherSimulateDocumentSimpleResult.getIngestDocument(), equalTo(simulateDocumentSimpleResult.getIngestDocument()));
if (isFailure) { if (isFailure) {
assertThat(otherSimulateDocumentSimpleResult.getFailure(), instanceOf(IllegalArgumentException.class)); assertThat(otherSimulateDocumentSimpleResult.getFailure(), instanceOf(IllegalArgumentException.class));
IllegalArgumentException e = (IllegalArgumentException) otherSimulateDocumentSimpleResult.getFailure(); IllegalArgumentException e = (IllegalArgumentException) otherSimulateDocumentSimpleResult.getFailure();

View File

@ -68,12 +68,12 @@ public class SimulateExecutionServiceTests extends ESTestCase {
SimulateDocumentVerboseResult simulateDocumentVerboseResult = (SimulateDocumentVerboseResult) actualItemResponse; SimulateDocumentVerboseResult simulateDocumentVerboseResult = (SimulateDocumentVerboseResult) actualItemResponse;
assertThat(simulateDocumentVerboseResult.getProcessorResults().size(), equalTo(2)); assertThat(simulateDocumentVerboseResult.getProcessorResults().size(), equalTo(2));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getProcessorId(), equalTo("processor[mock]-0")); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getProcessorId(), equalTo("processor[mock]-0"));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getData(), not(sameInstance(ingestDocument))); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getIngestDocument(), not(sameInstance(ingestDocument)));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getData(), equalTo(ingestDocument)); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getIngestDocument(), equalTo(ingestDocument));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure(), nullValue()); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure(), nullValue());
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getProcessorId(), equalTo("processor[mock]-1")); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getProcessorId(), equalTo("processor[mock]-1"));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getData(), not(sameInstance(ingestDocument))); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getIngestDocument(), not(sameInstance(ingestDocument)));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getData(), equalTo(ingestDocument)); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getIngestDocument(), equalTo(ingestDocument));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getFailure(), nullValue()); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getFailure(), nullValue());
} }
@ -82,7 +82,7 @@ public class SimulateExecutionServiceTests extends ESTestCase {
verify(processor, times(2)).execute(ingestDocument); verify(processor, times(2)).execute(ingestDocument);
assertThat(actualItemResponse, instanceOf(SimulateDocumentSimpleResult.class)); assertThat(actualItemResponse, instanceOf(SimulateDocumentSimpleResult.class));
SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) actualItemResponse; SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) actualItemResponse;
assertThat(simulateDocumentSimpleResult.getData(), equalTo(ingestDocument)); assertThat(simulateDocumentSimpleResult.getIngestDocument(), equalTo(ingestDocument));
assertThat(simulateDocumentSimpleResult.getFailure(), nullValue()); assertThat(simulateDocumentSimpleResult.getFailure(), nullValue());
} }
@ -95,13 +95,13 @@ public class SimulateExecutionServiceTests extends ESTestCase {
SimulateDocumentVerboseResult simulateDocumentVerboseResult = (SimulateDocumentVerboseResult) actualItemResponse; SimulateDocumentVerboseResult simulateDocumentVerboseResult = (SimulateDocumentVerboseResult) actualItemResponse;
assertThat(simulateDocumentVerboseResult.getProcessorResults().size(), equalTo(2)); assertThat(simulateDocumentVerboseResult.getProcessorResults().size(), equalTo(2));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getProcessorId(), equalTo("processor[mock]-0")); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getProcessorId(), equalTo("processor[mock]-0"));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getData(), nullValue()); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getIngestDocument(), nullValue());
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure(), instanceOf(RuntimeException.class)); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure(), instanceOf(RuntimeException.class));
RuntimeException runtimeException = (RuntimeException) simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure(); RuntimeException runtimeException = (RuntimeException) simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure();
assertThat(runtimeException.getMessage(), equalTo("processor failed")); assertThat(runtimeException.getMessage(), equalTo("processor failed"));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getProcessorId(), equalTo("processor[mock]-1")); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getProcessorId(), equalTo("processor[mock]-1"));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getData(), not(sameInstance(ingestDocument))); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getIngestDocument(), not(sameInstance(ingestDocument)));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getData(), equalTo(ingestDocument)); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getIngestDocument(), equalTo(ingestDocument));
assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getFailure(), nullValue()); assertThat(simulateDocumentVerboseResult.getProcessorResults().get(1).getFailure(), nullValue());
runtimeException = (RuntimeException) simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure(); runtimeException = (RuntimeException) simulateDocumentVerboseResult.getProcessorResults().get(0).getFailure();
assertThat(runtimeException.getMessage(), equalTo("processor failed")); assertThat(runtimeException.getMessage(), equalTo("processor failed"));
@ -114,7 +114,7 @@ public class SimulateExecutionServiceTests extends ESTestCase {
verify(processor, times(1)).execute(ingestDocument); verify(processor, times(1)).execute(ingestDocument);
assertThat(actualItemResponse, instanceOf(SimulateDocumentSimpleResult.class)); assertThat(actualItemResponse, instanceOf(SimulateDocumentSimpleResult.class));
SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) actualItemResponse; SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) actualItemResponse;
assertThat(simulateDocumentSimpleResult.getData(), nullValue()); assertThat(simulateDocumentSimpleResult.getIngestDocument(), nullValue());
assertThat(simulateDocumentSimpleResult.getFailure(), instanceOf(RuntimeException.class)); assertThat(simulateDocumentSimpleResult.getFailure(), instanceOf(RuntimeException.class));
RuntimeException runtimeException = (RuntimeException) simulateDocumentSimpleResult.getFailure(); RuntimeException runtimeException = (RuntimeException) simulateDocumentSimpleResult.getFailure();
assertThat(runtimeException.getMessage(), equalTo("processor failed")); assertThat(runtimeException.getMessage(), equalTo("processor failed"));

View File

@ -91,7 +91,7 @@ public class SimulatePipelineResponseTests extends ESTestCase {
for (SimulateProcessorResult simulateProcessorResult : simulateDocumentVerboseResult.getProcessorResults()) { for (SimulateProcessorResult simulateProcessorResult : simulateDocumentVerboseResult.getProcessorResults()) {
SimulateProcessorResult expectedProcessorResult = expectedProcessorResultIterator.next(); SimulateProcessorResult expectedProcessorResult = expectedProcessorResultIterator.next();
assertThat(simulateProcessorResult.getProcessorId(), equalTo(expectedProcessorResult.getProcessorId())); assertThat(simulateProcessorResult.getProcessorId(), equalTo(expectedProcessorResult.getProcessorId()));
assertThat(simulateProcessorResult.getData(), equalTo(expectedProcessorResult.getData())); assertThat(simulateProcessorResult.getIngestDocument(), equalTo(expectedProcessorResult.getIngestDocument()));
if (expectedProcessorResult.getFailure() == null) { if (expectedProcessorResult.getFailure() == null) {
assertThat(simulateProcessorResult.getFailure(), nullValue()); assertThat(simulateProcessorResult.getFailure(), nullValue());
} else { } else {
@ -104,7 +104,7 @@ public class SimulatePipelineResponseTests extends ESTestCase {
SimulateDocumentSimpleResult expectedSimulateDocumentSimpleResult = (SimulateDocumentSimpleResult) expectedResultIterator.next(); SimulateDocumentSimpleResult expectedSimulateDocumentSimpleResult = (SimulateDocumentSimpleResult) expectedResultIterator.next();
assertThat(result, instanceOf(SimulateDocumentSimpleResult.class)); assertThat(result, instanceOf(SimulateDocumentSimpleResult.class));
SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) result; SimulateDocumentSimpleResult simulateDocumentSimpleResult = (SimulateDocumentSimpleResult) result;
assertThat(simulateDocumentSimpleResult.getData(), equalTo(expectedSimulateDocumentSimpleResult.getData())); assertThat(simulateDocumentSimpleResult.getIngestDocument(), equalTo(expectedSimulateDocumentSimpleResult.getIngestDocument()));
if (expectedSimulateDocumentSimpleResult.getFailure() == null) { if (expectedSimulateDocumentSimpleResult.getFailure() == null) {
assertThat(simulateDocumentSimpleResult.getFailure(), nullValue()); assertThat(simulateDocumentSimpleResult.getFailure(), nullValue());
} else { } else {

View File

@ -49,7 +49,7 @@ public class SimulateProcessorResultTests extends ESTestCase {
StreamInput streamInput = StreamInput.wrap(out.bytes()); StreamInput streamInput = StreamInput.wrap(out.bytes());
SimulateProcessorResult otherSimulateProcessorResult = SimulateProcessorResult.readSimulateProcessorResultFrom(streamInput); SimulateProcessorResult otherSimulateProcessorResult = SimulateProcessorResult.readSimulateProcessorResultFrom(streamInput);
assertThat(otherSimulateProcessorResult.getProcessorId(), equalTo(simulateProcessorResult.getProcessorId())); assertThat(otherSimulateProcessorResult.getProcessorId(), equalTo(simulateProcessorResult.getProcessorId()));
assertThat(otherSimulateProcessorResult.getData(), equalTo(simulateProcessorResult.getData())); assertThat(otherSimulateProcessorResult.getIngestDocument(), equalTo(simulateProcessorResult.getIngestDocument()));
if (isFailure) { if (isFailure) {
assertThat(otherSimulateProcessorResult.getFailure(), instanceOf(IllegalArgumentException.class)); assertThat(otherSimulateProcessorResult.getFailure(), instanceOf(IllegalArgumentException.class));
IllegalArgumentException e = (IllegalArgumentException) otherSimulateProcessorResult.getFailure(); IllegalArgumentException e = (IllegalArgumentException) otherSimulateProcessorResult.getFailure();