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

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

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

AbstractBooleanAssert.describedAs介绍

暂无

代码示例

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

private void compareVersions(Map<String, VersionTag<VersionSource<?>>> versions,
  InternalDistributedMember defaultID,
  List<InternalDistributedMember> vmIds,
  List<RegionVersionVector<VersionSource<?>>> versionVectors) {
 for (Map.Entry<String, VersionTag<VersionSource<?>>> entry : versions.entrySet()) {
  VersionTag<VersionSource<?>> tag = entry.getValue();
  tag.replaceNullIDs(defaultID);
  for (int i = 0; i < vmIds.size(); i++) {
   assertThat(versionVectors.get(i).contains(tag.getMemberID(), tag.getRegionVersion()))
     .describedAs(
       vmIds.get(i) + " should contain " + tag)
     .isTrue();
  }
 }
}

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

@Test
public void testRollbackFailDoesntLeak() throws Exception {
  final BoomHandler handler = new BoomHandler();
  dbRule.getJdbi().setTransactionHandler(handler);
  final Handle h = dbRule.openHandle();
  assertThat(h.isClosed()).isFalse();
  handler.failRollback = true;
  assertThatThrownBy(() -> h.useTransaction(h2 -> h2.execute("insert into true")))
    .isInstanceOf(UnableToCreateStatementException.class);
  assertThat(h.isInTransaction())
    .describedAs("rollback failed but handle should still be in transaction").isTrue();
  assertThatThrownBy(h::close)
    .isInstanceOf(CloseException.class);
  assertThat(h.isClosed()).isTrue();
  assertThat(h.getConnection().isClosed()).isTrue();
}

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

@Override
 public void run() {
  try {
   long stopTime = System.currentTimeMillis() + 5000;
   Random ran = new Random(System.currentTimeMillis());
   while (System.currentTimeMillis() < stopTime) {
    for (int i = 0; i < 10; i++) {
     CCRegion.put("cckey" + i, new DeltaValue("ccvalue" + ran.nextInt()));
    }
   }
   long events = CCRegion.getCachePerfStats().getDeltaFailedUpdates();
   assertThat(events > 0).describedAs("expected some failed deltas").isTrue();
  } catch (CacheException e) {
   fail("while performing concurrent operations", e);
  }
 }
};

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

protected void awaitTermination(GfshScript script) throws InterruptedException {
 boolean exited = process.waitFor(script.getTimeout(), script.getTimeoutTimeUnit());
 try {
  assertThat(exited).describedAs("Process of [" + script.toString() + "] did not exit after "
    + script.getTimeout() + " " + script.getTimeoutTimeUnit().toString()).isTrue();
  assertThat(process.exitValue()).isEqualTo(script.getExpectedExitValue());
 } catch (AssertionError error) {
  printLogFiles();
  throw error;
 }
}

代码示例来源:origin: spring-io/initializr

public ProjectAssert assertFile(String localPath, boolean exist) {
  File candidate = file(localPath);
  assertThat(candidate.exists())
      .describedAs("Invalid presence (%s) exist for %s", exist, localPath)
      .isEqualTo(exist);
  return this;
}

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

case 2:
 case 4:
  assertThat(entry).isNotNull();
  assertThat(Arrays.equals(values[i], (byte[]) v)).isTrue();
  break;
 case 1: // updated
  assertThat(v).isNotNull();
  boolean condition = v instanceof Long;
  assertThat(condition).describedAs(
    "Value for key " + i + " is not a Long, is a " + v.getClass().getName()).isTrue();
  Long timestamp = (Long) entry.getValue();
assertThat(v).isNotNull();
boolean condition = v instanceof Long;
assertThat(condition).describedAs(
  "Value for key " + i + " is not a Long, is a " + v.getClass().getName()).isTrue();
Long timestamp = (Long) entry.getValue();

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

assertThat(manager.getHelper().hasAvailabilityIndicator(cliCommand.value()[0]))
  .describedAs(cliCommand.value()[0] + " in " + commandMarker.getClass()
    + " has no availability indicator defined. "
    + "Please add the command in the CommandAvailabilityIndicator")

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

@Test
public void testInvokeEquals() throws Throwable {
  final Method equalsMethod = testService.getClass().getMethod("equals", Object.class);
  final Boolean result = (Boolean) testSubject.invoke(testService, equalsMethod, new Object[] {testSubject});
  verify(methodHandler, times(0)).invoke(any());
  assertThat(feignDecorator.isCalled())
      .describedAs("FeignDecorator is called")
      .isTrue();
  assertThat(result)
      .describedAs("Return of invocation")
      .isTrue();
}

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

private void assertStats(DistributedMetricStatsInt distribution, String label, int onLeak, int offLeak, int total) {
 Optional<MetricStatsInt> statsOption = distribution.getForLabel(label);
 assertThat(statsOption.isPresent()).describedAs("distribution for label %s not found", label).isTrue();
 MetricStatsInt stats = statsOption.get();
 assertThat(stats.getOnLeak()).isEqualTo(onLeak);
 assertThat(stats.getTotal()).isEqualTo(total);
}

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

@Test
public void can_move_to_OPERATIONAL_from_STARTED_only() {
 for (State state : values()) {
  boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(OPERATIONAL);
  if (state == STARTED) {
   assertThat(tryToMoveTo).describedAs("from state " + state).isTrue();
  } else {
   assertThat(tryToMoveTo).describedAs("from state " + state).isFalse();
  }
 }
}

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

@Test
public void can_move_to_STOPPING_from_STARTING_STARTED_OPERATIONAL_only() {
 for (State state : values()) {
  boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(STOPPING);
  if (state == STARTING || state == STARTED || state == OPERATIONAL) {
   assertThat(tryToMoveTo).describedAs("from state " + state).isTrue();
  } else {
   assertThat(tryToMoveTo).describedAs("from state " + state).isFalse();
  }
 }
}

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

@Override
 public void run2() {
  Cache cache = getCache();
  Region<?, ?> pr = cache.getRegion(rName);
  assertThat(pr).describedAs("Region already destroyed.").isNotNull();
  pr.destroyRegion();
  assertThat(pr.isDestroyed()).describedAs("Region isDestroyed false").isTrue();
  assertThat(cache.getRegion(rName)).describedAs("Region not destroyed.").isNull();
 }
});

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

@Test
public void redactorWillIdentifySampleTabooProperties() {
 List<String> shouldBeRedacted = Arrays.asList("gemfire.security-password", "password",
   "other-password-option", CLUSTER_SSL_TRUSTSTORE_PASSWORD, GATEWAY_SSL_TRUSTSTORE_PASSWORD,
   SERVER_SSL_KEYSTORE_PASSWORD, "security-username", "security-manager",
   "security-important-property", "javax.net.ssl.keyStorePassword",
   "javax.net.ssl.some.security.item", "javax.net.ssl.keyStoreType", "sysprop-secret-prop");
 for (String option : shouldBeRedacted) {
  assertThat(isTaboo(option))
    .describedAs("This option should be identified as taboo: " + option).isTrue();
 }
}

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

@Test
public void redactorWillAllowSampleMiscProperties() {
 List<String> shouldNotBeRedacted = Arrays.asList("gemfire.security-manager",
   CLUSTER_SSL_ENABLED, CONSERVE_SOCKETS, "username", "just-an-option");
 for (String option : shouldNotBeRedacted) {
  assertThat(isTaboo(option))
    .describedAs("This option should not be identified as taboo: " + option).isFalse();
 }
}

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

@Test
public void testInvokeToString() throws Throwable {
  final Method toStringMethod = testService.getClass().getMethod("toString");
  final Object result = testSubject.invoke(testService, toStringMethod, new Object[0]);
  verify(methodHandler, times(0)).invoke(any());
  assertThat(feignDecorator.isCalled())
      .describedAs("FeignDecorator is called")
      .isTrue();
  assertThat(result)
      .describedAs("Return of invocation")
      .isEqualTo(target.toString());
}

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

@Test
  public void testInvokeHashcode() throws Throwable {
    final Method hashCodeMethod = testService.getClass().getMethod("hashCode");

    final Integer result = (Integer) testSubject.invoke(testService, hashCodeMethod, new Object[0]);

    verify(methodHandler, times(0)).invoke(any());
    assertThat(feignDecorator.isCalled())
        .describedAs("FeignDecorator is called")
        .isTrue();
    assertThat(result)
        .describedAs("Return of invocation")
        .isEqualTo(target.hashCode());
  }
}

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

@Test
public void scanSubscriberTerminated() {
  BlockingIterable.SubscriberIterator<String> test =
      new BlockingIterable.SubscriberIterator<>(Queues.<String>one().get(), 123);
  assertThat(test.scan(Scannable.Attr.TERMINATED)).describedAs("before TERMINATED").isFalse();
  test.onComplete();
  assertThat(test.scan(Scannable.Attr.TERMINATED)).describedAs("after TERMINATED").isTrue();
}

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

@Test
public void testInvoke() throws Throwable {
  final Object result = testSubject.invoke(testService, greetingMethod, new Object[0]);
  verify(methodHandler, times(1)).invoke(any());
  assertThat(feignDecorator.isCalled())
      .describedAs("FeignDecorator is called")
      .isTrue();
  assertThat(result)
      .describedAs("Return of invocation")
      .isEqualTo(testService.greeting());
}

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

assertThat(size).describedAs("Size doesn't return expected value")
  .isEqualTo(PUT_RANGE_1_END);
assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region")
  .isFalse();
assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region")
  .isFalse();
 boolean replaceSucceeded =
   pr.replace(Integer.toString(i), Integer.toString(i), "replaced" + i);
 assertThat(replaceSucceeded).describedAs("for i=" + i).isTrue();
assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region")
  .isFalse();
 assertThat(replaceSucceeded).describedAs("for i=" + i).isFalse();
assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region")
  .isFalse();
assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region")
  .isFalse();
assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region")
  .isFalse();
 assertThat(removeResult).describedAs("for i=" + i).isFalse();
 Object expected1 =
   i <= PUT_RANGE_1_END ? "twice replaced" + i : null;

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

@Test
public void scanSubscriberCancelled() {
  BlockingIterable.SubscriberIterator<String> test = new BlockingIterable.SubscriberIterator<>(
      Queues.<String>one().get(),
      123);
  //simulate cancellation by offering two elements
  test.onNext("a");
  assertThat(test.scan(Scannable.Attr.CANCELLED)).describedAs("before CANCELLED").isFalse();
  test.onNext("b");
  assertThat(test.scan(Scannable.Attr.CANCELLED)).describedAs("after CANCELLED").isTrue();
}

相关文章