parent
0c5b07b0ae
commit
e22fbbf175
|
@ -231,7 +231,10 @@ public class Configurations extends AbstractList<Configuration> implements Dumpa
|
|||
|
||||
public Configurations(List<Configuration> configurations)
|
||||
{
|
||||
_configurations = new ArrayList<>(configurations == null ? Collections.emptyList() : configurations);
|
||||
_configurations = new ArrayList<>();
|
||||
//ensure replacements are processed
|
||||
if (configurations != null)
|
||||
configurations.forEach(this::add);
|
||||
}
|
||||
|
||||
public Configurations(Configuration... configurations)
|
||||
|
|
|
@ -135,6 +135,44 @@ public class ConfigurationsTest
|
|||
assertThat(configs.getConfigurations().size(), equalTo(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplacementWithInstances()
|
||||
{
|
||||
//ConfigDick should be replaced by ReplacementDick
|
||||
Configurations configs = new Configurations(
|
||||
new ConfigDick(),
|
||||
new ConfigBar(),
|
||||
new ConfigZ(),
|
||||
new ConfigY(),
|
||||
new ConfigX(),
|
||||
new ConfigTom(),
|
||||
new ReplacementDick(),
|
||||
new ConfigHarry(),
|
||||
new ConfigAdditionalHarry(),
|
||||
new ConfigFoo()
|
||||
);
|
||||
|
||||
configs.sort();
|
||||
|
||||
assertThat(configs.stream().map(c -> c.getClass().getName()).collect(toList()),
|
||||
contains(
|
||||
ConfigFoo.class.getName(),
|
||||
ConfigBar.class.getName(),
|
||||
ConfigX.class.getName(),
|
||||
ConfigY.class.getName(),
|
||||
ConfigZ.class.getName(),
|
||||
ConfigTom.class.getName(),
|
||||
ReplacementDick.class.getName(),
|
||||
ConfigHarry.class.getName(),
|
||||
ConfigAdditionalHarry.class.getName()
|
||||
));
|
||||
|
||||
assertThat(configs.stream().map(c -> c.getClass().getName()).collect(toList()),
|
||||
not(contains(
|
||||
ConfigDick.class.getName()
|
||||
)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplacement()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue