本文整理汇总了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();
}