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

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

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

ListAssert.containsExactlyElementsOf介绍

暂无

代码示例

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

@Test
public void executeLargeUpdates() {
 List<Integer> inputs = newArrayList();
 for (int i = 0; i < 2010; i++) {
  inputs.add(i);
 }
 List<Integer> processed = newArrayList();
 DatabaseUtils.executeLargeUpdates(inputs, input -> {
  assertThat(input.size()).isLessThanOrEqualTo(1000);
  processed.addAll(input);
 });
 assertThat(processed).containsExactlyElementsOf(inputs);
}

代码示例来源:origin: cbeust/testng

@Test
public void testSimpleDataProviderWithListenerAnnotationAndInvolvingInheritance() {
 final String prefix =
   ":" + SimpleDataProviderWithListenerAnnotationSample1.class.getName() + ".testMethod";
 TestNG tng = create(SimpleDataProviderWithListenerAnnotationSample1.class);
 tng.run();
 assertThat(LocalDataProviderListener.messages)
   .containsExactlyElementsOf(Arrays.asList("before" + prefix, "after" + prefix));
}

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

@Test
public void testIntList() {
  List<Integer> testIntList = Arrays.stream(testInts).boxed().collect(Collectors.toList());
  ao.insertIntList(testIntList);
  assertThat(ao.fetchIntList()).containsExactlyElementsOf(testIntList);
}

代码示例来源:origin: cbeust/testng

@Test
public void ensureExecutionListenerIsInvokedOnlyOnce() {
  XmlSuite suite = createXmlSuite("suite");
  createXmlTest(suite, "test1", TestClassSample.class, TestClassTwoSample.class);
  createXmlTest(suite, "test2", TestClassSample.class, TestClassTwoSample.class);
  TestNG testng = create(suite);
  testng.run();
  assertThat(LocalExecutionListener.getFinish()).containsExactlyElementsOf(Collections.singletonList("finish"));
  assertThat(LocalExecutionListener.getStart()).containsExactlyElementsOf(Collections.singletonList("start"));
}

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

@Test
  public void fluxInitialValueCanBeConsumedMultipleTimes() {
//        "A deferred Flux with initial values can be consumed multiple times"
//         given: "a composable with an initial value"
    Flux<String> stream = Flux.just("test", "test2", "test3")
                 .map(v -> v)
                 .log();

//        when: "the value is retrieved"
    List<String> value1 = stream.collectList().block();
    List<String> value2 = stream.collectList().block();

//        then: "it is available"
    assertThat(value1).containsExactlyElementsOf(value2);
  }

代码示例来源:origin: cbeust/testng

private static void runTest(String prefix, Class<?> clazz, boolean hasListenerAnnotation) {
 TestNG tng = create(clazz);
 if (!hasListenerAnnotation) {
  tng.addListener(new LocalDataProviderListener());
 }
 tng.run();
 assertThat(LocalDataProviderListener.messages)
   .containsExactlyElementsOf(Arrays.asList("before" + prefix, "after" + prefix));
}

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

@Test
public void scanOrDefaultOverridesGlobalDefault() {
  Scannable emptyScannable = key -> null;
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.BUFFERED, 123)).isEqualTo(123); //global 0
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.CAPACITY, 123)).isEqualTo(123); //global 0
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.PREFETCH, 123)).isEqualTo(123); //global 0
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.LARGE_BUFFERED, 123L)).isEqualTo(123L); //global null
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM, 123L)).isEqualTo(123L); //global 0
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.CANCELLED, true)).isTrue(); //global false
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.DELAY_ERROR, true)).isTrue(); //global false
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.TERMINATED, true)).isTrue(); //global false
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.ERROR, new IllegalStateException())).isInstanceOf(IllegalStateException.class); //global null
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.ACTUAL, Scannable.Attr.NULL_SCAN)).isSameAs(Scannable.Attr.NULL_SCAN); //global null
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.PARENT, Scannable.Attr.NULL_SCAN)).isSameAs(Scannable.Attr.NULL_SCAN); // global null
  List<Tuple2<String, String>> tags = Collections.singletonList(Tuples.of("some", "key"));
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.TAGS, tags.stream())).containsExactlyElementsOf(tags); //global null
  assertThat(emptyScannable.scanOrDefault(Scannable.Attr.NAME, "SomeName")).isEqualTo("SomeName"); // global null
}

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

@Test
public void testInsertWithPositionalParameters() {
  somethingDao.insertSomething(4, "Dave", 90);
  List<Map<String, Object>> rows = handle.select("select * from something where something_id=?", 4).mapToMap().list();
  assertThat(rows).containsExactlyElementsOf(ImmutableList.of(
      ImmutableMap.of("something_id", 4, "name", "Dave", "code", 90)));
}

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

@Test
public void testInsertWithDefaultParams() {
  somethingDao.insertWithDefaultParams("Greg", 21);
  List<Map<String, Object>> rows = handle.select("select * from something where something_id=?", 19).mapToMap().list();
  assertThat(rows).containsExactlyElementsOf(ImmutableList.of(
      ImmutableMap.of("something_id", 19, "name", "Greg", "code", 21)));
}

代码示例来源:origin: cbeust/testng

private static void runTestWithListenerViaSuiteXml(String prefix, Class<?> clazz) {
 XmlSuite xmlSuite = createXmlSuite("SampleSuite");
 XmlTest xmlTest = createXmlTest(xmlSuite, "SampleTest");
 createXmlClass(xmlTest, clazz);
 xmlSuite.addListener(LocalDataProviderListener.class.getName());
 TestNG tng = create(xmlSuite);
 tng.run();
 assertThat(LocalDataProviderListener.messages)
   .containsExactlyElementsOf(Arrays.asList("before" + prefix, "after" + prefix));
}

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

@Test
public void testExecuteSomeStatements() {
  try (Handle h = dbRule.openHandle()) {
    h.execute("insert into something (id, name) values (?, ?)", 3, "Patrick");
    List<Map<String, Object>> rs = h.select("select id, name from something").mapToMap().list();
    assertThat(rs).containsExactlyElementsOf(ImmutableList.of(ImmutableMap.of("id", 3L, "name", "Patrick")));
   }
}

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

@Test
  public void alwaysFalseWithNSimilarToSimpleZero() {
    List<Integer> expected = Flux.just(1, 2, 3).repeat(0).collectList().block();
    List<Integer> result = Flux.just(1, 2, 3).repeat(3, () -> false).collectList().block();

    assertThat(result).containsExactlyElementsOf(expected);
  }
}

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

private void assertPublished(DefaultInputFile file, Set<Integer> lines) {
 assertThat(new File(temp.getRoot(), "changed-lines-" + file.scannerId() + ".pb")).exists();
 ScannerReportReader reader = new ScannerReportReader(temp.getRoot());
 assertThat(reader.readComponentChangedLines(file.scannerId()).getLineList()).containsExactlyElementsOf(lines);
}

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

@Test
public void alwaysTrueWithNSimilarToSimpleN() {
  List<Integer> expected = Flux.just(1, 2, 3).repeat(3).collectList().block();
  List<Integer> result = Flux.just(1, 2, 3).repeat(3, () -> true).collectList().block();
  assertThat(result).containsExactlyElementsOf(expected);
}

代码示例来源:origin: cbeust/testng

@Test(dataProvider = "dp", description ="GITHUB-1029" )
public void ensureXmlTestIsNotNull(Class<?> clazz, XmlSuite.ParallelMode mode) {
 XmlSuite xmlSuite = createXmlSuite("Suite");
 createXmlTest(xmlSuite, "GITHUB-1029-Test", clazz);
 xmlSuite.setParallel(mode);
 Issue1029InvokedMethodListener listener = new Issue1029InvokedMethodListener();
 TestNG testng = create(xmlSuite);
 testng.addListener(listener);
 testng.setThreadCount(10);
 testng.setDataProviderThreadCount(10);
 testng.run();
 List<String> expected = Collections.nCopies(5, "GITHUB-1029-Test");
 assertThat(listener.getBeforeInvocation()).containsExactlyElementsOf(expected);
 assertThat(listener.getAfterInvocation()).containsExactlyElementsOf(expected);
}

代码示例来源:origin: cbeust/testng

@Test(dataProvider = "dp")
public void testListenerInvocation(Class<?> clazz, XmlSuite.FailurePolicy policy, List<String> expected) {
  TestNG tng = create(clazz);
  ListenerForIssue1602 listener = new ListenerForIssue1602();
  tng.setConfigFailurePolicy(policy);
  tng.setVerbose(2);
  tng.addListener(listener);
  tng.run();
  assertThat(listener.getLogs()).containsExactlyElementsOf(expected);
}

代码示例来源:origin: cbeust/testng

@Test(description = "GITHUB-1770")
 public void verifyDataProvider2() {
  InvokedMethodNameListener listener = new InvokedMethodNameListener();
  XmlSuite xmlSuite = createXmlSuite("xml_suite");
  XmlTest xmlTest = createXmlTest(xmlSuite, "xml_test", SampleTestFour.class);
  Map<String, String> parameters = Maps.newHashMap();
  parameters.put("isCustom", RANDOM_VALUE);
  xmlTest.setParameters(parameters);
  TestNG testng = create(xmlSuite);
  testng.addListener(listener);
  testng.run();
  assertThat(listener.getLogs("test"))
    .containsExactlyElementsOf(Collections.singletonList(RANDOM_VALUE));
 }
}

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

@Test
public void iterableWithCombinatorHasCorrectLength() {
  Flux<Integer> flux1 = Flux.just(1);
  Flux<Integer> flux2 = Flux.just(2);
  Flux<Integer> flux3 = Flux.just(3);
  Flux<Integer> flux4 = Flux.just(4);
  List<Object> expected = Arrays.asList(1, 2, 3, 4);
  Flux<List<Object>> zipped =
      Flux.zip(Arrays.asList(flux1, flux2, flux3, flux4), Arrays::asList);
  StepVerifier.create(zipped)
        .consumeNextWith(t -> Assertions.assertThat(t)
                        .containsExactlyElementsOf(expected))
        .expectComplete()
        .verify();
}

代码示例来源:origin: cbeust/testng

private static void runTest(List<String> expected, Class<?> clazz, boolean skipInvocationCount) {
 TestNG testng = create(clazz);
 testng.setSkipFailedInvocationCounts(skipInvocationCount);
 UniversalListener listener = new UniversalListener();
 testng.addListener(listener);
 testng.alwaysRunListeners(false);
 testng.run();
 Assertions.assertThat(listener.getMessages()).containsExactlyElementsOf(expected);
}

代码示例来源:origin: cbeust/testng

private static void runTest(List<String> expected, Class<?> clazz, boolean skipInvocationCount) {
 TestNG testng = create(clazz);
 testng.setSkipFailedInvocationCounts(skipInvocationCount);
 UniversalListener listener = new UniversalListener();
 testng.addListener(listener);
 testng.alwaysRunListeners(true);
 testng.run();
 Assertions.assertThat(listener.getMessages()).containsExactlyElementsOf(expected);
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法