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

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

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

ListAssert.has介绍

暂无

代码示例

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

@Test
public void testShallowSubComponents() {
 final ComponentContext c = mComponentsRule.getContext();
 assertThat(c, mComponent)
   .extractingSubComponents(c)
   .hasSize(1)
   .has(
     new Condition<InspectableComponent>() {
      @Override
      public boolean matches(InspectableComponent value) {
       return value.getComponentClass() == Card.class;
      }
     },
     atIndex(0));
}

代码示例来源:origin: junit-pioneer/junit-pioneer

@SafeVarargs
public static void assertRecordedExecutionEventsContainsExactly(List<ExecutionEvent> executionEvents,
    Condition<? super ExecutionEvent>... conditions) {
  SoftAssertions softly = new SoftAssertions();
  assertThat(executionEvents).hasSize(conditions.length);
  for (int i = 0; i < conditions.length; i++) {
    softly.assertThat(executionEvents).has(conditions[i], atIndex(i));
  }
  softly.assertAll();
}

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

@Test
public void testDeepSubComponents() {
 final ComponentContext c = mComponentsRule.getContext();
 // N.B. This manual way of testing is not recommended and will be replaced by more high-level
 // matchers, but illustrates how it can be used in case more fine-grained assertions are
 // required.
 assertThat(c, mComponent)
   .extractingSubComponentsDeeply(c)
   .hasSize(16)
   .has(
     new Condition<InspectableComponent>() {
      @Override
      public boolean matches(InspectableComponent value) {
       describedAs(value.getComponentClass() + " with text " + value.getTextContent());
       return value.getComponentClass() == Text.class
         && "JavaScript Rockstar".equals(value.getTextContent());
      }
     },
     atIndex(7));
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void sortProductProjectionsOnSearchByCategory2() {
  final Comparator<ProductProjection> comparator = comparingCategoryOrderHints(category2Id);
  assertWithQueryResult(result -> {
    assertThat(productProjectionsSortedBy(result.productProjections, comparator)).has(itemsInThisOrder(asList(id5, id2, id1)));
    assertThat(result.sortedFromSearchForCategory2).extracting("id").as("search").startsWith(id5, id2, id1);
  });
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void connection_to_remote_es_nodes_when_cluster_mode_is_enabled_and_local_es_is_disabled() {
 settings.setProperty(CLUSTER_ENABLED.getKey(), true);
 settings.setProperty(CLUSTER_NODE_TYPE.getKey(), "application");
 settings.setProperty(CLUSTER_SEARCH_HOSTS.getKey(), format("%s:8080,%s:8081", localhost, localhost));
 EsClient client = underTest.provide(settings.asConfig());
 TransportClient transportClient = (TransportClient) client.nativeClient();
 assertThat(transportClient.transportAddresses()).hasSize(2);
 TransportAddress address = transportClient.transportAddresses().get(0);
 assertThat(address.getAddress()).isEqualTo(localhost);
 assertThat(address.getPort()).isEqualTo(8080);
 address = transportClient.transportAddresses().get(1);
 assertThat(address.getAddress()).isEqualTo(localhost);
 assertThat(address.getPort()).isEqualTo(8081);
 assertThat(logTester.logs(LoggerLevel.INFO)).has(new Condition<>(s -> s.contains("Connected to remote Elasticsearch: [" + localhost + ":8080, " + localhost + ":8081]"), ""));
 // keep in cache
 assertThat(underTest.provide(settings.asConfig())).isSameAs(client);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void es_client_provider_must_add_default_port_when_not_specified() {
  settings.setProperty(CLUSTER_ENABLED.getKey(), true);
  settings.setProperty(CLUSTER_NODE_TYPE.getKey(), "application");
  settings.setProperty(CLUSTER_SEARCH_HOSTS.getKey(), format("%s,%s:8081", localhost, localhost));

  EsClient client = underTest.provide(settings.asConfig());
  TransportClient transportClient = (TransportClient) client.nativeClient();
  assertThat(transportClient.transportAddresses()).hasSize(2);
  TransportAddress address = transportClient.transportAddresses().get(0);
  assertThat(address.getAddress()).isEqualTo(localhost);
  assertThat(address.getPort()).isEqualTo(9001);
  address = transportClient.transportAddresses().get(1);
  assertThat(address.getAddress()).isEqualTo(localhost);
  assertThat(address.getPort()).isEqualTo(8081);
  assertThat(logTester.logs(LoggerLevel.INFO)).has(new Condition<>(s -> s.contains("Connected to remote Elasticsearch: [" + localhost + ":9001, " + localhost + ":8081]"), ""));

  // keep in cache
  assertThat(underTest.provide(settings.asConfig())).isSameAs(client);
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void connection_to_local_es_when_cluster_mode_is_disabled() {
 settings.setProperty(CLUSTER_ENABLED.getKey(), false);
 settings.setProperty(SEARCH_HOST.getKey(), localhost);
 settings.setProperty(SEARCH_PORT.getKey(), 8080);
 EsClient client = underTest.provide(settings.asConfig());
 TransportClient transportClient = (TransportClient) client.nativeClient();
 assertThat(transportClient.transportAddresses()).hasSize(1);
 TransportAddress address = transportClient.transportAddresses().get(0);
 assertThat(address.getAddress()).isEqualTo(localhost);
 assertThat(address.getPort()).isEqualTo(8080);
 assertThat(logTester.logs(LoggerLevel.INFO)).has(new Condition<>(s -> s.contains("Connected to local Elasticsearch: [" + localhost + ":8080]"), ""));
 // keep in cache
 assertThat(underTest.provide(settings.asConfig())).isSameAs(client);
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法