Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianBroudy committed Feb 17, 2025
1 parent 6cf6182 commit bdd777a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.AbstractObjectAssert;
import org.assertj.core.api.AbstractOptionalAssert;
import org.assertj.core.api.AbstractStringAssert;
import org.assertj.core.api.ObjectAssert;
import org.assertj.core.api.OptionalAssert;
import tech.picnic.errorprone.refaster.annotation.OnlineDocumentation;
Expand Down Expand Up @@ -103,13 +104,14 @@ AbstractOptionalAssert<?, T> after(AbstractOptionalAssert<?, T> optionalAssert,
}
}

static final class OptionalAssertHasValue<T> {
static final class AssertThatHasValue<T> {
@BeforeTemplate
AbstractAssert<?, ?> before(Optional<T> optional, T value) {
AbstractStringAssert<?> before(Optional<String> optional, String value) {
return assertThat(optional.orElseThrow()).isEqualTo(value);
}

@AfterTemplate
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
AbstractOptionalAssert<?, T> after(Optional<T> optional, T value) {
return assertThat(optional).hasValue(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ImmutableSet<OptionalAssert<Integer>> testAbstractOptionalAssertIsEmpty() {
assertThat(Optional.of(4)).isPresent().hasValue(4));
}

AbstractAssert<?, ?> testOptionalAssertHasValue() {
AbstractAssert<?, ?> testAssertThatHasValue() {
return assertThat(Optional.of("foo").orElseThrow()).isEqualTo("bar");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ImmutableSet<OptionalAssert<Integer>> testAbstractOptionalAssertIsEmpty() {
assertThat(Optional.of(4)).hasValue(4));
}

AbstractAssert<?, ?> testOptionalAssertHasValue() {
AbstractAssert<?, ?> testAssertThatHasValue() {
return assertThat(Optional.of("foo")).hasValue("bar");
}

Expand Down

0 comments on commit bdd777a

Please sign in to comment.