Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DeleteOptions#isRecurse #264

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class DeleteOptions implements ParamAdder {

@Value.Derived
public boolean isRecurse() {
return getRecurse().isPresent();
return getRecurse().orElse(false);
}

@Override
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/org/kiwiproject/consul/option/DeleteOptionsTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}