本文整理汇总了Java中org.hamcrest.Description.appendText方法的典型用法代码示例。如果您正苦于以下问题:Java Description.appendText方法的具体用法?Java Description.appendText怎么用?Java Description.appendText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hamcrest.Description
的用法示例。
在下文中一共展示了Description.appendText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchesSafely
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {
// check node identifier of master
String jsonNodeId = jsonNode.get("master").asText();
String nodeId = mastershipTerm.master().id();
if (!jsonNodeId.equals(nodeId)) {
description.appendText("master's node id was " + jsonNodeId);
return false;
}
// check term number
long jsonTermNumber = jsonNode.get("termNumber").asLong();
long termNumber = mastershipTerm.termNumber();
if (jsonTermNumber != termNumber) {
description.appendText("term number was " + jsonTermNumber);
return false;
}
return true;
}
示例2: isActuallyAnExcelFile
import org.hamcrest.Description; //导入方法依赖的package包/类
public static Matcher<byte[]> isActuallyAnExcelFile() {
return new BaseMatcher<byte[]>() {
@Override
public boolean matches(Object o) {
final List<String> names = new ArrayList<>();
try (ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream((byte[]) o))) {
ZipEntry zipEntry;
while ((zipEntry = zipStream.getNextEntry()) != null) {
names.add(zipEntry.getName());
zipStream.closeEntry();
}
} catch (IOException e) {
return false;
}
return hasItems("_rels/.rels", "docProps/app.xml", "xl/styles.xml", "xl/workbook.xml").matches(names);
}
@Override
public void describeTo(Description description) {
description.appendText("Given binary data corresponds to an excel file");
}
};
}
示例3: hasFieldWithUserRef
import org.hamcrest.Description; //导入方法依赖的package包/类
public static <T> Matcher<T> hasFieldWithUserRef(final String fieldName, final User user) {
return new BaseMatcher<T>() {
@Override
public boolean matches(Object o) {
Ref<User> userRef = TestSupport.getField(o, fieldName);
if (user == null) {
return userRef == null;
} else {
String username = userRef.getKey().getName();
return user.getUsername().equals(username);
}
}
@Override
public void describeTo(Description description) {
description.appendText(String.format("User with username '%s' on field %s", user, fieldName));
}
};
}
示例4: withItemViewAtPosition
import org.hamcrest.Description; //导入方法依赖的package包/类
/**
* <p>
* Returns a matcher that matches an item view at the given position
* in the RecyclerView matched by {@code recyclerViewMatcher}.
* </p>
* <p>
* If the item view at the given position is not laid out,
* the matcher returned by this method will not match anything.
* Call {@link android.support.test.espresso.contrib.RecyclerViewActions#scrollToPosition(int)}
* with the same position prior to calling this method
* in order to ensure that the item view is laid out.
* </p>
* <pre><code>
* onView(withId(R.id.recyclerView).perform(RecyclerViewActions.scrollToPosition(position);
* </code></pre>
*
* @param recyclerViewMatcher a matcher for RecyclerView containing the item view.
* @param position position of the item view in RecyclerView
*/
public static Matcher<View> withItemViewAtPosition(final Matcher<View> recyclerViewMatcher, final int position) {
return new TypeSafeMatcher<View>() {
@Override
protected boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
if (!(parent instanceof RecyclerView) || !recyclerViewMatcher.matches(parent)) {
return false;
}
RecyclerView.ViewHolder viewHolder = ((RecyclerView) parent).findViewHolderForAdapterPosition(position);
return viewHolder != null && viewHolder.itemView.equals(view);
}
@Override
public void describeTo(Description description) {
description.appendText("Item view at position " + position + " in recycler view ");
recyclerViewMatcher.describeTo(description);
}
};
}
示例5: matchModIPv6FlowLabelInstruction
import org.hamcrest.Description; //导入方法依赖的package包/类
/**
* Matches the contents of a mod IPv6 Flow Label instruction.
*
* @param instructionJson JSON instruction to match
* @param description Description object used for recording errors
* @return true if contents match, false otherwise
*/
private boolean matchModIPv6FlowLabelInstruction(JsonNode instructionJson,
Description description) {
ModIPv6FlowLabelInstruction instructionToMatch =
(ModIPv6FlowLabelInstruction) instruction;
final String jsonSubtype = instructionJson.get("subtype").textValue();
if (!instructionToMatch.subtype().name().equals(jsonSubtype)) {
description.appendText("subtype was " + jsonSubtype);
return false;
}
final String jsonType = instructionJson.get("type").textValue();
if (!instructionToMatch.type().name().equals(jsonType)) {
description.appendText("type was " + jsonType);
return false;
}
final int jsonFlowLabel = instructionJson.get("flowLabel").intValue();
final int flowLabel = instructionToMatch.flowLabel();
if (flowLabel != jsonFlowLabel) {
description.appendText("IPv6 flow label was " + jsonFlowLabel);
return false;
}
return true;
}
示例6: withinSecondsAfter
import org.hamcrest.Description; //导入方法依赖的package包/类
public static Matcher<String> withinSecondsAfter(Seconds seconds, DateTime after) {
return new TypeSafeMatcher<String>() {
@Override
public void describeTo(Description description) {
description.appendText(String.format(
"a date time within %s seconds after %s",
seconds.getSeconds(), after.toString()));
}
@Override
protected boolean matchesSafely(String textRepresentation) {
//response representation might vary from request representation
DateTime actual = DateTime.parse(textRepresentation);
return actual.isAfter(after) &&
Seconds.secondsBetween(after, actual).isLessThan(seconds);
}
};
}
示例7: matchesSafely
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {
// check application role
int jsonAppId = jsonNode.get("id").asInt();
int appId = applicationId.id();
if (jsonAppId != appId) {
description.appendText("application ID was " + jsonAppId);
return false;
}
String jsonAppName = jsonNode.get("name").asText();
String appName = applicationId.name();
if (!jsonAppName.equals(appName)) {
description.appendText("application name was " + jsonAppName);
return false;
}
return true;
}
示例8: matchesSafely
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(RecordedRequest item, Description mismatchDescription) {
if (item == null) {
mismatchDescription.appendText("was null");
return false;
}
switch (checkingOption) {
default:
case METHOD_PATH:
return matchesMethodAndPath(item, mismatchDescription);
case HEADER:
return matchesHeader(item, mismatchDescription);
case QUERY_PARAMETER:
return matchesQueryParameter(item, mismatchDescription);
}
}
示例9: hasMeasurementPeriodInMillis
import org.hamcrest.Description; //导入方法依赖的package包/类
private static TypeSafeMatcher<IncreaseOverTimeFrameUsageThresholdCondition>
hasMeasurementPeriodInMillis(final long millis) {
return new TypeSafeMatcher<IncreaseOverTimeFrameUsageThresholdCondition>() {
@Override
protected boolean matchesSafely(
IncreaseOverTimeFrameUsageThresholdCondition condition) {
return millis == condition.measurementPeriod;
}
@Override
public void describeTo(Description description) {
description.appendText("has a measurement period of '" + millis + "' millis");
}
};
}
示例10: withDisconnectedHost
import org.hamcrest.Description; //导入方法依赖的package包/类
@NonNull
public static Matcher<RecyclerView.ViewHolder> withDisconnectedHost() {
return new BoundedMatcher<RecyclerView.ViewHolder, HostListActivity.HostViewHolder>(HostListActivity.HostViewHolder.class) {
@Override
public boolean matchesSafely(HostListActivity.HostViewHolder holder) {
return hasDrawableState(holder.icon, android.R.attr.state_expanded);
}
@Override
public void describeTo(Description description) {
description.appendText("is disconnected status");
}
};
}
示例11: describeTo
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(Description description) {
description.appendText(reason);
}
示例12: describeTo
import org.hamcrest.Description; //导入方法依赖的package包/类
public void describeTo(Description description) {
description.appendText("an Object with the same fields as " + toMatch);
}
示例13: describeTo
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(Description description) {
description
.appendText("SagaEvent {sagaId=" + sagaId + ", operation=" + operation + ", class=" + aClass.getCanonicalName());
}
示例14: describeTo
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(final Description description) {
description.appendText("a Success");
}
示例15: matchesSafely
import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(
final FunctionalList<E> functionalList, final Description description) {
E head = functionalList.head();
Stream<E> stream = Stream.concat(
Stream.of(head), functionalList.tailStream());
List<E> list = stream.collect(Collectors.toList());
if (_matcher.matches(list)) {
return true;
}
description.appendText("was a functional list whose ");
_matcher.describeMismatch(list, description);
return false;
}