@Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        final CompositePropertySource compositePropertySource = new CompositePropertySource(SOURCE_NAME);
        compositePropertySource.addPropertySource(new OriginRegistrySwitchSource(SOURCE_NAME));
        if (environment.getPropertySources().contains(DYNAMIC_PROPERTY_NAME)) {
            environment.getPropertySources().addAfter(DYNAMIC_PROPERTY_NAME, compositePropertySource);
        } else {
            environment.getPropertySources().addFirst(compositePropertySource);
        }
    }
@Test
    public void test() {
        final SpringEnvironmentProcessor springEnvironmentProcessor = new SpringEnvironmentProcessor();
        final ConfigurableEnvironment environment = Mockito.mock(ConfigurableEnvironment.class);
        final MutablePropertySources propertySources = new MutablePropertySources();
        Mockito.when(environment.getPropertySources()).thenReturn(propertySources);
        springEnvironmentProcessor.postProcessEnvironment(environment, null);
        Assert.assertTrue(propertySources.size() > 0);
        final Optional<Object> sourceName = ReflectUtils.getFieldValue(springEnvironmentProcessor, "SOURCE_NAME");
        Assert.assertTrue(sourceName.isPresent());
        propertySources.remove((String) sourceName.get());
        assertEquals(0, propertySources.size());
        propertySources.addFirst(new CompositePropertySource("test1"));
        propertySources.addFirst(new CompositePropertySource("test2"));
        propertySources.addFirst(new CompositePropertySource("test3"));
        final Optional<Object> dynamicPropertyName = ReflectUtils.getFieldValue(springEnvironmentProcessor, "DYNAMIC_PROPERTY_NAME");
        Assert.assertTrue(dynamicPropertyName.isPresent());
        propertySources.addFirst(new CompositePropertySource((String) dynamicPropertyName.get()));
        springEnvironmentProcessor.postProcessEnvironment(environment, null);
        final Iterator<PropertySource<?>> iterator = propertySources.iterator();
        int index = 2;
        PropertySource<?> expectedSource = null;
        while (iterator.hasNext() && index-- > 0) {
            expectedSource = iterator.next();
        }
        Assert.assertNotNull(expectedSource);
        Assert.assertEquals(expectedSource.getName(), sourceName.get());
    }