From 88bd740957362ef07b7f37d57c9f9484d241431c Mon Sep 17 00:00:00 2001 From: Henry Coles Date: Wed, 30 Dec 2020 10:14:10 +0000 Subject: [PATCH] make feature names case insensitive --- .../java/org/pitest/plugin/FeatureSelector.java | 4 ++-- .../org/pitest/plugin/FeatureSelectorTest.java | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pitest/src/main/java/org/pitest/plugin/FeatureSelector.java b/pitest/src/main/java/org/pitest/plugin/FeatureSelector.java index ada938722..9a0b3c316 100644 --- a/pitest/src/main/java/org/pitest/plugin/FeatureSelector.java +++ b/pitest/src/main/java/org/pitest/plugin/FeatureSelector.java @@ -25,7 +25,7 @@ public List getActiveFeatures() { public FeatureSetting getSettingForFeature(String feature) { FeatureSetting conf = null; - final Collection groupedSettings = this.settings.get(feature); + final Collection groupedSettings = this.settings.get(feature.toLowerCase()); if (groupedSettings != null) { conf = groupedSettings.iterator().next(); } @@ -65,7 +65,7 @@ private Function byFeatureName() { } private Function byFeature() { - return a -> a.feature(); + return a -> a.feature().toLowerCase(); } } \ No newline at end of file diff --git a/pitest/src/test/java/org/pitest/plugin/FeatureSelectorTest.java b/pitest/src/test/java/org/pitest/plugin/FeatureSelectorTest.java index 54c082a37..3c6de733a 100644 --- a/pitest/src/test/java/org/pitest/plugin/FeatureSelectorTest.java +++ b/pitest/src/test/java/org/pitest/plugin/FeatureSelectorTest.java @@ -38,7 +38,7 @@ public void shouldSelectFeaturesThatAreOffByDefault() { @Test public void shouldEnableFeaturesWhenRequested() { - final FeatureSetting enableBar = new FeatureSetting("bar", ToggleStatus.ACTIVATE, new HashMap>()); + 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); @@ -46,7 +46,7 @@ public void shouldEnableFeaturesWhenRequested() { @Test public void shouldDisableFeaturesWhenRequested() { - final FeatureSetting disableFoo = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap>()); + 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(); @@ -54,13 +54,21 @@ public void shouldDisableFeaturesWhenRequested() { @Test public void shouldProvideConfigurationForFeatureWhenProvided() { - final FeatureSetting fooConfig = new FeatureSetting("foo", ToggleStatus.DEACTIVATE, new HashMap>()); + 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 noSettings() { return Collections.emptyList(); }