本文整理汇总了Java中org.hamcrest.StringDescription.appendText方法的典型用法代码示例。如果您正苦于以下问题:Java StringDescription.appendText方法的具体用法?Java StringDescription.appendText怎么用?Java StringDescription.appendText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hamcrest.StringDescription
的用法示例。
在下文中一共展示了StringDescription.appendText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
StringDescription description = new StringDescription();
RecyclerView recyclerView = (RecyclerView) view;
sortedList = withAdapter.itemsToSort(recyclerView);
checkIsNotEmpty(view, description);
description.appendText("The list " + sortedList + " is not sorted");
assertTrue(description.toString(), Ordering.natural().<T>isOrdered(sortedList));
}
示例2: checkIsNotEmpty
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
private void checkIsNotEmpty(View view, StringDescription description) {
if (sortedList.isEmpty()) {
description.appendText("The list must be not empty");
throw (new PerformException.Builder())
.withActionDescription(description.toString())
.withViewDescription(HumanReadables.describe(view))
.withCause(new IllegalStateException("The list is empty"))
.build();
}
}
示例3: testIndentDescription
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
@Test
public void testIndentDescription() throws Exception {
StringDescription innerDescription = new StringDescription();
innerDescription.appendText("a\nb");
StringDescription description = new StringDescription();
DescriptionUtils.indentDescription(description, innerDescription);
assertThat(description.toString(), is("a\n b\n"));
}
示例4: testIndentDescriptionNoExtraNewline
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
@Test
public void testIndentDescriptionNoExtraNewline() throws Exception {
StringDescription innerDescription = new StringDescription();
innerDescription.appendText("a\nb\n");
StringDescription description = new StringDescription();
DescriptionUtils.indentDescription(description, innerDescription);
assertThat(description.toString(), is("a\n b\n"));
}
示例5: dispatch
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
@Override
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
for (Map.Entry<Matcher<RecordedRequest>, MockResponse> response : responses.entrySet()) {
Matcher<RecordedRequest> requestMatcher = response.getKey();
if (requestMatcher.matches(request)) {
return response.getValue();
} else {
StringDescription description = new StringDescription();
description.appendText("Did not match request");
requestMatcher.describeMismatch(request, description);
Log.v(MatchingDispatcher.class.getName(), description.toString());
}
}
return new MockResponse().setResponseCode(500);
}
示例6: check
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
StringDescription description = new StringDescription();
RecyclerView recyclerView = (RecyclerView) view;
sortedList = withAdapter.itemsToSort(recyclerView);
checkIsNotEmpty(view, description);
description.appendText("The list "+ sortedList + " is not sorted");
assertTrue(description.toString(), Ordering.natural().<T>isOrdered(sortedList));
}
示例7: checkIsNotEmpty
import org.hamcrest.StringDescription; //导入方法依赖的package包/类
private void checkIsNotEmpty(View view, StringDescription description) {
if (sortedList.isEmpty()) {
description.appendText("The list must be not null");
throw (new PerformException.Builder())
.withActionDescription(description.toString())
.withViewDescription(HumanReadables.describe(view))
.withCause(new IllegalStateException("The list is empty"))
.build();
}
}
示例8: 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();
}