本文整理匯總了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();
}
示例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());
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}