Remove copy of documentation tests

This commit is contained in:
Paul Campbell 2017-12-10 16:24:56 +00:00
parent e0eb0614c3
commit e711184628

View file

@ -21,42 +21,6 @@ public class MaybeTest {
return v -> Objects.equals(value, v); return v -> Objects.equals(value, v);
} }
@Test
public void documentation() {
assertThat(Maybe.maybe(null)).isEqualTo(Maybe.nothing());
assertThat(Maybe.maybe(1)).isEqualTo(Maybe.just(1));
assertThat(Maybe.nothing()
.orElseGet(() -> 1)).isEqualTo(1);
assertThat(Maybe.just(1)
.orElseGet(() -> 2)).isEqualTo(1);
assertThat(Maybe.nothing()
.orElse(1)).isEqualTo(1);
assertThat(Maybe.just(1)
.orElse(2)).isEqualTo(1);
assertThat(Maybe.just(1)
.filter(v -> v > 2)).isEqualTo(Maybe.nothing());
assertThat(Maybe.just(3)
.filter(v -> v > 2)).isEqualTo(Maybe.just(3));
assertThat(Maybe.just(1)
.toOptional()).isEqualTo(Optional.of(1));
assertThat(Maybe.nothing()
.toOptional()).isEqualTo(Optional.empty());
assertThat(Maybe.fromOptional(Optional.of(1))).isEqualTo(Maybe.just(1));
assertThat(Maybe.fromOptional(Optional.empty())).isEqualTo(Maybe.nothing());
final AtomicInteger reference = new AtomicInteger(0);
assertThat(Maybe.just(1)
.peek(reference::set)).isEqualTo(Maybe.just(1));
assertThat(reference).hasValue(1);
assertThat(Maybe.nothing()
.peek(v -> reference.incrementAndGet())).isEqualTo(Maybe.nothing());
assertThat(reference).hasValue(1);
assertThatCode(() -> Maybe.just(1)
.orElseThrow(IllegalStateException::new)).doesNotThrowAnyException();
assertThatThrownBy(() -> Maybe.nothing()
.orElseThrow(IllegalStateException::new)).isInstanceOf(
IllegalStateException.class);
}
@Test @Test
public void justMustBeNonNull() { public void justMustBeNonNull() {
assertThatNullPointerException().isThrownBy(() -> just(null)) assertThatNullPointerException().isThrownBy(() -> just(null))