org.assertj.core.api.IterableAssert.hasOnlyOneElementSatisfying()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.assertj.core.api.IterableAssert.hasOnlyOneElementSatisfying()方法的一些代码示例,展示了IterableAssert.hasOnlyOneElementSatisfying()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IterableAssert.hasOnlyOneElementSatisfying()方法的具体详情如下:
包路径:org.assertj.core.api.IterableAssert
类名称:IterableAssert
方法名:hasOnlyOneElementSatisfying

IterableAssert.hasOnlyOneElementSatisfying介绍

暂无

代码示例

代码示例来源:origin: reactor/reactor-core

@Test
public void shouldReturnNormallyIfExceptionIsThrownOnNextDuringSwitching() {
  Signal<? extends Long>[] first = new Signal[1];
  StepVerifier.create(Flux.just(1L)
              .switchOnFirst((s, f) -> {
                first[0] = s;
                throw new NullPointerException();
              }))
        .expectSubscription()
        .expectError(NullPointerException.class)
        .verifyThenAssertThat()
        .hasOperatorErrorsSatisfying(c ->
          Assertions.assertThat(c)
               .hasOnlyOneElementSatisfying(t -> {
                 Assertions.assertThat(t.getT1()).containsInstanceOf(NullPointerException.class);
                 Assertions.assertThat((Optional)t.getT2()).hasValue(1L);
               })
        );
  Assertions.assertThat((long) first[0].get()).isEqualTo(1L);
}

代码示例来源:origin: line/line-bot-sdk-java

@Test
public void ngForFixedTest() {
  // Do
  Set<ConstraintViolation<LineBotProperties>> constraintViolations =
      VALIDATOR.validate(new LineBotProperties() {{
        setChannelSecret("SECRET");
      }});
  //Verify
  assertThat(constraintViolations)
      .isNotEmpty()
      .filteredOn("propertyPath", createPathFromString("channelToken"))
      .hasOnlyOneElementSatisfying(violation -> {
        assertThat(violation.getMessage()).isEqualTo("channelToken is null");
      });
}

代码示例来源:origin: line/line-bot-sdk-java

@Test
  public void ngForSupplierTest() {
    // Do
    Set<ConstraintViolation<LineBotProperties>> constraintViolations =
        VALIDATOR.validate(new LineBotProperties() {{
          setChannelTokenSupplyMode(SUPPLIER);
          setChannelSecret("SECRET");
          setChannelToken("TOKEN");
        }});

    //Verify
    assertThat(constraintViolations)
        .isNotEmpty()
        .filteredOn("propertyPath", createPathFromString("channelToken"))
        .hasOnlyOneElementSatisfying(violation -> {
          assertThat(violation.getMessage())
              .isEqualTo("channelToken should be null if channelTokenSupplyMode = SUPPLIER");
        });
  }
}

相关文章

微信公众号

最新文章

更多