|
117 | 117 | import org.reactivestreams.Subscriber; |
118 | 118 | import org.reactivestreams.Subscription; |
119 | 119 |
|
| 120 | +import static org.hamcrest.Matchers.containsString; |
120 | 121 | import static org.hamcrest.Matchers.equalTo; |
121 | 122 | import static org.hamcrest.Matchers.instanceOf; |
122 | 123 | import static org.mockito.ArgumentMatchers.any; |
@@ -794,11 +795,14 @@ public void testExecuteSingleUploadIfEtagMatchesPreconditionFailed() throws IOEx |
794 | 795 | assertNotNull("Expected an exception to be captured", exception); |
795 | 796 | assertTrue(exception instanceof OpenSearchException); |
796 | 797 | OpenSearchException osException = (OpenSearchException) exception; |
797 | | - String msg = osException.getMessage(); |
798 | | - assertTrue( |
799 | | - "expected an S3 precondition‑failure message, got [" + msg + "]", |
800 | | - msg.contains("Precondition Failed") && msg.contains("Etag Mismatch") |
801 | | - ); |
| 798 | + |
| 799 | + // Fix: Update assertion to expect "stale_primary_shard" as the main message |
| 800 | + assertEquals("stale_primary_shard", osException.getMessage()); |
| 801 | + |
| 802 | + // Add assertions for the detailed message content |
| 803 | + assertThat(osException.toString(), containsString("Precondition Failed")); |
| 804 | + assertThat(osException.toString(), containsString("Etag Mismatch")); |
| 805 | + |
802 | 806 | assertEquals(412, ((S3Exception) osException.getCause()).statusCode()); |
803 | 807 | assertEquals("stale_primary_shard", osException.getMetadata("es.error.type").getFirst()); |
804 | 808 | assertEquals(preconditionFailedException, osException.getCause()); |
|
0 commit comments