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

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

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

AbstractListAssert.containsAll介绍

暂无

代码示例

代码示例来源:origin: json-path/JsonPath

@Test
public void root_context_can_be_referred_in_predicate() {
  List<Double> prices = using(conf).parse(JSON_DOCUMENT).read("store.book[?(@.display-price <= $.max-price)].display-price", List.class);
  assertThat(prices).containsAll(asList(8.95D, 8.99D));
}

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

@Test
public void searchBranchStatistics_on_many_branches() {
 ComponentDto project = db.components().insertMainBranch();
 List<String> branchUuids = new ArrayList<>();
 List<Tuple> expectedResult = new ArrayList<>();
 IntStream.range(0, 15).forEach(i -> {
  ComponentDto branch = db.components().insertProjectBranch(project);
  addIssues(branch, 1 + i, 2 + i, 3 + i);
  expectedResult.add(tuple(branch.uuid(), 1L + i, 2L + i, 3L + i));
  branchUuids.add(branch.uuid());
 });
 List<BranchStatistics> branchStatistics = underTest.searchBranchStatistics(project.uuid(), branchUuids);
 assertThat(branchStatistics)
  .extracting(BranchStatistics::getBranchUuid, BranchStatistics::getBugs, BranchStatistics::getVulnerabilities, BranchStatistics::getCodeSmells)
  .hasSize(15)
  .containsAll(expectedResult);
}

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

@Test
public void select_by_projects_with_high_number_of_projects() {
 List<String> projectUuids = new ArrayList<>();
 for (int i = 0; i < 350; i++) {
  ComponentDto project = ComponentTesting.newPrivateProjectDto(organization, Integer.toString(i));
  dbClient.componentDao().insert(dbSession, project);
  projectUuids.add(project.uuid());
  GroupPermissionDto dto = new GroupPermissionDto()
   .setOrganizationUuid(group.getOrganizationUuid())
   .setGroupId(group.getId())
   .setRole(USER)
   .setResourceId(project.getId());
  dbClient.groupPermissionDao().insert(dbSession, dto);
 }
 dbSession.commit();
 assertThat(underTest.selectByUuids(dbClient, dbSession, projectUuids))
  .hasSize(350)
  .extracting(IndexPermissions::getProjectUuid)
  .containsAll(projectUuids);
}

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

.contains(uuids3)
.contains(dto5.getUuid())
.containsAll(tasks.stream().map(CeTask::getUuid).collect(Collectors.toList()));

代码示例来源:origin: gentics/mesh

public PermissionInfoAssert hasPerm(Permission... permissions) {
  List<String> hasPerm = actual.asMap().entrySet().stream().filter(p -> p.getValue() == true).map(e -> e.getKey().getName())
      .collect(Collectors.toList());
  List<String> mustHave = Arrays.asList(permissions).stream().map(e -> e.getName()).collect(Collectors.toList());
  assertThat(hasPerm).containsAll(mustHave);
  return this;
}

代码示例来源:origin: allegro/hermes

public void waitUntilReceived(long seconds) {
  logger.info("Expecting to receive {} messages", expectedMessages.size());
  await().atMost(adjust(new Duration(seconds, TimeUnit.SECONDS))).until(() ->
      assertThat(receivedRequests.size()).isGreaterThanOrEqualTo(expectedMessages.size()));
  synchronized (receivedRequests) {
    assertThat(receivedRequests.stream().map(LoggedRequest::getBodyAsString).collect(toList())).containsAll(expectedMessages);
  }
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-test-helper

public void waitUntilReceived(long seconds) {
  logger.info("Expecting to receive {} messages", expectedMessages.size());
  await().atMost(adjust(new Duration(seconds, TimeUnit.SECONDS))).until(() ->
      assertThat(receivedRequests.size()).isGreaterThanOrEqualTo(expectedMessages.size()));
  synchronized (receivedRequests) {
    assertThat(receivedRequests.stream().map(LoggedRequest::getBodyAsString).collect(toList())).containsAll(expectedMessages);
  }
}

代码示例来源:origin: prestodb/presto-yarn

@Test
public void multiNodeWithPlacementLifecycle()
{
  PrestoCluster prestoCluster = new PrestoCluster(slider, hdfsClient, sliderConfDirPath, "resources-multinode.json", APP_CONFIG_TEST_TEMPLATE);
  prestoCluster.withPrestoCluster(() -> {
    prestoCluster.assertThatPrestoIsUpAndRunning(workersCount());
    assertThatAllProcessesAreRunning(prestoCluster);
    assertThatPrestoYarnContainersUsesCgroup(prestoCluster);
    // check placement policy
    Assertions.assertThat(prestoCluster.getCoordinatorHost()).contains(master);
    Assertions.assertThat(prestoCluster.getWorkerHosts()).containsAll(workers);
    assertThatApplicationIsStoppable(prestoCluster);
  });
}

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

@Test
public void testGenerateExplodedTestMethodsForShouldCallTestGeneratorWithFoundDataProviderMethodAndAddResult() {
  // Given:
  doReturn(asList(dataProviderMethod)).when(underTest).getDataProviderMethods(testMethod);
  List<FrameworkMethod> explodedMethods = new ArrayList<FrameworkMethod>();
  explodedMethods.add(mock(FrameworkMethod.class));
  explodedMethods.add(mock(FrameworkMethod.class));
  doReturn(explodedMethods).when(testGenerator).generateExplodedTestMethodsFor(testMethod, dataProviderMethod);
  // When:
  List<FrameworkMethod> result = underTest.generateExplodedTestMethodsFor(asList(testMethod));
  // Then:
  assertThat(result).hasSize(2).containsAll(explodedMethods);
  verify(testGenerator).generateExplodedTestMethodsFor(testMethod, dataProviderMethod);
  verifyNoMoreInteractions(testGenerator);
}

代码示例来源:origin: HubSpot/jinjava

@SuppressWarnings("unchecked")
@Test
public void itShufflesConsistentlyWithConstantRandom() {
 when(interpreter.getRandom()).thenReturn(new ConstantZeroRandomNumberGenerator());
 List<String> before = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9");
 List<String> after = (List<String>) filter.filter(before, interpreter);
 assertThat(before).isSorted();
 assertThat(after).containsAll(before);
 assertThat(after).containsExactly("2", "3", "4", "5", "6", "7", "8", "9", "1");
}

代码示例来源:origin: com.hubspot.jinjava/jinjava

@SuppressWarnings("unchecked")
@Test
public void itShufflesConsistentlyWithConstantRandom() {
 when(interpreter.getRandom()).thenReturn(new ConstantZeroRandomNumberGenerator());
 List<String> before = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9");
 List<String> after = (List<String>) filter.filter(before, interpreter);
 assertThat(before).isSorted();
 assertThat(after).containsAll(before);
 assertThat(after).containsExactly("2", "3", "4", "5", "6", "7", "8", "9", "1");
}

代码示例来源:origin: HubSpot/jinjava

@SuppressWarnings("unchecked")
@Test
public void itShufflesItems() {
 when(interpreter.getRandom()).thenReturn(ThreadLocalRandom.current());
 List<String> before = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9");
 List<String> after = (List<String>) filter.filter(before, interpreter);
 assertThat(before).isSorted();
 assertThat(after).containsAll(before);
 try {
  assertThat(after).isSorted();
  failBecauseExceptionWasNotThrown(AssertionError.class);
 } catch (AssertionError e) {
  assertThat(e).hasMessageContaining("is not sorted");
 }
}

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

@Test
public void testGetDataProviderMethodShouldReturnFirstNotEmptyListIfResolveStrategyIsAggregateAllMatchesAndMultipleResolversWouldMatch() {
  // Given:
  final DataProviderMethodResolver resolver2 = mock(DataProviderMethodResolver.class);
  final DataProviderMethodResolver resolver3 = mock(DataProviderMethodResolver.class);
  final List<FrameworkMethod> expected2 = Arrays.asList(mock(FrameworkMethod.class), mock(FrameworkMethod.class));
  final List<FrameworkMethod> expected3 = Arrays.asList(mock(FrameworkMethod.class));
  doReturn(useDataProvider).when(testMethod).getAnnotation(UseDataProvider.class);
  doReturn(new Class<?>[] { DataProviderMethodResolver.class, DataProviderMethodResolver.class,
      DataProviderMethodResolver.class })
  .when(useDataProvider).resolver();
  doReturn(ResolveStrategy.AGGREGATE_ALL_MATCHES).when(useDataProvider).resolveStrategy();
  doReturn(dataProviderMethodResolver, resolver2, resolver3).when(underTest).getResolverInstanceInt(any(Class.class));
  doReturn(emptyList()).when(dataProviderMethodResolver).resolve(testMethod, useDataProvider);
  doReturn(expected2).when(resolver2).resolve(testMethod, useDataProvider);
  doReturn(expected3).when(resolver3).resolve(testMethod, useDataProvider);
  // When:
  List<FrameworkMethod> result = underTest.getDataProviderMethods(testMethod);
  // Then:
  assertThat(result).hasSize(3).containsAll(expected2).containsAll(expected3);
  assertThat(underTest.dataProviderMethods).containsEntry(testMethod, result);
}

代码示例来源:origin: com.hubspot.jinjava/jinjava

@SuppressWarnings("unchecked")
@Test
public void itShufflesItems() {
 when(interpreter.getRandom()).thenReturn(ThreadLocalRandom.current());
 List<String> before = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9");
 List<String> after = (List<String>) filter.filter(before, interpreter);
 assertThat(before).isSorted();
 assertThat(after).containsAll(before);
 try {
  assertThat(after).isSorted();
  failBecauseExceptionWasNotThrown(AssertionError.class);
 } catch (AssertionError e) {
  assertThat(e).hasMessageContaining("is not sorted");
 }
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Test
public void aggregationsOnDifferentNodes() throws Exception {
  String[] columnNames = {"n.lastName", "type(r)", "collect(m.name)"};
  String cypher = "MATCH (n:Person)-[r]->(m:Interest) RETURN n.lastName, type(r), collect(m.name)";
  List<Map<String, Object>> cypherResults = submitAndGet(cypher);
  assertThat(cypherResults)
    .hasSize(2)
    .extracting(columnNames)
    .usingElementComparator(ignoreOrderInCollections())
    .containsAll(extract(cypherResults, byName(columnNames)))
    .containsExactlyInAnyOrder(
      tuple("Andresen", "LIKES", asList("Video", "Video", "Music")),
      tuple("Haugland", "LIKES", asList("Video"))
    );
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Test
@SuppressWarnings("unchecked")
public void onePivotOneAggregation() throws Exception {
  String[] columnNames = {"n.lastName", "c1"};
  String cypher = "MATCH (n:Person) RETURN\n" +
    "n.lastName," +
    "collect(n.firstName) AS c1;";
  List<Map<String, Object>> cypherResults = submitAndGet(cypher);
  assertThat(cypherResults)
    .extracting(Map::keySet)
    .allSatisfy(columns -> assertThat(columns).containsExactly(columnNames));
  assertThat(cypherResults)
    .hasSize(4)
    .extracting(columnNames)
    .usingElementComparator(ignoreOrderInCollections())
    .containsAll(extract(cypherResults, byName(columnNames)))
    .containsExactlyInAnyOrder(
      tuple("Andresen", asList("Erik", "Erik", "Erik", "Lars")),
      tuple("Lehtinen", asList("Olavi")),
      tuple("Haugland", asList("Martin")),
      tuple("Pedersen", asList("Erlend"))
    );
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Test
public void aggregationsOnly() throws Exception {
  String[] columnNames = {"count(n1)", "count(n2)"};
  String cypher = "MATCH (n1)-[r]->(n2) RETURN count(n1), count(n2)";
  List<Map<String, Object>> cypherResults = submitAndGet(cypher);
  assertThat(cypherResults)
    .hasSize(1)
    .extracting(columnNames)
    .usingElementComparator(ignoreOrderInCollections())
    .containsAll(extract(cypherResults, byName(columnNames)))
    .containsExactlyInAnyOrder(
      tuple(22L, 22L)
    );
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Test
public void labelPredicate() throws Exception {
  String[] columnNames = {"isPerson", "count"};
  String cypher = "MATCH (n)\n" +
    "RETURN (n:Person) AS isPerson, count(*) AS count";
  List<Map<String, Object>> cypherResults = submitAndGet(cypher);
  assertThat(cypherResults)
    .hasSize(2)
    .extracting(columnNames)
    .usingElementComparator(ignoreOrderInCollections())
    .containsAll(extract(cypherResults, byName(columnNames)))
    .containsExactlyInAnyOrder(
      tuple(true, 7L),
      tuple(false, 11L)
    );
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Test
public void distinct() throws Exception {
  String[] columnNames = {"n.lastName", "type(r)"};
  String cypher = "MATCH ()-[r]->(n:Person) RETURN DISTINCT n.lastName, type(r)";
  List<Map<String, Object>> cypherResults = submitAndGet(cypher);
  assertThat(cypherResults)
    .hasSize(3)
    .extracting(columnNames)
    .usingElementComparator(ignoreOrderInCollections())
    .containsAll(extract(cypherResults, byName(columnNames)))
    .containsExactlyInAnyOrder(
      tuple("Andresen", "KNOWS"),
      tuple("Pedersen", "KNOWS"),
      tuple("Lehtinen", "KNOWS")
    );
}

代码示例来源:origin: opencypher/cypher-for-gremlin

@Test
public void multiple() throws Exception {
  String[] columnNames = {"type(r)", "count"};
  String cypher = "MATCH ()-[r]->() RETURN count(r) AS count, type(r)";
  List<Map<String, Object>> cypherResults = submitAndGet(cypher);
  assertThat(cypherResults)
    .hasSize(4)
    .extracting(columnNames)
    .usingElementComparator(ignoreOrderInCollections())
    .containsAll(extract(cypherResults, byName(columnNames)))
    .containsExactlyInAnyOrder(
      tuple("IS_LOCATED_IN", 6L),
      tuple("LIKES", 4L),
      tuple("KNOWS", 6L),
      tuple("IS_PART_OF", 6L)
    );
}

相关文章

微信公众号

最新文章

更多