|
60 | 60 | import java.util.ArrayList; |
61 | 61 | import java.util.Arrays; |
62 | 62 | import java.util.Collections; |
| 63 | +import java.util.HashSet; |
63 | 64 | import java.util.List; |
64 | 65 | import java.util.Map; |
65 | 66 | import java.util.Set; |
@@ -383,8 +384,8 @@ public boolean matches(Object o) { |
383 | 384 | // the other messages are matched using .+ |
384 | 385 | return message.matches( |
385 | 386 | "(?is).*Error writing to Elasticsearch, some elements could not be inserted" |
386 | | - + ".*Document id .+: failed to parse \\(.+\\).*Caused by: .+ \\(.+\\).*" |
387 | | - + "Document id .+: failed to parse \\(.+\\).*Caused by: .+ \\(.+\\).*"); |
| 387 | + + ".*Document id .+:.*failed to parse.*\\(.+\\).*Caused by: .+ \\(.+\\).*" |
| 388 | + + "Document id .+:.*failed to parse.*\\(.+\\).*Caused by: .+ \\(.+\\).*"); |
388 | 389 | } |
389 | 390 | }); |
390 | 391 |
|
@@ -429,12 +430,15 @@ void testWriteWithErrorsReturned() throws Exception { |
429 | 430 | } |
430 | 431 |
|
431 | 432 | void testWriteWithErrorsReturnedAllowedErrors() throws Exception { |
| 433 | + Set<String> allowedErrors = new HashSet<>(); |
| 434 | + allowedErrors.add("json_parse_exception"); |
| 435 | + allowedErrors.add("document_parsing_exception"); |
432 | 436 | Write write = |
433 | 437 | ElasticsearchIO.write() |
434 | 438 | .withConnectionConfiguration(connectionConfiguration) |
435 | 439 | .withMaxBatchSize(BATCH_SIZE) |
436 | 440 | .withThrowWriteErrors(false) |
437 | | - .withAllowableResponseErrors(Collections.singleton("json_parse_exception")); |
| 441 | + .withAllowableResponseErrors(allowedErrors); |
438 | 442 |
|
439 | 443 | List<String> data = |
440 | 444 | ElasticsearchIOTestUtils.createDocuments( |
@@ -503,11 +507,14 @@ void testWriteWithElasticClientResponseException() throws Exception { |
503 | 507 | } |
504 | 508 |
|
505 | 509 | void testWriteWithAllowedErrors() throws Exception { |
| 510 | + Set<String> allowedErrors = new HashSet<>(); |
| 511 | + allowedErrors.add("json_parse_exception"); |
| 512 | + allowedErrors.add("document_parsing_exception"); |
506 | 513 | Write write = |
507 | 514 | ElasticsearchIO.write() |
508 | 515 | .withConnectionConfiguration(connectionConfiguration) |
509 | 516 | .withMaxBatchSize(BATCH_SIZE) |
510 | | - .withAllowableResponseErrors(Collections.singleton("json_parse_exception")); |
| 517 | + .withAllowableResponseErrors(allowedErrors); |
511 | 518 | List<String> input = |
512 | 519 | ElasticsearchIOTestUtils.createDocuments( |
513 | 520 | numDocs, ElasticsearchIOTestUtils.InjectionMode.INJECT_SOME_INVALID_DOCS); |
|
0 commit comments