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

x33g5p2x  于2022-01-25 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(67)

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

ObjectArrayAssert.describedAs介绍

暂无

代码示例

代码示例来源:origin: apache/geode

@SuppressWarnings("unchecked")
private static <L extends TransactionListener> L firstTransactionListenerFrom(
  CacheTransactionManager transactionManager) {
 TransactionListener[] listeners = transactionManager.getListeners();
 assertThat(listeners).describedAs("Listeners on transactionManager for transaction with id "
   + transactionManager.getTransactionId()).hasSize(1);
 return (L) listeners[0];
}

代码示例来源:origin: jdbi/jdbi

@Test
public void testEventuallyFails() {
  final AtomicInteger attempts = new AtomicInteger(0);
  Handle handle = dbRule.getJdbi().open();
  assertThatExceptionOfType(SQLException.class)
    .isThrownBy(() -> handle.inTransaction(TransactionIsolationLevel.SERIALIZABLE,
      conn -> {
        attempts.incrementAndGet();
        throw new SQLException("serialization", "40001", attempts.get());
      }))
    .satisfies(e -> assertThat(e.getSQLState()).isEqualTo("40001"))
    .satisfies(e -> assertThat(e.getSuppressed())
      .hasSize(MAX_RETRIES)
      .describedAs("suppressed are ordered reverse chronologically, like a stack")
      .isSortedAccordingTo(Comparator.comparing(ex -> ((SQLException) ex).getErrorCode()).reversed()))
    .describedAs("thrown exception is chronologically last")
    .satisfies(e -> assertThat(e.getErrorCode()).isEqualTo(((SQLException) e.getSuppressed()[0]).getErrorCode() + 1));
  assertThat(attempts.get()).isEqualTo(1 + MAX_RETRIES);
}

相关文章