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

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

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

ListAssert.containsOnlyElementsOf介绍

暂无

代码示例

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

private void validateNodeBean(final NodeBean nodeBean, final String name, final String type,
  final String configKey,
  final String configValue, final int numNodes, final List<String> dependsOn) {
 assertThat(nodeBean.getName()).isEqualTo(name);
 assertThat(nodeBean.getType()).isEqualTo(type);
 if (configKey != null) {
  assertThat(nodeBean.getConfig().get(configKey)).isEqualTo(configValue);
 }
 if (numNodes != 0) {
  assertThat(nodeBean.getNodes().size()).isEqualTo(numNodes);
 }
 if (dependsOn != null) {
  assertThat(nodeBean.getDependsOn()).containsOnlyElementsOf(dependsOn);
 }
}

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

private void validateAzkabanNode(final AzkabanNode azkabanNode, final String name,
  final String type, final Props props, final List<String> nodeList, final List<String>
  dependsOn) {
 assertThat(azkabanNode.getName()).isEqualTo(name);
 assertThat(azkabanNode.getType()).isEqualTo(type);
 assertThat(azkabanNode.getProps()).isEqualTo(props);
 if (azkabanNode instanceof AzkabanFlow) {
  assertThat(((AzkabanFlow) azkabanNode).getNodes().keySet()).containsOnlyElementsOf(nodeList);
 }
 if (dependsOn != null) {
  assertThat(azkabanNode.getDependsOn()).containsOnlyElementsOf(dependsOn);
 }
}

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

@Test
public void immutableList() {
  ImmutableList<Integer> list = dbRule.getSharedHandle().createQuery("select intValue from something")
      .collectInto(new GenericType<ImmutableList<Integer>>(){});
  assertThat(list).containsOnlyElementsOf(expected);
}

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

@Test
public void testMapToTuple2ListShouldSucceed() {
  List<Tuple2<Integer, String>> expectedTuples = expected.map(i -> new Tuple2<>(i, "t2" + i));
  java.util.List<Tuple2<Integer, String>> tupleProjection = dbRule.getSharedHandle()
      .createQuery("select t1, t2 from tuples")
      .mapTo(new GenericType<Tuple2<Integer, String>>() {}).list();
  assertThat(tupleProjection).containsOnlyElementsOf(expectedTuples);
}

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

@Test
public void partitioningOnlyReordersEvents() {
  CheckerResult checkerResult = runPartitionChecker(() -> identityChecker, eventList);
  assertThat(checkerResult.valid()).isFalse();
  assertThat(checkerResult.errors().size()).isEqualTo(eventList.size());
  assertThat(checkerResult.errors()).containsOnlyElementsOf(eventList);
}

代码示例来源:origin: OpenGamma/Strata

public void stream() {
 RatesCurveGroup test = RatesCurveGroup.of(NAME, DISCOUNT_CURVES, IBOR_CURVES);
 List<Curve> expected = ImmutableList.<Curve>builder()
   .addAll(DISCOUNT_CURVES.values())
   .addAll(IBOR_CURVES.values())
   .build();
 assertThat(test.stream().collect(toList())).containsOnlyElementsOf(expected);
}

代码示例来源:origin: apache/james-project

@Test
public void chunkShouldReturnOneArrayWhenInputEqualsChunkSize() {
  byte[] data = "1234567890".getBytes(StandardCharsets.UTF_8);
  assertThat(data.length).isEqualTo(CHUNK_SIZE);
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(data, CHUNK_SIZE);
  assertThat(chunks)
    .containsOnlyElementsOf(ImmutableList.of(Pair.of(0, ByteBuffer.wrap(data))));
}

代码示例来源:origin: apache/james-project

@Test
public void chunkShouldReturnOneArrayWhenInputLessThanChunkSize() {
  byte[] data = "12345".getBytes(StandardCharsets.UTF_8);
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(data, CHUNK_SIZE);
  assertThat(chunks)
    .containsOnlyElementsOf(ImmutableList.of(Pair.of(0, ByteBuffer.wrap(data))));
}

代码示例来源:origin: apache/james-project

@Test
public void chunkShouldReturnOneEmptyArrayWhenInputEmpty() {
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(new byte[0], CHUNK_SIZE);
  ByteBuffer emptyBuffer = ByteBuffer.wrap(new byte[0]);
  assertThat(chunks)
    .containsOnlyElementsOf(ImmutableList.of(Pair.of(0, emptyBuffer)));
}

代码示例来源:origin: org.apache.james/blob-cassandra

@Test
public void chunkShouldReturnOneEmptyArrayWhenInputEmpty() {
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(new byte[0], CHUNK_SIZE);
  ByteBuffer emptyBuffer = ByteBuffer.wrap(new byte[0]);
  assertThat(chunks)
    .containsOnlyElementsOf(ImmutableList.of(Pair.of(0, emptyBuffer)));
}

代码示例来源:origin: org.apache.james/blob-cassandra

@Test
public void chunkShouldReturnOneArrayWhenInputEqualsChunkSize() {
  byte[] data = "1234567890".getBytes(StandardCharsets.UTF_8);
  assertThat(data.length).isEqualTo(CHUNK_SIZE);
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(data, CHUNK_SIZE);
  assertThat(chunks)
    .containsOnlyElementsOf(ImmutableList.of(Pair.of(0, ByteBuffer.wrap(data))));
}

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

@Test
  public void authHeadersShouldReturnStreamOfHeadersWhenSome() {
    HttpServletRequest request = mock(HttpServletRequest.class);
    ImmutableList<String> expectedHeaders = ImmutableList.of("header", "otherHeader");
    when(request.getHeaders("Authorization"))
      .thenReturn(Collections.enumeration(expectedHeaders));

    assertThat(testee.authHeaders(request)).containsOnlyElementsOf(expectedHeaders);
  }
}

代码示例来源:origin: org.apache.james/blob-cassandra

@Test
public void chunkShouldReturnOneArrayWhenInputLessThanChunkSize() {
  byte[] data = "12345".getBytes(StandardCharsets.UTF_8);
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(data, CHUNK_SIZE);
  assertThat(chunks)
    .containsOnlyElementsOf(ImmutableList.of(Pair.of(0, ByteBuffer.wrap(data))));
}

代码示例来源:origin: org.apache.james/blob-cassandra

@Test
public void chunkShouldReturnSeveralArrayWhenInputBiggerThanChunkSize() {
  byte[] part1 = "1234567890".getBytes(StandardCharsets.UTF_8);
  byte[] part2 = "12345".getBytes(StandardCharsets.UTF_8);
  byte[] data = Bytes.concat(part1, part2);
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(data, CHUNK_SIZE);
  assertThat(chunks)
  .containsOnlyElementsOf(ImmutableList.of(
      Pair.of(0, ByteBuffer.wrap(part1)),
      Pair.of(1, ByteBuffer.wrap(part2))));
}

代码示例来源:origin: apache/james-project

@Test
public void chunkShouldReturnSeveralArrayWhenInputBiggerThanChunkSize() {
  byte[] part1 = "1234567890".getBytes(StandardCharsets.UTF_8);
  byte[] part2 = "12345".getBytes(StandardCharsets.UTF_8);
  byte[] data = Bytes.concat(part1, part2);
  Stream<Pair<Integer, ByteBuffer>> chunks = testee.chunk(data, CHUNK_SIZE);
  assertThat(chunks)
  .containsOnlyElementsOf(ImmutableList.of(
      Pair.of(0, ByteBuffer.wrap(part1)),
      Pair.of(1, ByteBuffer.wrap(part2))));
}

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

@Test
public void createMailboxesIfNeededShouldCreateSystemMailboxes() throws Exception {
  testee.createMailboxesIfNeeded(session);
  assertThat(mailboxManager.list(session))
    .containsOnlyElementsOf(DefaultMailboxes.DEFAULT_MAILBOXES
      .stream()
      .map(mailboxName -> MailboxPath.forUser(USERNAME, mailboxName))
      .collect(Guavate.toImmutableList()));
}

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

@Test
public void getRecipientsShouldReturnRecipientsWhenMailetRecipientsAreCommon() throws Exception {
  ImmutableList<MailAddress> expectedRecipients = ImmutableList.of(new MailAddress("test", "james.org"), new MailAddress("test2", "james.org"));
  when(mailet.getRecipients())
    .thenReturn(expectedRecipients);
  FakeMail fakeMail = FakeMail.defaultFakeMail();
  List<MailAddress> recipients = testee.getRecipients(fakeMail);
  assertThat(recipients).containsOnlyElementsOf(expectedRecipients);
}

代码示例来源:origin: org.jdbi/jdbi3-guava

@Test
public void immutableList() {
  ImmutableList<Integer> list = dbRule.getSharedHandle().createQuery("select intValue from something")
      .collectInto(new GenericType<ImmutableList<Integer>>(){});
  assertThat(list).containsOnlyElementsOf(expected);
}

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

@Test
public void getToShouldReturnToWhenMailetToAreCommon() throws Exception {
  MailAddress mailAddress = new MailAddress("test", "james.org");
  MailAddress mailAddress2 = new MailAddress("test2", "james.org");
  when(mailet.getTo())
    .thenReturn(ImmutableList.of(mailAddress.toInternetAddress(), mailAddress2.toInternetAddress()));
  FakeMail fakeMail = FakeMail.defaultFakeMail();
  List<MailAddress> to = testee.getTo(fakeMail);
  ImmutableList<MailAddress> expectedTo = ImmutableList.of(mailAddress, mailAddress2);
  assertThat(to).containsOnlyElementsOf(expectedTo);
}

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

@Test
public void createMailboxesIfNeededShouldNotGenerateExceptionsInConcurrentEnvironment() throws Exception {
  ConcurrentTestRunner.builder()
    .operation((threadNumber, step) -> testee.createMailboxesIfNeeded(session))
    .threadCount(10)
    .runSuccessfullyWithin(Duration.ofSeconds(10));
  assertThat(mailboxManager.list(session))
    .containsOnlyElementsOf(DefaultMailboxes.DEFAULT_MAILBOXES
      .stream()
      .map(mailboxName -> MailboxPath.forUser(USERNAME, mailboxName))
      .collect(Guavate.toImmutableList()));
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法