當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。