当前位置: 首页>>代码示例>>Java>>正文


Java StringDescription.toString方法代码示例

本文整理汇总了Java中org.hamcrest.StringDescription.toString方法的典型用法代码示例。如果您正苦于以下问题:Java StringDescription.toString方法的具体用法?Java StringDescription.toString怎么用?Java StringDescription.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hamcrest.StringDescription的用法示例。


在下文中一共展示了StringDescription.toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: failureDescriptionOf

import org.hamcrest.StringDescription; //导入方法依赖的package包/类
private static String failureDescriptionOf(Probe probe) {
    final StringDescription description = new StringDescription();

    description.appendText("\nTried to:\n    ")
               .appendDescriptionOf(probe)
               .appendText("\nbut:\n    ");
    probe.describeFailureTo(description);

    return description.toString();
}
 
开发者ID:testinfected,项目名称:mario,代码行数:11,代码来源:PollingProber.java

示例2: assertThat

import org.hamcrest.StringDescription; //导入方法依赖的package包/类
private static <T> void assertThat(final T obj, final String name, final Matcher<T> matcher) {
    if (!matcher.matches(obj)) {
        final StringDescription description = new StringDescription();
        description.appendText(name).appendText(" must fulfill this spec: ").appendDescriptionOf(matcher).appendText("\nbut: ");
        matcher.describeMismatch(obj, description);
        throw new IllegalArgumentException(description.toString());
    }
}
 
开发者ID:e-Spirit,项目名称:FSDevTools,代码行数:9,代码来源:ServerProperties.java

示例3: exceptionClassErrorStr

import org.hamcrest.StringDescription; //导入方法依赖的package包/类
public static String exceptionClassErrorStr(Class expected, Class actual) {
    StringDescription sd = new StringDescription();
    exceptionClassError(sd, expected, actual);
    return sd.toString();
}
 
开发者ID:AutSoft,项目名称:AxoloTL,代码行数:6,代码来源:DescriptionBuilder.java

示例4: errorCodeMismatchStr

import org.hamcrest.StringDescription; //导入方法依赖的package包/类
public static String errorCodeMismatchStr(int expectedErrorCode, int actualErrorCode) {
    StringDescription sd = new StringDescription();
    errorCodeMismatch(sd, expectedErrorCode, actualErrorCode);
    return sd.toString();
}
 
开发者ID:AutSoft,项目名称:AxoloTL,代码行数:6,代码来源:DescriptionBuilder.java

示例5: errorObjectMismatchStr

import org.hamcrest.StringDescription; //导入方法依赖的package包/类
public static String errorObjectMismatchStr(Object expectedErrorObject, Object actualErrorObject) {
    StringDescription sd = new StringDescription();
    errorObjectMismatch(sd, expectedErrorObject, actualErrorObject);
    return sd.toString();
}
 
开发者ID:AutSoft,项目名称:AxoloTL,代码行数:6,代码来源:DescriptionBuilder.java

示例6: verifyNoAbandoned

import org.hamcrest.StringDescription; //导入方法依赖的package包/类
private boolean verifyNoAbandoned(
    final ApiSurface checkedApiSurface,
    final Set<Matcher<Class<?>>> allowedClasses,
    final Description mismatchDescription) {

  // <helper_lambdas>

  final Function<Matcher<Class<?>>, String> toMessage =
      new Function<Matcher<Class<?>>, String>() {

        @Override
        public String apply(@Nonnull final Matcher<Class<?>> abandonedClassMacther) {
          final StringDescription description = new StringDescription();
          description.appendText("No ");
          abandonedClassMacther.describeTo(description);
          return description.toString();
        }
      };

  final Predicate<Matcher<Class<?>>> matchedByExposedClasses =
      new Predicate<Matcher<Class<?>>>() {

        @Override
        public boolean apply(@Nonnull final Matcher<Class<?>> classMatcher) {
          return FluentIterable.from(checkedApiSurface.getExposedClasses())
              .anyMatch(
                  new Predicate<Class<?>>() {

                    @Override
                    public boolean apply(@Nonnull final Class<?> aClass) {
                      return classMatcher.matches(aClass);
                    }
                  });
        }
      };

  // </helper_lambdas>

  final ImmutableSet<Matcher<Class<?>>> matchedClassMatchers =
      FluentIterable.from(allowedClasses).filter(matchedByExposedClasses).toSet();

  final Sets.SetView<Matcher<Class<?>>> abandonedClassMatchers =
      Sets.difference(allowedClasses, matchedClassMatchers);

  final ImmutableList<String> messages =
      FluentIterable.from(abandonedClassMatchers)
          .transform(toMessage)
          .toSortedList(Ordering.<String>natural());

  if (!messages.isEmpty()) {
    mismatchDescription.appendText(
        "The following white-listed scopes did not have matching classes on the API surface:"
            + "\n\t"
            + Joiner.on("\n\t").join(messages));
  }

  return messages.isEmpty();
}
 
开发者ID:apache,项目名称:beam,代码行数:59,代码来源:ApiSurface.java


注:本文中的org.hamcrest.StringDescription.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。