当前位置: 首页>>代码示例>>Java>>正文


Java Description.appendText方法代码示例

本文整理汇总了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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:MastershipTermCodecTest.java

示例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");
        }
    };
}
 
开发者ID:Dactilo,项目名称:spring-spreadsheet,代码行数:26,代码来源:SpreadsheetsMatchers.java

示例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));
        }
    };
}
 
开发者ID:3wks,项目名称:generator-thundr-gae-react,代码行数:21,代码来源:Matchers.java

示例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);
        }
    };
}
 
开发者ID:sumio,项目名称:espresso-sample-for-droidkaigi2017,代码行数:39,代码来源:RecyclerViewUtils.java

示例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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:InstructionJsonMatcher.java

示例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);
      }
    };
}
 
开发者ID:folio-org,项目名称:mod-circulation-storage,代码行数:20,代码来源:TextDateTimeMatcher.java

示例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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:ApplicationIdCodecTest.java

示例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);
    }
}
 
开发者ID:auth0,项目名称:Guardian.java,代码行数:18,代码来源:RecordedRequestMatcher.java

示例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");
    }
  };
}
 
开发者ID:SAP,项目名称:java-memory-assistant,代码行数:16,代码来源:IncreaseOverTimeFrameThresholdConditionTest.java

示例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");
		}
	};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ConnectbotMatchers.java

示例11: describeTo

import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(Description description) {
    description.appendText(reason);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:MulticastRouteResourceTest.java

示例12: describeTo

import org.hamcrest.Description; //导入方法依赖的package包/类
public void describeTo(Description description) {
    description.appendText("an Object with the same fields as " + toMatch);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:ReflectionEqualsMatcher.java

示例13: describeTo

import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(Description description) {
  description
      .appendText("SagaEvent {sagaId=" + sagaId + ", operation=" + operation + ", class=" + aClass.getCanonicalName());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:6,代码来源:SagaEventMatcher.java

示例14: describeTo

import org.hamcrest.Description; //导入方法依赖的package包/类
@Override
public void describeTo(final Description description) {
	description.appendText("a Success");
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:5,代码来源:SuccessTry.java

示例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;
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:22,代码来源:IsAFunctionalList.java


注:本文中的org.hamcrest.Description.appendText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。