本文整理了Java中org.assertj.core.api.ListAssert.first()
方法的一些代码示例,展示了ListAssert.first()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAssert.first()
方法的具体详情如下:
包路径:org.assertj.core.api.ListAssert
类名称:ListAssert
方法名:first
暂无
代码示例来源:origin: reactor/reactor-core
.first()
.matches(ctx -> ctx.hasKey("thirdPartyContext"));
assertThat(contextPerRetry.subList(1, contextPerRetry.size() - 1))
代码示例来源:origin: reactor/reactor-core
"emitted 2 elements this attempt, 0 repeats left");
assertThat(contexts).first().matches(ctx -> ctx.hasKey("thirdPartyContext"));
assertThat(contexts).noneMatch(ctx -> ctx.getOrDefault("repeatsLeft", -1) != 3 && ctx.hasKey("thirdPartyContext"));
代码示例来源:origin: RoboZonky/robozonky
@Test
void fails() {
final Runnable r = mock(Runnable.class);
doThrow(IllegalStateException.class).when(r).run();
final PowerTenant t = mockTenant();
final Consumer<Throwable> c = mock(Consumer.class);
final Skippable s = new Skippable(r, t, c);
s.run();
verify(c, never()).accept(any());
assertThat(this.getEventsRequested()).hasSize(1)
.first()
.isInstanceOf(RoboZonkyDaemonFailedEvent.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"));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void processHopeless() {
final TransactionalPowerTenant transactional = PowerTenant.transactional(mockTenant(zonky));
System.out.println("Processing.");
HOPELESS.process(transactional, investment);
System.out.println("Processed.");
transactional.commit();
System.out.println("Committed.");
assertThat(getEventsRequested()).hasSize(1)
.first().isInstanceOf(LoanDelinquent90DaysOrMoreEvent.class);
verify(zonky).getLoan(eq(loan.getId()));
verify(zonky).getDevelopments(eq(loan.getId()));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void processMild() {
final TransactionalPowerTenant transactional = PowerTenant.transactional(mockTenant(zonky));
MILD.process(transactional, investment);
transactional.commit();
assertThat(getEventsRequested()).hasSize(1)
.first().isInstanceOf(LoanDelinquent10DaysOrMoreEvent.class);
verify(zonky).getLoan(eq(loan.getId()));
verify(zonky).getDevelopments(eq(loan.getId()));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void processCritical() {
final TransactionalPowerTenant transactional = PowerTenant.transactional(mockTenant(zonky));
CRITICAL.process(transactional, investment);
transactional.commit();
assertThat(getEventsRequested()).hasSize(1)
.first().isInstanceOf(LoanDelinquent60DaysOrMoreEvent.class);
verify(zonky).getLoan(eq(loan.getId()));
verify(zonky).getDevelopments(eq(loan.getId()));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void processSevere() {
final TransactionalPowerTenant transactional = PowerTenant.transactional(mockTenant(zonky));
SEVERE.process(transactional, investment);
transactional.commit();
assertThat(getEventsRequested()).hasSize(1)
.first().isInstanceOf(LoanDelinquent30DaysOrMoreEvent.class);
verify(zonky).getLoan(eq(loan.getId()));
verify(zonky).getDevelopments(eq(loan.getId()));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void processNew() {
final TransactionalPowerTenant transactional = PowerTenant.transactional(mockTenant(zonky));
NEW.process(transactional, investment);
transactional.commit();
assertThat(getEventsRequested()).hasSize(1)
.first().isInstanceOf(LoanNowDelinquentEvent.class);
verify(zonky).getLoan(eq(loan.getId()));
verify(zonky).getDevelopments(eq(loan.getId()));
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void processDefaulted() {
final TransactionalPowerTenant transactional = PowerTenant.transactional(mockTenant(zonky));
DEFAULTED.process(transactional, investment);
transactional.commit();
assertThat(getEventsRequested()).hasSize(1)
.first().isInstanceOf(LoanDefaultedEvent.class);
verify(zonky).getLoan(eq(loan.getId()));
verify(zonky).getDevelopments(eq(loan.getId()));
}
}
代码示例来源:origin: io.syndesis.server/server-api-generator
@Test
public void testEmptyOperationSummary() throws IOException {
ProvidedApiTemplate template = new ProvidedApiTemplate(dummyConnection(), "fromAction", "toAction");
String specification = TestHelper.resource("/swagger/empty-summary.json");
SwaggerAPIGenerator generator = new SwaggerAPIGenerator();
APIIntegration apiIntegration = generator.generateIntegration(specification, template);
assertThat(apiIntegration).isNotNull();
assertThat(apiIntegration.getIntegration().getFlows()).hasSize(3);
List<Flow> flows = apiIntegration.getIntegration().getFlows();
assertThat(flows).filteredOn(idEndsWith("-1")).first().hasFieldOrPropertyWithValue("name", "Receiving GET request on /hi");
assertThat(flows).filteredOn(idEndsWith("-2")).first().hasFieldOrPropertyWithValue("name", "post operation");
assertThat(flows).filteredOn(idEndsWith("-3")).first().hasFieldOrPropertyWithValue("name", "Receiving PUT request on /hi");
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void handlesRegularHealing() {
final Investment i1 = Investment.custom().setDaysPastDue(1).build();
when(zonky.getDelinquentInvestments()).thenReturn(Stream.of(i1));
// run test
payload.accept(tenant); // nothing will happen here, as this is the initializing run
final Investment i2 = Investment.custom().setDaysPastDue(1).setPaymentStatus(PaymentStatus.OK).build();
when(zonky.getDelinquentInvestments()).thenReturn(Stream.of(i2));
when(zonky.getLoan(anyInt())).thenReturn(Loan.custom().build());
payload.accept(tenant); // the new delinquency will show up now
assertThat(getEventsRequested()).hasSize(1)
.extracting(e -> (Object) e.getClass().getInterfaces()[0])
.containsOnly(LoanNowDelinquentEvent.class);
readPreexistingEvents();
// now the same delinquency is no longer available
when(zonky.getDelinquentInvestments()).thenReturn(Stream.empty());
when(zonky.getInvestment(eq(i2.getId()))).thenReturn(Optional.of(i2));
payload.accept(tenant); // the new delinquency will show up now
assertThat(getEventsRequested()).hasSize(1)
.first()
.isInstanceOf(LoanNoLongerDelinquentEvent.class);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void handlesLoss() {
final Investment i1 = Investment.custom().setDaysPastDue(1).build();
when(zonky.getDelinquentInvestments()).thenReturn(Stream.of(i1));
// run test
payload.accept(tenant); // nothing will happen here, as this is the initializing run
final Investment i2 = Investment.custom().setDaysPastDue(1).setPaymentStatus(PaymentStatus.WRITTEN_OFF).build();
when(zonky.getDelinquentInvestments()).thenReturn(Stream.of(i2));
when(zonky.getLoan(anyInt())).thenReturn(Loan.custom().build());
payload.accept(tenant); // the new delinquency will show up now
assertThat(getEventsRequested()).hasSize(1)
.extracting(e -> (Object) e.getClass().getInterfaces()[0])
.containsOnly(LoanNowDelinquentEvent.class);
readPreexistingEvents();
// now the same delinquency is no longer available
when(zonky.getDelinquentInvestments()).thenReturn(Stream.empty());
when(zonky.getInvestment(eq(i2.getId()))).thenReturn(Optional.of(i2));
payload.accept(tenant); // the lost loan will show up now
assertThat(getEventsRequested()).hasSize(1)
.first()
.isInstanceOf(LoanLostEvent.class);
}
内容来源于网络,如有侵权,请联系作者删除!