|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0 and the Server Side Public License, v 1; you may not use this file except |
| 5 | + * in compliance with, at your election, the Elastic License 2.0 or the Server |
| 6 | + * Side Public License, v 1. |
| 7 | + */ |
| 8 | + |
| 9 | +package org.elasticsearch.ingest; |
| 10 | + |
| 11 | +import org.elasticsearch.test.ESTestCase; |
| 12 | + |
| 13 | +import static org.elasticsearch.ingest.TestIngestDocument.emptyIngestDocument; |
| 14 | +import static org.hamcrest.Matchers.equalTo; |
| 15 | +import static org.hamcrest.Matchers.is; |
| 16 | + |
| 17 | +public class LogstashInternalBridgeTests extends ESTestCase { |
| 18 | + public void testIngestDocumentRerouteBridge() { |
| 19 | + final IngestDocument ingestDocument = emptyIngestDocument(); |
| 20 | + ingestDocument.setFieldValue("_index", "nowhere"); |
| 21 | + assertThat(ingestDocument.getFieldValue("_index", String.class), is(equalTo("nowhere"))); |
| 22 | + assertThat(LogstashInternalBridge.isReroute(ingestDocument), is(false)); |
| 23 | + |
| 24 | + ingestDocument.reroute("somewhere"); |
| 25 | + assertThat(ingestDocument.getFieldValue("_index", String.class), is(equalTo("somewhere"))); |
| 26 | + assertThat(LogstashInternalBridge.isReroute(ingestDocument), is(true)); |
| 27 | + |
| 28 | + LogstashInternalBridge.resetReroute(ingestDocument); |
| 29 | + assertThat(ingestDocument.getFieldValue("_index", String.class), is(equalTo("somewhere"))); |
| 30 | + assertThat(LogstashInternalBridge.isReroute(ingestDocument), is(false)); |
| 31 | + } |
| 32 | +} |
0 commit comments