Skip to content

Commit

Permalink
chore: spotlesS
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed May 8, 2024
1 parent 9e557e7 commit e4d1e52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/io/getunleash/FakeUnleash.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public boolean isEnabled(
@Override
public boolean isEnabled(
String toggleName, BiPredicate<String, UnleashContext> fallbackAction) {
if ((!enableAll && !disableAll || excludedFeatures.containsKey(toggleName)) && !features.containsKey(toggleName)) {
if ((!enableAll && !disableAll || excludedFeatures.containsKey(toggleName))
&& !features.containsKey(toggleName)) {
return fallbackAction.test(toggleName, UnleashContext.builder().build());
}
return isEnabled(toggleName);
Expand Down
17 changes: 12 additions & 5 deletions src/test/java/io/getunleash/FakeUnleashTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,30 @@ public void should_countVariant_and_not_throw_an_error() {
}

@Test
public void if_all_is_enabled_should_return_true_even_if_feature_does_not_exist_and_fallback_returns_false() {
public void
if_all_is_enabled_should_return_true_even_if_feature_does_not_exist_and_fallback_returns_false() {
FakeUnleash fakeUnleash = new FakeUnleash();
fakeUnleash.enableAll();
assertThat(fakeUnleash.isEnabled("my.non.existing.feature", (name, context) -> false)).isTrue();
assertThat(fakeUnleash.isEnabled("my.non.existing.feature", (name, context) -> false))
.isTrue();
}

@Test
public void if_all_is_disabled_should_return_false_even_if_feature_does_not_exist_and_fallback_returns_true() {
public void
if_all_is_disabled_should_return_false_even_if_feature_does_not_exist_and_fallback_returns_true() {
FakeUnleash fakeUnleash = new FakeUnleash();
fakeUnleash.disableAll();
assertThat(fakeUnleash.isEnabled("my.non.existing.feature", (name, context) -> true)).isFalse();
assertThat(fakeUnleash.isEnabled("my.non.existing.feature", (name, context) -> true))
.isFalse();
}

@Test
public void all_enabled_and_exclusion_toggle_returns_expected_result() {
FakeUnleash fakeUnleash = new FakeUnleash();
fakeUnleash.enableAllExcept("my.feature.that.should.be.disabled");
assertThat(fakeUnleash.isEnabled("my.feature.that.should.be.disabled", (name, context) -> false)).isFalse();
assertThat(
fakeUnleash.isEnabled(
"my.feature.that.should.be.disabled", (name, context) -> false))
.isFalse();
}
}

0 comments on commit e4d1e52

Please sign in to comment.