28
28
import java .util .HashMap ;
29
29
import java .util .Map ;
30
30
import java .util .concurrent .TimeUnit ;
31
+ import java .util .function .Consumer ;
31
32
import java .util .function .LongSupplier ;
32
33
33
34
import static org .hamcrest .CoreMatchers .equalTo ;
@@ -74,7 +75,7 @@ public void testSingleProcessor() throws Exception {
74
75
}
75
76
76
77
public void testSingleProcessorWithException () throws Exception {
77
- TestProcessor processor = new TestProcessor (ingestDocument -> { throw new RuntimeException ("error" );} );
78
+ TestProcessor processor = new TestProcessor (new RuntimeException ("error" ));
78
79
LongSupplier relativeTimeProvider = mock (LongSupplier .class );
79
80
when (relativeTimeProvider .getAsLong ()).thenReturn (0L );
80
81
CompoundProcessor compoundProcessor = new CompoundProcessor (relativeTimeProvider , processor );
@@ -93,7 +94,7 @@ public void testSingleProcessorWithException() throws Exception {
93
94
}
94
95
95
96
public void testIgnoreFailure () throws Exception {
96
- TestProcessor processor1 = new TestProcessor (ingestDocument -> { throw new RuntimeException ("error" );} );
97
+ TestProcessor processor1 = new TestProcessor (new RuntimeException ("error" ));
97
98
TestProcessor processor2 = new TestProcessor (ingestDocument -> {ingestDocument .setFieldValue ("field" , "value" );});
98
99
LongSupplier relativeTimeProvider = mock (LongSupplier .class );
99
100
when (relativeTimeProvider .getAsLong ()).thenReturn (0L );
@@ -108,7 +109,7 @@ public void testIgnoreFailure() throws Exception {
108
109
}
109
110
110
111
public void testSingleProcessorWithOnFailureProcessor () throws Exception {
111
- TestProcessor processor1 = new TestProcessor ("id" , "first" , ingestDocument -> { throw new RuntimeException ("error" );} );
112
+ TestProcessor processor1 = new TestProcessor ("id" , "first" , new RuntimeException ("error" ));
112
113
TestProcessor processor2 = new TestProcessor (ingestDocument -> {
113
114
Map <String , Object > ingestMetadata = ingestDocument .getIngestMetadata ();
114
115
assertThat (ingestMetadata .size (), equalTo (3 ));
@@ -130,7 +131,7 @@ public void testSingleProcessorWithOnFailureProcessor() throws Exception {
130
131
}
131
132
132
133
public void testSingleProcessorWithOnFailureDropProcessor () throws Exception {
133
- TestProcessor processor1 = new TestProcessor ("id" , "first" , ingestDocument -> { throw new RuntimeException ("error" );} );
134
+ TestProcessor processor1 = new TestProcessor ("id" , "first" , new RuntimeException ("error" ));
134
135
Processor processor2 = new Processor () {
135
136
@ Override
136
137
public IngestDocument execute (IngestDocument ingestDocument ) throws Exception {
@@ -159,8 +160,8 @@ public String getTag() {
159
160
}
160
161
161
162
public void testSingleProcessorWithNestedFailures () throws Exception {
162
- TestProcessor processor = new TestProcessor ("id" , "first" , ingestDocument -> { throw new RuntimeException ("error" );} );
163
- TestProcessor processorToFail = new TestProcessor ("id2" , "second" , ingestDocument -> {
163
+ TestProcessor processor = new TestProcessor ("id" , "first" , new RuntimeException ("error" ));
164
+ TestProcessor processorToFail = new TestProcessor ("id2" , "second" , ( Consumer < IngestDocument >) ingestDocument -> {
164
165
Map <String , Object > ingestMetadata = ingestDocument .getIngestMetadata ();
165
166
assertThat (ingestMetadata .size (), equalTo (3 ));
166
167
assertThat (ingestMetadata .get (CompoundProcessor .ON_FAILURE_MESSAGE_FIELD ), equalTo ("error" ));
@@ -189,7 +190,7 @@ public void testSingleProcessorWithNestedFailures() throws Exception {
189
190
}
190
191
191
192
public void testCompoundProcessorExceptionFailWithoutOnFailure () throws Exception {
192
- TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , ingestDocument -> { throw new RuntimeException ("error" );} );
193
+ TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , new RuntimeException ("error" ));
193
194
TestProcessor secondProcessor = new TestProcessor ("id3" , "second" , ingestDocument -> {
194
195
Map <String , Object > ingestMetadata = ingestDocument .getIngestMetadata ();
195
196
assertThat (ingestMetadata .entrySet (), hasSize (3 ));
@@ -212,9 +213,9 @@ public void testCompoundProcessorExceptionFailWithoutOnFailure() throws Exceptio
212
213
}
213
214
214
215
public void testCompoundProcessorExceptionFail () throws Exception {
215
- TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , ingestDocument -> { throw new RuntimeException ("error" );} );
216
+ TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , new RuntimeException ("error" ));
216
217
TestProcessor failProcessor =
217
- new TestProcessor ("tag_fail" , "fail" , ingestDocument -> { throw new RuntimeException ("custom error message" );} );
218
+ new TestProcessor ("tag_fail" , "fail" , new RuntimeException ("custom error message" ));
218
219
TestProcessor secondProcessor = new TestProcessor ("id3" , "second" , ingestDocument -> {
219
220
Map <String , Object > ingestMetadata = ingestDocument .getIngestMetadata ();
220
221
assertThat (ingestMetadata .entrySet (), hasSize (3 ));
@@ -238,9 +239,9 @@ public void testCompoundProcessorExceptionFail() throws Exception {
238
239
}
239
240
240
241
public void testCompoundProcessorExceptionFailInOnFailure () throws Exception {
241
- TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , ingestDocument -> { throw new RuntimeException ("error" );} );
242
+ TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , new RuntimeException ("error" ));
242
243
TestProcessor failProcessor =
243
- new TestProcessor ("tag_fail" , "fail" , ingestDocument -> { throw new RuntimeException ("custom error message" );} );
244
+ new TestProcessor ("tag_fail" , "fail" , new RuntimeException ("custom error message" ));
244
245
TestProcessor secondProcessor = new TestProcessor ("id3" , "second" , ingestDocument -> {
245
246
Map <String , Object > ingestMetadata = ingestDocument .getIngestMetadata ();
246
247
assertThat (ingestMetadata .entrySet (), hasSize (3 ));
@@ -264,8 +265,8 @@ public void testCompoundProcessorExceptionFailInOnFailure() throws Exception {
264
265
}
265
266
266
267
public void testBreakOnFailure () throws Exception {
267
- TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , ingestDocument -> { throw new RuntimeException ("error1" );} );
268
- TestProcessor secondProcessor = new TestProcessor ("id2" , "second" , ingestDocument -> { throw new RuntimeException ("error2" );} );
268
+ TestProcessor firstProcessor = new TestProcessor ("id1" , "first" , new RuntimeException ("error1" ));
269
+ TestProcessor secondProcessor = new TestProcessor ("id2" , "second" , new RuntimeException ("error2" ));
269
270
TestProcessor onFailureProcessor = new TestProcessor ("id2" , "on_failure" , ingestDocument -> {});
270
271
LongSupplier relativeTimeProvider = mock (LongSupplier .class );
271
272
when (relativeTimeProvider .getAsLong ()).thenReturn (0L );
0 commit comments