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

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

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

AbstractListAssert.containsOnlyElementsOf介绍

暂无

代码示例

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

assertThat(lineBuilderCaptor.getAllValues())
 .extracting(DbFileSources.Line.Builder::getSource)
 .containsOnlyElementsOf(lines);
assertThat(lineBuilderCaptor.getAllValues())
 .extracting(DbFileSources.Line.Builder::getLine)

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

.containsOnlyElementsOf(expectedFilteredTypes);

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

assertThat(queryPlan).containsOnlyElementsOf(cluster.getMetadata().getAllHosts());
 assertThat(firstThree).containsOnlyElementsOf(replicas);
} else {
 assertThat(firstThree).containsExactlyElementsOf(replicas);

代码示例来源:origin: zeebe-io/zeebe

@Test
public void shouldActivateJobBatches() {
 // given
 final List<Long> jobKeys = createJobs(12);
 final List<Long> expectedFirstJobKeys = jobKeys.subList(0, 3);
 final List<Long> expectedSecondJobKeys = jobKeys.subList(3, 7);
 final List<Long> expectedThirdJobKeys = jobKeys.subList(7, 10);
 // when
 final List<Job> firstJobs = activateJobs(3);
 final List<Job> secondJobs = activateJobs(4);
 final List<Job> thirdJobs = activateJobs(3);
 // then
 assertThat(firstJobs).extracting(Job::getKey).containsOnlyElementsOf(expectedFirstJobKeys);
 assertThat(secondJobs).extracting(Job::getKey).containsOnlyElementsOf(expectedSecondJobKeys);
 assertThat(thirdJobs).extracting(Job::getKey).containsOnlyElementsOf(expectedThirdJobKeys);
}

代码示例来源:origin: io.zeebe/zeebe-broker-core

@Test
public void shouldActivateJobBatches() {
 // given
 final List<Long> jobKeys = createJobs(12);
 final List<Long> expectedFirstJobKeys = jobKeys.subList(0, 3);
 final List<Long> expectedSecondJobKeys = jobKeys.subList(3, 7);
 final List<Long> expectedThirdJobKeys = jobKeys.subList(7, 10);
 // when
 final List<Job> firstJobs = activateJobs(3);
 final List<Job> secondJobs = activateJobs(4);
 final List<Job> thirdJobs = activateJobs(3);
 // then
 assertThat(firstJobs).extracting(Job::getKey).containsOnlyElementsOf(expectedFirstJobKeys);
 assertThat(secondJobs).extracting(Job::getKey).containsOnlyElementsOf(expectedSecondJobKeys);
 assertThat(thirdJobs).extracting(Job::getKey).containsOnlyElementsOf(expectedThirdJobKeys);
}

代码示例来源:origin: zeebe-io/zeebe

@Test
public void shouldActivateJobBatch() {
 // given
 final List<Long> expectedJobKeys = createJobs(5).subList(0, 3);
 // when
 final List<Job> jobs = activateJobs(3);
 // then
 assertThat(jobs).extracting(Job::getKey).containsOnlyElementsOf(expectedJobKeys);
 final List<Record<JobRecordValue>> record =
   jobRecords(JobIntent.ACTIVATED).limit(3).collect(Collectors.toList());
 assertThat(record).extracting(Record::getKey).containsOnlyElementsOf(expectedJobKeys);
}

代码示例来源:origin: io.zeebe/zeebe-broker-core

@Test
public void shouldActivateJobBatch() {
 // given
 final List<Long> expectedJobKeys = createJobs(5).subList(0, 3);
 // when
 final List<Job> jobs = activateJobs(3);
 // then
 assertThat(jobs).extracting(Job::getKey).containsOnlyElementsOf(expectedJobKeys);
 final List<Record<JobRecordValue>> record =
   jobRecords(JobIntent.ACTIVATED).limit(3).collect(Collectors.toList());
 assertThat(record).extracting(Record::getKey).containsOnlyElementsOf(expectedJobKeys);
}

代码示例来源:origin: zeebe-io/zeebe

@Test
public void shouldOnlyReturnJobsOfCorrectType() {
 // given
 final List<Long> jobKeys = createJobs(JOB_TYPE, 3);
 createJobs("different" + JOB_TYPE, 5);
 jobKeys.addAll(createJobs(JOB_TYPE, 4));
 // when
 final List<Job> jobs = activateJobs(JOB_TYPE, 7);
 // then
 assertThat(jobs).extracting(Job::getKey).containsOnlyElementsOf(jobKeys);
 final List<Record<JobRecordValue>> records =
   jobRecords(JobIntent.ACTIVATED).limit(jobKeys.size()).collect(Collectors.toList());
 assertThat(records).extracting(Record::getKey).containsOnlyElementsOf(jobKeys);
 assertThat(records).extracting("value.type").containsOnly(JOB_TYPE);
}

代码示例来源:origin: zeebe-io/zeebe

@Test
public void shouldCompleteActivatedJobs() {
 // given
 final int jobAmount = 5;
 final List<Long> jobKeys = createJobs(jobAmount);
 final List<Job> jobs = activateJobs(jobAmount);
 // when
 jobs.forEach(this::completeJob);
 // then
 final List<Record<JobRecordValue>> records =
   jobRecords(JobIntent.COMPLETED).limit(jobAmount).collect(Collectors.toList());
 assertThat(records).extracting(Record::getKey).containsOnlyElementsOf(jobKeys);
}

代码示例来源:origin: io.zeebe/zeebe-broker-core

@Test
public void shouldOnlyReturnJobsOfCorrectType() {
 // given
 final List<Long> jobKeys = createJobs(JOB_TYPE, 3);
 createJobs("different" + JOB_TYPE, 5);
 jobKeys.addAll(createJobs(JOB_TYPE, 4));
 // when
 final List<Job> jobs = activateJobs(JOB_TYPE, 7);
 // then
 assertThat(jobs).extracting(Job::getKey).containsOnlyElementsOf(jobKeys);
 final List<Record<JobRecordValue>> records =
   jobRecords(JobIntent.ACTIVATED).limit(jobKeys.size()).collect(Collectors.toList());
 assertThat(records).extracting(Record::getKey).containsOnlyElementsOf(jobKeys);
 assertThat(records).extracting("value.type").containsOnly(JOB_TYPE);
}

代码示例来源:origin: io.zeebe/zeebe-broker-core

@Test
public void shouldCompleteActivatedJobs() {
 // given
 final int jobAmount = 5;
 final List<Long> jobKeys = createJobs(jobAmount);
 final List<Job> jobs = activateJobs(jobAmount);
 // when
 jobs.forEach(this::completeJob);
 // then
 final List<Record<JobRecordValue>> records =
   jobRecords(JobIntent.COMPLETED).limit(jobAmount).collect(Collectors.toList());
 assertThat(records).extracting(Record::getKey).containsOnlyElementsOf(jobKeys);
}

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

private void testBlueFilter(final Function<List<FilterExpression<ProductProjection>>, ProductProjectionSearch> createSearch) {
  final ProductProjectionSearch search = createSearch.apply(PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).is("blue"));
  testResult(search, result -> {
    final List<ProductProjection> results = result.getResults();
    final Predicate<ProductVariant> isBlue = variant -> variant.findAttribute(COLOR_ATTRIBUTE_ACCESS)
        .map(color -> color.equals("blue"))
        .orElse(false);
    final Condition<ProductVariant> blueVariant = new Condition<>(isBlue, "variant is blue");
    assertThat(results)
        .flatExtracting(ProductProjection::getAllVariants)
        .areAtLeastOne(notMatching(blueVariant))
        .areAtLeastOne(blueVariant);
    final List<ProductVariant> allMatchingVariants = results.stream()
        .flatMap(r -> r.findMatchingVariants().stream())
        .collect(toList());
    assertThat(allMatchingVariants).are(blueVariant);
    assertThat(results)
        .extracting(r -> r.findFirstMatchingVariant().get())
        .containsOnlyElementsOf(allMatchingVariants);
  });
}

代码示例来源:origin: SonarSource/sonar-php

private void assertPredecessors(CfgBlock actualBlock, String blockTestId) {
 if (expectedCfg.hasNonEmptyPredecessors()) {
  List<String> expectedPred = expectedCfg.expectedPred(actualBlock);
  assertThat(expectedCfg.blockIds(actualBlock.predecessors()))
   .withFailMessage(buildDebugMessage("predecessors", blockTestId))
   .containsOnlyElementsOf(expectedPred);
 }
}

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

@Test
public void getApprovedReviewsForOneProduct() {
  final String productId = product.getId();
  final ReviewQuery reviewQuery = ReviewQuery.of()
      .withPredicates(review -> review.includedInStatistics().is(true).and(review.target().id().is(productId)))
      .withSort(m -> m.createdAt().sort().desc())
      .withLimit(REVIEWS_PER_PRODUCT);
  final List<Review> reviews = client().executeBlocking(reviewQuery).getResults();
  assertThat(reviews).hasSize(REVIEWS_PER_PRODUCT);
  assertThat(reviews).extracting(r -> r.getTarget().getId()).containsOnlyElementsOf(singletonList(productId));
  assertThat(reviews).extracting(r -> r.isIncludedInStatistics()).containsOnlyElementsOf(singletonList(true));
}

代码示例来源:origin: SonarSource/sonar-php

private void assertSuccessors(CfgBlock actualBlock) {
 String blockTestId = expectedCfg.testId(actualBlock);
 if (actualBlock instanceof PhpCfgBranchingBlock) {
  PhpCfgBranchingBlock actualIfBlock = (PhpCfgBranchingBlock) actualBlock;
  List<String> expectedSucc = expectedCfg.expectedSucc(actualBlock);
  assertThat(expectedSucc)
   .withFailMessage(buildDebugMessage("branching block must have 2 elements", blockTestId))
   .hasSize(2);
  assertThat(expectedCfg.testId(actualIfBlock.trueSuccessor()))
   .withFailMessage(buildDebugMessage("'true' branch successor", blockTestId))
   .isEqualTo(expectedSucc.get(0));
  assertThat(expectedCfg.testId(actualIfBlock.falseSuccessor()))
   .withFailMessage(buildDebugMessage("'false' branch successor", blockTestId))
   .isEqualTo(expectedSucc.get(1));
 } else {
  List<String> expectedSucc = expectedCfg.expectedSucc(actualBlock);
  List<String> actual = expectedCfg.blockIds(actualBlock.successors());
  assertThat(actual)
   .withFailMessage(buildDebugMessage(format("successors actual: %s expected %s", actual, expectedSucc), blockTestId))
   .containsOnlyElementsOf(expectedSucc);
 }
}

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

@Test
public void getReviewsForOneProduct() {
  final String productId = product.getId();
  final ReviewQuery reviewQuery = ReviewQuery.of()
      .withPredicates(m -> m.target().id().is(productId))
      .withSort(m -> m.createdAt().sort().desc())
      .withLimit(REVIEWS_PER_PRODUCT);
  final List<Review> reviews = client().executeBlocking(reviewQuery).getResults();
  assertThat(reviews).hasSize(REVIEWS_PER_PRODUCT);
  assertThat(reviews).extracting(r -> r.getTarget().getId()).containsOnlyElementsOf(singletonList(productId));
}

代码示例来源:origin: org.apache.james/james-server-jmap

@Test
public void processShouldReturnKeywordsWithoutForwardedWhenForwardedUserFlagsMessages() throws Exception {
  Flags flags = FlagsBuilder.builder()
    .add(Flag.ANSWERED, Flag.DELETED)
    .add(FORWARDED)
    .build();
  MessageManager inbox = mailboxManager.getMailbox(inboxPath, session);
  ComposedMessageId message1 = inbox.appendMessage(
    AppendCommand.builder()
      .withFlags(flags)
      .build(messageContent1),
    session);
  GetMessagesRequest request = GetMessagesRequest.builder()
    .ids(ImmutableList.of(message1.getMessageId()))
    .build();
  List<JmapResponse> result = testee.process(request, clientId, session).collect(Collectors.toList());
  assertThat(result).hasSize(1)
    .extracting(JmapResponse::getResponse)
    .hasOnlyElementsOfType(GetMessagesResponse.class)
    .extracting(GetMessagesResponse.class::cast)
    .flatExtracting(GetMessagesResponse::list)
    .extracting(Message::getKeywords)
    .containsOnlyElementsOf(
        ImmutableList.of(
          ImmutableMap.of(
            "$Answered", true,
            FORWARDED, true)));
}

代码示例来源:origin: remibantos/jeeshop

@Test
public void modifyProduct_ShouldModifyProductAttributesAndPreserveSKUsWhenNotProvided() {
  Product product = service.find(testCatalog.aProductWithSKUs().getId(), null);
  Product detachedProductToModify = new Product(testCatalog.aProductWithSKUs().getId(), product.getName(), product.getDescription(), product.getStartDate(), product.getEndDate(), product.isDisabled());
  service.modify(detachedProductToModify);
  assertThat(product.getChildSKUs()).containsOnlyElementsOf(product.getChildSKUs());
}

代码示例来源:origin: zeebe-io/zeebe

@Test
public void shouldActivateJobsFromWorkflow() {
 // given
 final int jobAmount = 10;
 deployWorkflow("foo", "bar", "baz");
 final List<Long> workflowInstanceKeys = createWorkflowInstances(jobAmount);
 // when activating and completing all jobs
 waitUntil(
   () -> jobRecords(JobIntent.CREATED).withType("foo").limit(jobAmount).count() == jobAmount);
 activateJobs("foo", jobAmount).forEach(this::completeJob);
 waitUntil(
   () -> jobRecords(JobIntent.CREATED).withType("bar").limit(jobAmount).count() == jobAmount);
 activateJobs("bar", jobAmount).forEach(this::completeJob);
 waitUntil(
   () -> jobRecords(JobIntent.CREATED).withType("baz").limit(jobAmount).count() == jobAmount);
 activateJobs("baz", jobAmount).forEach(this::completeJob);
 // then all workflow instances are completed
 final List<Record<WorkflowInstanceRecordValue>> records =
   workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED)
     .filter(r -> r.getKey() == r.getValue().getWorkflowInstanceKey())
     .limit(jobAmount)
     .collect(Collectors.toList());
 assertThat(records)
   .extracting(r -> r.getValue().getWorkflowInstanceKey())
   .containsOnlyElementsOf(workflowInstanceKeys);
}

代码示例来源:origin: io.zeebe/zeebe-broker-core

@Test
public void shouldActivateJobsFromWorkflow() {
 // given
 final int jobAmount = 10;
 deployWorkflow("foo", "bar", "baz");
 final List<Long> workflowInstanceKeys = createWorkflowInstances(jobAmount);
 // when activating and completing all jobs
 waitUntil(
   () -> jobRecords(JobIntent.CREATED).withType("foo").limit(jobAmount).count() == jobAmount);
 activateJobs("foo", jobAmount).forEach(this::completeJob);
 waitUntil(
   () -> jobRecords(JobIntent.CREATED).withType("bar").limit(jobAmount).count() == jobAmount);
 activateJobs("bar", jobAmount).forEach(this::completeJob);
 waitUntil(
   () -> jobRecords(JobIntent.CREATED).withType("baz").limit(jobAmount).count() == jobAmount);
 activateJobs("baz", jobAmount).forEach(this::completeJob);
 // then all workflow instances are completed
 final List<Record<WorkflowInstanceRecordValue>> records =
   workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED)
     .filter(r -> r.getKey() == r.getValue().getWorkflowInstanceKey())
     .limit(jobAmount)
     .collect(Collectors.toList());
 assertThat(records)
   .extracting(r -> r.getValue().getWorkflowInstanceKey())
   .containsOnlyElementsOf(workflowInstanceKeys);
}

相关文章

微信公众号

最新文章

更多