Skip to content

Commit

Permalink
make feature names case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles authored and hcoles committed Dec 30, 2020
1 parent e34ca99 commit 88bd740
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pitest/src/main/java/org/pitest/plugin/FeatureSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public List<T> getActiveFeatures() {

public FeatureSetting getSettingForFeature(String feature) {
FeatureSetting conf = null;
final Collection<FeatureSetting> groupedSettings = this.settings.get(feature);
final Collection<FeatureSetting> groupedSettings = this.settings.get(feature.toLowerCase());
if (groupedSettings != null) {
conf = groupedSettings.iterator().next();
}
Expand Down Expand Up @@ -65,7 +65,7 @@ private Function<T, String> byFeatureName() {
}

private Function<FeatureSetting, String> byFeature() {
return a -> a.feature();
return a -> a.feature().toLowerCase();
}

}
14 changes: 11 additions & 3 deletions pitest/src/test/java/org/pitest/plugin/FeatureSelectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,37 @@ public void shouldSelectFeaturesThatAreOffByDefault() {

@Test
public void shouldEnableFeaturesWhenRequested() {
final FeatureSetting enableBar = new FeatureSetting("bar", ToggleStatus.ACTIVATE, new HashMap<String, List<String>>());
final FeatureSetting enableBar = new FeatureSetting("bar", ToggleStatus.ACTIVATE, new HashMap<>());
this.testee = new FeatureSelector<>(Arrays.asList(enableBar), features(this.onByDefault, this.offByDefault));

assertThat(this.testee.getActiveFeatures()).containsOnly(this.offByDefault, this.onByDefault);
}

@Test
public void shouldDisableFeaturesWhenRequested() {
final FeatureSetting disableFoo = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap<String, List<String>>());
final FeatureSetting disableFoo = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap<>());
this.testee = new FeatureSelector<>(Arrays.asList(disableFoo), features(this.onByDefault));

assertThat(this.testee.getActiveFeatures()).isEmpty();
}

@Test
public void shouldProvideConfigurationForFeatureWhenProvided() {
final FeatureSetting fooConfig = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap<String, List<String>>());
final FeatureSetting fooConfig = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap<>());
this.testee = new FeatureSelector<>(Arrays.asList(fooConfig), features(this.onByDefault));

assertThat(this.testee.getSettingForFeature("foo")).isEqualTo(fooConfig);
assertThat(this.testee.getSettingForFeature("bar")).isNull();
}

@Test
public void featureNamesAreCaseInsensitive() {
final FeatureSetting fooConfig = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap<>());
this.testee = new FeatureSelector<>(Arrays.asList(fooConfig), features(this.onByDefault));

assertThat(this.testee.getSettingForFeature("FOO")).isEqualTo(fooConfig);
}

private List<FeatureSetting> noSettings() {
return Collections.emptyList();
}
Expand Down

0 comments on commit 88bd740

Please sign in to comment.