DefaultConfigurationBuilder implements ConfigurationBuilder { @Override public ConfigurationBuilder increasePriority(PropertySource propertySource) { checkBuilderState(); int index = propertySources.indexOf(propertySource); if(index<0){ throw new IllegalArgumentException("No such PropertySource: " + propertySource); } if(index<(propertySources.size()-1)){ propertySources.remove(propertySource); propertySources.add(index+1, propertySource); } return this; } DefaultConfigurationBuilder();  DefaultConfigurationBuilder(ConfigurationContext context);  DefaultConfigurationBuilder(Configuration configuration); @Override ConfigurationBuilder setClassLoader(ClassLoader classLoader); @Override ClassLoader getClassLoader(); @Override ConfigurationBuilder setServiceContext(ServiceContext serviceContext); ConfigurationBuilder setConfiguration(Configuration configuration); @Override ConfigurationBuilder setContext(ConfigurationContext context); @Override ConfigurationBuilder setMeta(String property, String key, String value); @Override ConfigurationBuilder setMeta(String property, Map<String, String> metaData); @Override ConfigurationBuilder addPropertySources(Collection<PropertySource> sources); ConfigurationBuilder addDefaultPropertyFilters(); ConfigurationBuilder addDefaultPropertySources(); ConfigurationBuilder addDefaultPropertyConverters(); @Override ConfigurationBuilder removePropertySources(Collection<PropertySource> propertySources); @Override List<PropertySource> getPropertySources(); @Override ConfigurationBuilder increasePriority(PropertySource propertySource); @Override ConfigurationBuilder decreasePriority(PropertySource propertySource); @Override ConfigurationBuilder highestPriority(PropertySource propertySource); @Override ConfigurationBuilder lowestPriority(PropertySource propertySource); @Override ConfigurationBuilder addPropertyFilters(Collection<PropertyFilter> filters); @Override ConfigurationBuilder removePropertyFilters(Collection<PropertyFilter> filters); @Override ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
                                                                    Collection<PropertyConverter<T>> converters); @Override ConfigurationBuilder removePropertyConverters(TypeLiteral<?> typeToConvert); @Override ConfigurationBuilder addPropertyConverters(TypeLiteral<T> type, Collection<PropertyConverter<T>> propertyConverters); @Override Configuration build(); @Override ConfigurationBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator); @Override ConfigurationBuilder sortPropertySources(Comparator<PropertySource> comparator); @Override ConfigurationBuilder sortPropertyConverter(Comparator<PropertyConverter> comparator); @Override List<PropertyFilter> getPropertyFilters(); @Override Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverter();  }
@Test public void increasePriority() { DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(); MockedPropertySource[] propertySources = new MockedPropertySource[10]; for (int i = 0; i < propertySources.length; i++) { propertySources[i] = new MockedPropertySource("ps" + i, i); } b.addPropertySources(propertySources); b.increasePriority(propertySources[propertySources.length - 1]); for (int i = 0; i < propertySources.length; i++) { assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } b.increasePriority(propertySources[propertySources.length - 2]).build(); for (int i = 0; i < propertySources.length - 2; i++) { assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]); } assertThat(b.getPropertySources().get(propertySources.length - 2)).isEqualTo(propertySources[propertySources.length - 1]); assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[propertySources.length - 2]); boolean caughtAlreadyBuilt = false; try { b.increasePriority(propertySources[propertySources.length - 2]); } catch (IllegalStateException e) { caughtAlreadyBuilt = true; } assertThat(caughtAlreadyBuilt).isTrue(); }