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