|
37 | 37 | import java.util.stream.Stream; |
38 | 38 |
|
39 | 39 | import static org.assertj.core.api.Assertions.assertThat; |
| 40 | +import static org.hamcrest.Matchers.equalTo; |
| 41 | +import static org.hamcrest.MatcherAssert.assertThat; |
40 | 42 | import static org.junit.jupiter.api.Assertions.assertThrows; |
| 43 | +import static org.mockito.Mockito.doReturn; |
41 | 44 | import static org.mockito.Mockito.mock; |
| 45 | +import static org.mockito.Mockito.spy; |
42 | 46 | import static org.mockito.Mockito.when; |
43 | 47 |
|
44 | 48 | class DynamicConfigTransformerTest { |
@@ -456,4 +460,23 @@ void test_overlay_directive_overrides_existing_fields() throws Exception { |
456 | 460 | assertThat(resultOs.get("script").get("source").asText()).isEqualTo("ctx._source.merge(params.doc)"); |
457 | 461 | assertThat(resultOs.get("script").has("custom_field")).isFalse(); |
458 | 462 | } |
| 463 | + |
| 464 | + @Test |
| 465 | + void test_calculateDepthForRdsSource_without_source_coordination_identifier() { |
| 466 | + String mockPrefix = "my-bucket/path"; |
| 467 | + DynamicConfigTransformer transformer = spy(new DynamicConfigTransformer(mock(RuleEvaluator.class))); |
| 468 | + doReturn(null).when(transformer).getSourceCoordinationIdentifier(); |
| 469 | + String result = transformer.calculateDepthForRdsSource(mockPrefix); |
| 470 | + assertThat(result, equalTo("4")); |
| 471 | + } |
| 472 | + |
| 473 | + @Test |
| 474 | + void test_calculateDepthForRdsSource_with_source_coordination_identifier() { |
| 475 | + String mockPrefix = "my-bucket/path"; |
| 476 | + DynamicConfigTransformer transformer = spy(new DynamicConfigTransformer(mock(RuleEvaluator.class))); |
| 477 | + doReturn("testValue").when(transformer).getSourceCoordinationIdentifier(); |
| 478 | + String result = transformer.calculateDepthForRdsSource(mockPrefix); |
| 479 | + assertThat(result, equalTo("5")); |
| 480 | + } |
| 481 | + |
459 | 482 | } |
0 commit comments