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

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

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

ListAssert.size介绍

暂无

代码示例

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

@Test(dataProvider = "dp", description = "GITHUB-778")
public void testTimeOut(String timeout, int size, int lineNumber) {
 XmlSuite suite = new XmlSuite();
 suite.setTimeOut(timeout);
 StringReader stringReader = new StringReader(suite.toXml());
 List<String> resultLines = Lists.newArrayList();
 List<Integer> lineNumbers = grep(stringReader, "time-out=\"1000\"", resultLines);
 assertThat(lineNumbers).size().isEqualTo(size);
 assertThat(resultLines).size().isEqualTo(size);
 if (size > 0) {
  assertThat(lineNumbers.get(size - 1)).isEqualTo(lineNumber);
 }
}

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

@Test
 public void retryWithDataProvider() {
  TestNG testng = create(DataProviderRetryTest.class);
  TestListenerAdapter tla = new TestListenerAdapter();
  testng.addListener(tla);
  testng.run();
  assertThat(tla.getFailedTests()).size().isEqualTo(1);
  assertThat(tla.getSkippedTests()).size().isEqualTo(2);
 }
}

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

@Test(description = "GITHUB1509")
public void testDataProvidersThatReturnNull() {
 TestListenerAdapter tla = new TestListenerAdapter();
 TestNG tng = create(Github1509TestClassSample.class);
 tng.addListener(tla);
 tng.run();
 assertThat(tla.getFailedTests()).size().isEqualTo(1);
 ITestResult result = tla.getFailedTests().get(0);
 String className = Github1509TestClassSample.class.getName() + ".getData()";
 String msg =
   "Data Provider public java.lang.Object[][] " + className + " returned a null value";
 assertThat(result.getThrowable().getMessage()).contains(msg);
}

代码示例来源:origin: apache/geode

@Test
public void setsRegionEntryOnEvent_ifExistingRegionEntryIsValid() throws Exception {
 givenLocalRegion();
 givenConcurrencyChecks();
 givenExistingRegionEntry();
 Object oldValue = "oldValue";
 when(existingRegionEntry.getValueInVM(owner)).thenReturn(oldValue);
 doTxApplyDestroy();
 assertThat(pendingCallbacks).size().isEqualTo(1);
 EntryEventImpl event = pendingCallbacks.get(0);
 assertThat(event.getRegionEntry()).isSameAs(existingRegionEntry);
 assertThat(event.getOldValue()).isSameAs(oldValue);
 verify(owner).generateAndSetVersionTag(any(EntryEventImpl.class), same(existingRegionEntry));
 verify(existingRegionEntry, never()).makeTombstone(any(), any());
 verify(txEntryState).setVersionTag(event.getVersionTag());
}

代码示例来源:origin: PegaSysEng/pantheon

@Override
 public void verify(final Node node) {
  final List<String> response = node.execute(transaction);
  assertThat(response).isInstanceOf(List.class);
  assertThat(response).size().isEqualTo(expectedNodeNum);
 }
}

代码示例来源:origin: jlink/jqwik

@Example
void withUnboundParams() {
  PropertyMethodDescriptor descriptor = createDescriptor("propWithUnboundParams", "42", 11, 5, ShrinkingMode.OFF);
  CheckedProperty property = factory.fromDescriptor(descriptor, new PropertyExamples());
  assertThat(property.forAllParameters).size().isEqualTo(2);
  assertThat(property.forAllParameters.get(0).getType()).isEqualTo(int.class);
  assertThat(property.forAllParameters.get(0).getAnnotation(ForAll.class)).isNotNull();
  assertThat(property.forAllParameters.get(1).getType()).isEqualTo(String.class);
  assertThat(property.forAllParameters.get(1).getAnnotation(ForAll.class)).isNotNull();
}

代码示例来源:origin: jlink/jqwik

@Example
void simple() {
  PropertyMethodDescriptor descriptor = createDescriptor("prop", "42", 11, 4, ShrinkingMode.OFF);
  CheckedProperty property = factory.fromDescriptor(descriptor, new PropertyExamples());
  assertThat(property.propertyName).isEqualTo("prop");
  assertThat(property.forAllParameters).size().isEqualTo(2);
  assertThat(property.forAllParameters.get(0).getType()).isEqualTo(int.class);
  assertThat(property.forAllParameters.get(1).getType()).isEqualTo(String.class);
  List<Object> argsTrue = Arrays.asList(1, "test");
  List<Object> argsFalse = Arrays.asList(2, "test");
  assertThat(property.checkedFunction.test(argsTrue)).isTrue();
  assertThat(property.checkedFunction.test(argsFalse)).isFalse();
  assertThat(property.configuration.getStereotype()).isEqualTo("Property");
  assertThat(property.configuration.getSeed()).isEqualTo("42");
  assertThat(property.configuration.getTries()).isEqualTo(11);
  assertThat(property.configuration.getMaxDiscardRatio()).isEqualTo(4);
}

代码示例来源:origin: jlink/jqwik

@Example
void withNoParamsAndVoidResult() {
  PropertyMethodDescriptor descriptor = createDescriptor("propWithVoidResult", "42", 11, 5, ShrinkingMode.OFF);
  CheckedProperty property = factory.fromDescriptor(descriptor, new PropertyExamples());
  assertThat(property.forAllParameters).size().isEqualTo(0);
  List<Object> noArgs = Arrays.asList();
  assertThat(property.checkedFunction.test(noArgs)).isTrue();
}

代码示例来源:origin: jlink/jqwik

@Example
void twoParametersSatisfied() {
  CheckedFunction forAllFunction = args -> {
    assertThat(args).size().isEqualTo(2);
    assertThat(args.get(0)).isInstanceOf(Integer.class);
    assertThat(args.get(1)).isInstanceOf(Integer.class);
    return true;
  };
  Arbitrary<Integer> arbitrary1 = Arbitraries.samples(1, 2, 3, 4, 5);
  Arbitrary<Integer> arbitrary2 = Arbitraries.samples(1, 2, 3, 4, 5);
  ShrinkablesGenerator shrinkablesGenerator = randomizedShrinkablesGenerator(arbitrary1, arbitrary2);
  PropertyConfiguration configuration = aConfig().withTries(5).build();
  GenericProperty property = new GenericProperty("property with 2", configuration, shrinkablesGenerator, forAllFunction);
  PropertyCheckResult result = property.check(NULL_PUBLISHER, new Reporting[0]);
  assertThat(result.propertyName()).isEqualTo("property with 2");
  assertThat(result.status()).isEqualTo(PropertyCheckResult.Status.SATISFIED);
  assertThat(result.countTries()).isEqualTo(5);
  assertThat(result.countChecks()).isEqualTo(5);
  assertThat(result.randomSeed()).isEqualTo("1000");
  assertThat(result.throwable()).isNotPresent();
  assertThat(result.sample()).isNotPresent();
}

代码示例来源:origin: jlink/jqwik

@Example
void fourParametersFalsified() {
  int failingTry = 5;
  CheckedFunction forAllFunction = args -> {
    assertThat(args).size().isEqualTo(4);
    return ((int) args.get(0)) < failingTry;
  };
  Arbitrary<Integer> arbitrary1 = Arbitraries.samples(1, 2, 3, 4, 5);
  Arbitrary<Integer> arbitrary2 = Arbitraries.samples(1, 2, 3, 4, 5);
  Arbitrary<Integer> arbitrary3 = Arbitraries.samples(1, 2, 3, 4, 5);
  Arbitrary<Integer> arbitrary4 = Arbitraries.samples(1, 2, 3, 4, 5);
  ShrinkablesGenerator shrinkablesGenerator = randomizedShrinkablesGenerator(arbitrary1, arbitrary2, arbitrary3, arbitrary4);
  PropertyConfiguration configuration = aConfig().build();
  GenericProperty property = new GenericProperty("property with 4", configuration, shrinkablesGenerator, forAllFunction);
  PropertyCheckResult result = property.check(NULL_PUBLISHER, new Reporting[0]);
  assertThat(result.propertyName()).isEqualTo("property with 4");
  assertThat(result.status()).isEqualTo(PropertyCheckResult.Status.FALSIFIED);
  assertThat(result.countTries()).isEqualTo(failingTry);
  assertThat(result.countChecks()).isEqualTo(failingTry);
  assertThat(result.throwable()).isNotPresent();
  assertThat(result.sample()).isPresent();
  assertThat(result.sample().get()).containsExactly(failingTry, 1, 1, 1);
}

代码示例来源:origin: spring-projects/spring-integration-aws

assertThat(message.getPayload()).isInstanceOf(List.class);
List<String> payload = (List<String>) message.getPayload();
assertThat(payload).size().isEqualTo(1);
String record = payload.get(0);
assertThat(record).isEqualTo("bar");

相关文章

微信公众号

最新文章

更多

ListAssert类方法