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

x33g5p2x  于2022-01-23 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(147)

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

ListAssert.last介绍

暂无

代码示例

代码示例来源:origin: RoboZonky/robozonky

@Test
  void properEventsFired() {
    final RoboZonkyStartupNotifier rzsn = new RoboZonkyStartupNotifier(SESSION);
    final Optional<Consumer<ShutdownHook.Result>> result = rzsn.get();
    assertThat(result).isPresent();
    assertThat(this.getEventsRequested()).last().isInstanceOf(RoboZonkyInitializedEvent.class);
    final ShutdownHook.Result r = new ShutdownHook.Result(ReturnCode.OK, null);
    result.get().accept(r);
    assertThat(this.getEventsRequested()).last().isInstanceOf(RoboZonkyEndingEvent.class);
    final ShutdownHook.Result r2 = new ShutdownHook.Result(ReturnCode.ERROR_SETUP, null);
    result.get().accept(r2);
    assertThat(this.getEventsRequested()).last().isInstanceOf(RoboZonkyCrashedEvent.class);
  }
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void correctLoading() {
  final ListenerService s1 = mock(ListenerService.class);
  final EventListenerSupplier<RoboZonkyStartingEvent> returned = () -> Optional.of(l);
  doAnswer(i -> Stream.of(returned)).when(s1).findListeners(eq(RoboZonkyStartingEvent.class));
  final ListenerService s2 = mock(ListenerService.class);
  doAnswer(i -> Stream.of((EventListenerSupplier<RoboZonkyStartingEvent>) Optional::empty))
      .when(s2).findListeners(eq(RoboZonkyStartingEvent.class));
  final Iterable<ListenerService> s = () -> Arrays.asList(s1, s2).iterator();
  final List<EventListenerSupplier<RoboZonkyStartingEvent>> r =
      ListenerServiceLoader.load(RoboZonkyStartingEvent.class, s);
  assertThat(r).hasSize(2);
  assertThat(r)
      .first()
      .has(new Condition<>(result -> result.get().isPresent() && Objects.equals(result.get().get(), l),
                 "Exists"));
  assertThat(r)
      .last()
      .has(new Condition<>(result -> !result.get().isPresent(), "Does not exist"));
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法