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

x33g5p2x  于2022-01-15 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(98)

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

AbstractListAssert.has介绍

[英]Verifies that the actual object at the given index in the actual group satisfies the given condition.
[中]验证实际组中给定索引处的实际对象是否满足给定条件。

代码示例

代码示例来源:origin: facebook/litho

@Test
public void testEmptyGenerate() {
 final MockSpecModel specModel =
   MockSpecModel.newBuilder()
     .contextClass(ClassName.bestGuess(DummyContext.class.getName()))
     .enclosedSpecModel(sEnclosedSpec)
     .build();
 final TypeSpecDataHolder holder = MatcherGenerator.generate(specModel);
 assertThat(holder.getFieldSpecs()).isEmpty();
 assertThat(holder.getMethodSpecs())
   .hasSize(1)
   .has(
     new Condition<MethodSpec>() {
      @Override
      public boolean matches(MethodSpec value) {
       return value.name.equals("matcher")
         && value.returnType.toString().equals("Matcher");
      }
     },
     Index.atIndex(0));
}

代码示例来源:origin: dhleong/intellivim

assertThat(infoList)
    .isNotEmpty()
    .has(sizeAtLeast(4));

代码示例来源:origin: TNG/junit-dataprovider

@Test
public void testFindAnnotatedMethodsShouldNotShadowedMethodsHavingAnnotation() {
  // Given:
  final List<Class<?>> locations = Arrays.<Class<?>>asList(ShadowingTestChild.class);
  // When:
  List<Method> result = underTest.findAnnotatedMethods(locations, TestAnnotation.class);
  // Then:
  // @formatter:off
  assertThat(result).hasSize(7)
      .has(name("privateWithAnnotation"), atIndex(0))
      .has(name("notShadowedDueToParameterLength"), atIndex(1))
      .has(name("notShadowedDueToParameterTypes"), atIndex(2))
      .has(name("shadowed"), atIndex(3))
      .has(name("notShadowedDueToParameterLength"), atIndex(4))
      .has(name("notShadowedDueToParameterTypes"), atIndex(5))
      .has(name("shadowedButChildHasNoAnnotation"), atIndex(6))
    ;
  // @formatter:on
}

相关文章

微信公众号

最新文章

更多