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