本文整理汇总了Java中io.vavr.control.Option.of方法的典型用法代码示例。如果您正苦于以下问题:Java Option.of方法的具体用法?Java Option.of怎么用?Java Option.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vavr.control.Option
的用法示例。
在下文中一共展示了Option.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: failsWhenFailingConstraint
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void failsWhenFailingConstraint() {
Example example = new Example();
example.three = Option.of(2);
Set<ConstraintViolation<Example>> violations = validator.validate(example);
assertThat(violations).hasSize(1);
}
示例2: succeedsWhenConstraintsMet
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void succeedsWhenConstraintsMet() {
Example example = new Example();
example.three = Option.of(10);
Set<ConstraintViolation<Example>> violations = validator.validate(example);
assertThat(violations).isEmpty();
}
示例3: notBlankFailsWhenPresentButBlank
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void notBlankFailsWhenPresentButBlank() {
Example example = new Example();
example.notBlank = Option.of("\t");
Set<ConstraintViolation<Example>> violations = validator.validate(example);
assertThat(violations).hasSize(1);
}
示例4: should_fail_if_option_does_not_contain_the_expected_object_reference
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_the_expected_object_reference() {
Option<String> actual = Option.of("not-expected");
String expectedValue = "something";
thrown.expectAssertionError(shouldContainSame(actual, expectedValue).create());
assertThat(actual).containsSame(expectedValue);
}
示例5: should_fail_if_option_contains_equal_but_not_same_value
import io.vavr.control.Option; //导入方法依赖的package包/类
@SuppressWarnings("RedundantStringConstructorCall")
@Test
public void should_fail_if_option_contains_equal_but_not_same_value() {
Option<String> actual = Option.of(new String("something"));
String expectedValue = new String("something");
thrown.expectAssertionError(shouldContainSame(actual, expectedValue).create());
assertThat(actual).containsSame(expectedValue);
}
示例6: should_fail_if_option_does_not_contain_expected_value
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_expected_value() throws Exception {
Option<String> actual = Option.of("not-expected");
String expectedValue = "something";
thrown.expectAssertionError(shouldContain(actual, expectedValue).create());
assertThat(actual).contains(expectedValue);
}
示例7: should_fail_if_option_does_not_contain_expected_value
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_expected_value() throws Exception {
Option<Foo> actual = Option.of(new Foo("something"));
Foo expectedValue = new Foo("something else");
thrown.expectAssertionError(shouldContain(actual, expectedValue).create());
assertThat(actual).usingValueComparator(FOO_COMPARATOR).contains(expectedValue);
}
示例8: should_fail_if_option_does_not_contain_expected_value
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_does_not_contain_expected_value() {
Option<Foo> actual = Option.of(new Foo("something"));
Foo expectedValue = new Foo("something else");
thrown.expectAssertionError(shouldContain(actual, expectedValue).create());
assertThat(actual).usingFieldByFieldValueComparator().contains(expectedValue);
}
开发者ID:assertj,项目名称:assertj-vavr,代码行数:10,代码来源:OptionAssert_contains_usingFieldByFieldValueComparator_Test.java
示例9: should_fail_if_option_contains_other_type_than_required
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_option_contains_other_type_than_required() {
Option<ParentClass> actual = Option.of(new ParentClass());
Throwable thrown = catchThrowable(
() -> assertThat(actual).containsInstanceOf(OtherClass.class));
assertThat(thrown).isInstanceOf(AssertionError.class)
.hasMessage(shouldContainInstanceOf(actual, OtherClass.class).create());
}
示例10: should_fail_if_Option_is_present
import io.vavr.control.Option; //导入方法依赖的package包/类
@Test
public void should_fail_if_Option_is_present() throws Exception {
Option<String> actual = Option.of("not-empty");
thrown.expectAssertionError(shouldBeEmpty(actual).create());
assertThat(actual).isEmpty();
}
示例11: add
import io.vavr.control.Option; //导入方法依赖的package包/类
@Override
public ContainerBuilder<Option<?>> add(Object it) {
optional = Option.of(it);
return this;
}
示例12: optionFilledResult
import io.vavr.control.Option; //导入方法依赖的package包/类
@GET
@Path("/option-filled")
public Option<String> optionFilledResult() {
return Option.of("option");
}
示例13: some
import io.vavr.control.Option; //导入方法依赖的package包/类
@GET
@Path("option-some")
public Option<String> some() {
return Option.of("Foobar");
}
示例14: setPublicFacingIP
import io.vavr.control.Option; //导入方法依赖的package包/类
public void setPublicFacingIP(final String ip) {
publicFacingIP = Option.of(ip);
}
示例15: DatabaseWait
import io.vavr.control.Option; //导入方法依赖的package包/类
public DatabaseWait(final String connectionUrl, final Duration atMost) {
this.connectionUrl = Option.of(connectionUrl);
this.atMost = atMost;
}