public static ApplicationContextInitializer<ConfigurableApplicationContext> dynamicConfigPropertiesInitializer() {
    return appCtx ->
        new DynamicConfigOperations(appCtx)
            .loadDynamicPropertySource()
            .ifPresent(source -> appCtx.getEnvironment().getPropertySources().addFirst(source));
  }
@Test
  void initializerAddsDynamicPropertySourceIfAllEnvVarsAreSet() throws Exception {
    Path propsFilePath = tmpDir.resolve("props.yaml");
    Files.writeString(propsFilePath, SAMPLE_YAML_CONFIG, StandardOpenOption.CREATE);

    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(new MapPropertySource("test", Map.of("testK", "testV")));

    when(envMock.getPropertySources()).thenReturn(propertySources);
    mockEnvWithVars(Map.of(
        DYNAMIC_CONFIG_ENABLED_ENV_PROPERTY, "true",
        DYNAMIC_CONFIG_PATH_ENV_PROPERTY, propsFilePath.toString()
    ));

    DynamicConfigOperations.dynamicConfigPropertiesInitializer().initialize(ctxMock);

    assertThat(propertySources.size()).isEqualTo(2);
    assertThat(propertySources.stream())
        .element(0)
        .extracting(PropertySource::getName)
        .isEqualTo("dynamicProperties");
  }