@Test public void assertValue_prohibitsNullValue() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage(startsWith("Expected value cannot be null: use assertNone instead")); new OptionAssertion<Object>(Option.none()) .assertValue((Object) null); }
@NotNull public OptionAssertion<T> assertValue(@NotNull final T expected) { checkNotNull(expected, "Expected value cannot be null: use assertNone instead"); if (!actual.isSome()) { throw fail("Option was not Some"); } if (!matches(actual, equalsPredicate(expected))) { throw fail(String.format("Actual Option value: <%s> did not equal expected value: <%s>", OptionUnsafe.getUnsafe(actual), expected)); } return this; }
OptionAssertion { @NotNull public OptionAssertion<T> assertValue(@NotNull final T expected) { checkNotNull(expected, "Expected value cannot be null: use assertNone instead"); if (!actual.isSome()) { throw fail("Option was not Some"); } if (!matches(actual, equalsPredicate(expected))) { throw fail(String.format("Actual Option value: <%s> did not equal expected value: <%s>", OptionUnsafe.getUnsafe(actual), expected)); } return this; } }
OptionAssertion { @NotNull public OptionAssertion<T> assertValue(@NotNull final T expected) { checkNotNull(expected, "Expected value cannot be null: use assertNone instead"); if (!actual.isSome()) { throw fail("Option was not Some"); } if (!matches(actual, equalsPredicate(expected))) { throw fail(String.format("Actual Option value: <%s> did not equal expected value: <%s>", OptionUnsafe.getUnsafe(actual), expected)); } return this; } OptionAssertion(@NotNull final Option<T> actual); }
OptionAssertion { @NotNull public OptionAssertion<T> assertValue(@NotNull final T expected) { checkNotNull(expected, "Expected value cannot be null: use assertNone instead"); if (!actual.isSome()) { throw fail("Option was not Some"); } if (!matches(actual, equalsPredicate(expected))) { throw fail(String.format("Actual Option value: <%s> did not equal expected value: <%s>", OptionUnsafe.getUnsafe(actual), expected)); } return this; } OptionAssertion(@NotNull final Option<T> actual); void assertIsNone(); @NotNull OptionAssertion<T> assertIsSome(); @NotNull OptionAssertion<T> assertValue(@NotNull final T expected); @NotNull OptionAssertion<T> assertValue(@NotNull final Func1<T, Boolean> predicate); }
OptionAssertion { @NotNull public OptionAssertion<T> assertValue(@NotNull final T expected) { checkNotNull(expected, "Expected value cannot be null: use assertNone instead"); if (!actual.isSome()) { throw fail("Option was not Some"); } if (!matches(actual, equalsPredicate(expected))) { throw fail(String.format("Actual Option value: <%s> did not equal expected value: <%s>", OptionUnsafe.getUnsafe(actual), expected)); } return this; } OptionAssertion(@NotNull final Option<T> actual); void assertIsNone(); @NotNull OptionAssertion<T> assertIsSome(); @NotNull OptionAssertion<T> assertValue(@NotNull final T expected); @NotNull OptionAssertion<T> assertValue(@NotNull final Func1<T, Boolean> predicate);  }