diff --git a/src/main/java/org/kiwiproject/consul/option/DeleteOptions.java b/src/main/java/org/kiwiproject/consul/option/DeleteOptions.java index 16c17a9..125c9dd 100644 --- a/src/main/java/org/kiwiproject/consul/option/DeleteOptions.java +++ b/src/main/java/org/kiwiproject/consul/option/DeleteOptions.java @@ -20,7 +20,7 @@ public abstract class DeleteOptions implements ParamAdder { @Value.Derived public boolean isRecurse() { - return getRecurse().isPresent(); + return getRecurse().orElse(false); } @Override diff --git a/src/test/java/org/kiwiproject/consul/option/DeleteOptionsTest.java b/src/test/java/org/kiwiproject/consul/option/DeleteOptionsTest.java new file mode 100644 index 0000000..5a67e8d --- /dev/null +++ b/src/test/java/org/kiwiproject/consul/option/DeleteOptionsTest.java @@ -0,0 +1,32 @@ +package org.kiwiproject.consul.option; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +@DisplayName("DeleteOptions") +class DeleteOptionsTest { + + @Nested + class IsRecurse { + + @Test + void shouldReturnFalse_WhenGetRecurseReturnsEmptyOptional() { + var deleteOptions = ImmutableDeleteOptions.builder().build(); + assertThat(deleteOptions.getRecurse()).isEmpty(); + assertThat(deleteOptions.isRecurse()).isFalse(); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + void shouldReturnExpectedValue_WhenGetRecurseReturnsOptionalWithValue(boolean recurse) { + var deleteOptions = ImmutableDeleteOptions.builder().recurse(recurse).build(); + assertThat(deleteOptions.getRecurse()).contains(recurse); + assertThat(deleteOptions.isRecurse()).isEqualTo(recurse); + } + } +}