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

x33g5p2x  于2022-01-20 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(75)

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

IterableAssert.containsExactlyElementsOf介绍

暂无

代码示例

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

@Test
public void uniqueIndex_parallel_stream() {
 Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity()));
 assertThat(map.keySet()).isEqualTo(HUGE_SET);
 assertThat(map.values()).containsExactlyElementsOf(HUGE_SET);
}

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

@Test
public void uniqueIndex_with_valueFunction_and_expected_size_parallel_stream() {
 Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity(), identity(), HUGE_LIST.size()));
 assertThat(map.keySet()).isEqualTo(HUGE_SET);
 assertThat(map.values()).containsExactlyElementsOf(HUGE_SET);
}

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

@Test
public void uniqueIndex_with_expected_size_parallel_stream() {
 Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity(), HUGE_LIST.size()));
 assertThat(map.keySet()).isEqualTo(HUGE_SET);
 assertThat(map.values()).containsExactlyElementsOf(HUGE_SET);
}

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

@Test
public void uniqueIndex_with_valueFunction_parallel_stream() {
 Map<String, String> map = HUGE_LIST.parallelStream().collect(uniqueIndex(identity(), identity()));
 assertThat(map.keySet()).isEqualTo(HUGE_SET);
 assertThat(map.values()).containsExactlyElementsOf(HUGE_SET);
}

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

private void verifyComponentsHavingCopyComponentUuid(Component... expectedComponents) {
 Map<String, Component> expectedComponentsByUuid = Arrays.stream(expectedComponents).collect(MoreCollectors.uniqueIndex(Component::getUuid));
 List<Map<String, Object>> rows = db.select("SELECT uuid, copy_component_uuid FROM " + TABLE_PROJECTS + " WHERE copy_component_uuid IS NOT NULL");
 Map<String, Component> components = rows.stream()
  .map(map -> new Component((String) map.get("UUID"), (String) map.get("COPY_COMPONENT_UUID")))
  .collect(MoreCollectors.uniqueIndex(Component::getUuid));
 assertThat(components.keySet()).containsExactlyElementsOf(expectedComponentsByUuid.keySet());
 components.entrySet().forEach(entry -> {
  Component expectedComponent = expectedComponentsByUuid.get(entry.getKey());
  assertThat(expectedComponent.getUuid()).isEqualTo(entry.getKey());
  assertThat(expectedComponent.getCopyComponentUuid()).isEqualTo(entry.getValue().getCopyComponentUuid());
 });
}

代码示例来源:origin: jdbi/jdbi

@Test
public void immutableSortedSetWithComparator() {
  Comparator<Integer> comparator = Comparator.<Integer>naturalOrder().reversed();
  ImmutableSortedSet<Integer> set = dbRule.getSharedHandle().createQuery("select intValue from something")
      .mapTo(int.class)
      .collect(ImmutableSortedSet.toImmutableSortedSet(comparator));
  assertThat(set).containsExactlyElementsOf(expected.stream()
      .sorted(comparator)
      .collect(Collectors.toList()));
}

代码示例来源:origin: jdbi/jdbi

@Test
public void immutableSortedSet() {
  ImmutableSortedSet<Integer> set = dbRule.getSharedHandle().createQuery("select intValue from something")
      .collectInto(new GenericType<ImmutableSortedSet<Integer>>(){});
  assertThat(set).containsExactlyElementsOf(expected);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void verifyRecordWith2() {
  final List<Integer> source = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  Flux<Integer> flux = Flux.fromStream(source.stream());
  StepVerifier.create(flux)
        .recordWith(ArrayList::new)
        .expectNextCount(10)
        .consumeRecordedWith(c -> assertThat(c).containsExactlyElementsOf(source))
        .expectComplete()
        .verify();
}

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

@Test
 public void verify_readAnalysisWarnings() {
  ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
  ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
  ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
  writer.writeAnalysisWarnings(warnings);

  CloseableIterator<ScannerReport.AnalysisWarning> res = underTest.readAnalysisWarnings();
  assertThat(res).containsExactlyElementsOf(warnings);
  res.close();
 }
}

代码示例来源:origin: palantir/atlasdb

/**
 * Asserts that the specified RowResult contains the expected entries.
 * @param entry The RowResult to check
 * @param row expected row name (row names are expected to be integers converted to bytes)
 * @param cols expected set of columns in the RowResult (set of integers)
 * @param values expected timestamps as an union of timestamps for all the columns, order-invariant
 */
private void assertRowColumnsTimestamps(RowResult<Set<Long>> entry, int row, Set<Integer> cols, Long... values) {
  assertThat(entry.getRowName()).isEqualTo(PtBytes.toBytes(row));
  SortedMap<byte[], Set<Long>> columns = entry.getColumns();
  assertThat(columns.keySet()).containsExactlyElementsOf(
      cols.stream().map(PtBytes::toBytes).collect(Collectors.toList()));
  Set<Long> timestamps = new HashSet<>();
  columns.values().stream().forEach(set -> timestamps.addAll(set));
  assertThat(timestamps).containsExactlyInAnyOrder(values);
}

代码示例来源:origin: palantir/atlasdb

@SuppressWarnings("unchecked")
  private Map<Long, Long> assertRequestedTimestampsAndMapIdentity(InvocationOnMock invocation,
      Collection<Long> expected) {
    Collection<Long> timestamps = (Collection<Long>) invocation.getArguments()[0];
    assertThat(timestamps).containsExactlyElementsOf(expected);
    return timestamps.stream().collect(Collectors.toMap(n -> n, n -> n));
  }
}

代码示例来源:origin: palantir/atlasdb

@Test(timeout = 50000)
public void testSweepBatchesDownToDeleteBatchSize() {
  CellsSweeper cellsSweeper = Mockito.mock(CellsSweeper.class);
  SweepTaskRunner spiedSweepRunner =
      new SweepTaskRunner(kvs, tsSupplier, tsSupplier, txService, ssm, cellsSweeper);
  putTwoValuesInEachCell(SMALL_LIST_OF_CELLS);
  int deleteBatchSize = 1;
  Pair<List<List<Cell>>, SweepResults> sweptCellsAndSweepResults = runSweep(cellsSweeper, spiedSweepRunner,
      8, 8, deleteBatchSize);
  List<List<Cell>> sweptCells = sweptCellsAndSweepResults.getLhSide();
  assertThat(sweptCells).allMatch(list -> list.size() <= 2 * deleteBatchSize);
  assertThat(Iterables.concat(sweptCells)).containsExactlyElementsOf(SMALL_LIST_OF_CELLS);
}

代码示例来源:origin: palantir/atlasdb

private void assertDeleted(TableReference tableRef, Multimap<Cell, Long> expectedDeletes) {
  ArgumentCaptor<Multimap> argumentCaptor = ArgumentCaptor.forClass(Multimap.class);
  verify(spiedKvs).delete(eq(tableRef), argumentCaptor.capture());
  Multimap<Cell, Long> actual = argumentCaptor.getValue();
  assertThat(actual.keySet()).containsExactlyElementsOf(expectedDeletes.keySet());
  actual.keySet().forEach(key -> assertThat(actual.get(key)).containsExactlyElementsOf(expectedDeletes.get(key)));
}

代码示例来源:origin: palantir/atlasdb

@Test(timeout = 50000)
public void testSweepBatches() {
  CellsSweeper cellsSweeper = Mockito.mock(CellsSweeper.class);
  SweepTaskRunner spiedSweepRunner =
      new SweepTaskRunner(kvs, tsSupplier, tsSupplier, txService, ssm, cellsSweeper);
  putTwoValuesInEachCell(BIG_LIST_OF_CELLS);
  int deleteBatchSize = 2;
  Pair<List<List<Cell>>, SweepResults> sweptCellsAndSweepResults = runSweep(cellsSweeper, spiedSweepRunner,
      1000, 1, deleteBatchSize);
  List<List<Cell>> sweptCells = sweptCellsAndSweepResults.getLhSide();
  SweepResults sweepResults = sweptCellsAndSweepResults.getRhSide();
  assertThat(Iterables.concat(sweptCells)).containsExactlyElementsOf(BIG_LIST_OF_CELLS);
  for (List<Cell> sweptBatch : sweptCells.subList(0, sweptCells.size() - 1)) {
    // We requested deleteBatchSize = 2, so we expect between 2 and 4 timestamps deleted at a time.
    // We also expect a single timestamp to be swept per each cell.
    assertThat(sweptBatch.size()).isBetween(deleteBatchSize, 2 * deleteBatchSize);
  }
  // The last batch can be smaller than deleteBatchSize
  assertThat(sweptCells.get(sweptCells.size() - 1).size()).isLessThanOrEqualTo(2 * deleteBatchSize);
  assertEquals("Expected Ts Pairs Examined should add up to entire table (2 values in each cell)",
      2 * BIG_LIST_OF_CELLS.size(), sweepResults.getCellTsPairsExamined());
}

代码示例来源:origin: palantir/atlasdb

@Test(timeout = 50000)
public void testSweepBatchesInDifferentRows() {
  CellsSweeper cellsSweeper = Mockito.mock(CellsSweeper.class);
  SweepTaskRunner spiedSweepRunner =
      new SweepTaskRunner(kvs, tsSupplier, tsSupplier, txService, ssm, cellsSweeper);
  putTwoValuesInEachCell(BIG_LIST_OF_CELLS_IN_DIFFERENT_ROWS);
  int deleteBatchSize = 2;
  Pair<List<List<Cell>>, SweepResults> sweptCellsAndSweepResults = runSweep(cellsSweeper, spiedSweepRunner,
      10, 1, deleteBatchSize);
  List<List<Cell>> sweptCells = sweptCellsAndSweepResults.getLhSide();
  SweepResults sweepResults = sweptCellsAndSweepResults.getRhSide();
  assertThat(Iterables.concat(sweptCells)).containsExactlyElementsOf(BIG_LIST_OF_CELLS_IN_DIFFERENT_ROWS);
  for (List<Cell> sweptBatch : sweptCells.subList(0, sweptCells.size() - 1)) {
    // We requested deleteBatchSize = 2, so we expect between 2 and 4 timestamps deleted at a time.
    // We also expect a single timestamp to be swept per each cell.
    assertThat(sweptBatch.size()).isBetween(deleteBatchSize, 2 * deleteBatchSize);
  }
  // The last batch can be smaller than deleteBatchSize
  assertThat(sweptCells.get(sweptCells.size() - 1).size()).isLessThanOrEqualTo(2 * deleteBatchSize);
  assertEquals("Expected Ts Pairs Examined should add up to entire table (2 values in each cell)",
      2 * BIG_LIST_OF_CELLS_IN_DIFFERENT_ROWS.size(), sweepResults.getCellTsPairsExamined());
}

代码示例来源:origin: palantir/atlasdb

@Test
public void canGetRowsColumnRange() {
  BatchColumnRangeSelection rangeSelection = BatchColumnRangeSelection.create(null, null, 1);
  Map<byte[], RowColumnRangeIterator> rowsColumnRange = getTestKvs()
      .getRowsColumnRange(TEST_TABLE, ImmutableList.of(FIRST_ROW), rangeSelection, Long.MAX_VALUE);
  assertThat(Iterables.getOnlyElement(rowsColumnRange.keySet())).isEqualTo(FIRST_ROW);
  assertThat(rowsColumnRange.get(FIRST_ROW)).containsExactlyElementsOf(expectedRowEntries);
}

代码示例来源:origin: hcoles/pitest

@Test
public void shouldNotFilterMutationsWhenNoAnnotations() {
 final Collection<MutationDetails> input = someMutations();
 final Collection<MutationDetails> actual = runWithTestee(input, UnAnnotated.class);
 assertThat(actual).containsExactlyElementsOf(input);
}

代码示例来源:origin: hcoles/pitest

@Test
public void shouldLeaveMutantsNotOnLoggingLinesUntouched() {
 final ClassName clazz = ClassName.fromClass(DoesNotLog.class);
 final List<MutationDetails> input = this.mutator.findMutations(clazz);
 final Collection<MutationDetails> actual = analyseWithTestee(DoesNotLog.class);
 assertThat(actual).containsExactlyElementsOf(input);
}

代码示例来源:origin: palantir/atlasdb

@Test
public void canGetRange() {
  RangeRequest range = RangeRequest.builder().endRowExclusive(SECOND_ROW).build();
  ClosableIterator<RowResult<Value>> resultIterator = getTestKvs().getRange(TEST_TABLE, range, Long.MAX_VALUE);
  Map<byte[], Value> expectedColumns = ImmutableMap.of(FIRST_COLUMN, VALUE, SECOND_COLUMN, VALUE);
  RowResult<Value> expectedRowResult = RowResult.create(FIRST_ROW,
      ImmutableSortedMap.copyOf(expectedColumns, UnsignedBytes.lexicographicalComparator()));
  assertThat(resultIterator).containsExactlyElementsOf(ImmutableList.of(expectedRowResult));
}

代码示例来源:origin: com.palantir.atlasdb/atlasdb-tests-shared

@Test(timeout = 50000)
public void testSweepBatchesDownToDeleteBatchSize() {
  CellsSweeper cellsSweeper = Mockito.mock(CellsSweeper.class);
  SweepTaskRunner spiedSweepRunner =
      new SweepTaskRunner(kvs, tsSupplier, tsSupplier, txService, ssm, cellsSweeper);
  putTwoValuesInEachCell(SMALL_LIST_OF_CELLS);
  int deleteBatchSize = 1;
  Pair<List<List<Cell>>, SweepResults> sweptCellsAndSweepResults = runSweep(cellsSweeper, spiedSweepRunner,
      8, 8, deleteBatchSize);
  List<List<Cell>> sweptCells = sweptCellsAndSweepResults.getLhSide();
  assertThat(sweptCells).allMatch(list -> list.size() <= 2 * deleteBatchSize);
  assertThat(Iterables.concat(sweptCells)).containsExactlyElementsOf(SMALL_LIST_OF_CELLS);
}

相关文章

微信公众号

最新文章

更多