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


Java Matcher.describeMismatch方法代码示例

本文整理汇总了Java中org.hamcrest.Matcher.describeMismatch方法的典型用法代码示例。如果您正苦于以下问题:Java Matcher.describeMismatch方法的具体用法?Java Matcher.describeMismatch怎么用?Java Matcher.describeMismatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hamcrest.Matcher的用法示例。


在下文中一共展示了Matcher.describeMismatch方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: everyItemInArray

import org.hamcrest.Matcher; //导入方法依赖的package包/类
private static <T> Matcher<T[]> everyItemInArray(final Matcher<T> itemMatcher) {
    return new TypeSafeDiagnosingMatcher<T[]>() {

        @Override
        public void describeTo(Description description) {
            description.appendText("every item in array is ").appendDescriptionOf(itemMatcher);
        }

        @Override
        protected boolean matchesSafely(T[] items, Description mismatchDescription) {
            for (T item : items) {
                if (!itemMatcher.matches(item)) {
                    mismatchDescription.appendText("an item ");
                    itemMatcher.describeMismatch(item, mismatchDescription);
                    return false;
                }
            }
            return true;
        }

    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:IncludeAccessorsPropertiesIT.java

示例2: check

import org.hamcrest.Matcher; //导入方法依赖的package包/类
public <T> PropertyMismatchDescriber check(String propertyName, T propertyValue, Matcher<? super T> matcher) {
  if (matcher == null) {
    return this;
  }
  if (matcher.matches(propertyValue)) {
    return this;
  }

  matches = false;

  newline(description).appendText(propertyName).appendText(": ");
  indent();
  matcher.describeMismatch(propertyValue, description);
  outdent();

  return this;
}
 
开发者ID:poetix,项目名称:fluvius,代码行数:18,代码来源:PropertyMismatchDescriber.java

示例3: matchesSafely

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(List<FlowEvent<T>> flowEvents, Description description) {
  if (flowEvents.size() != matchers.size()) {
    description.appendText("history contained ").appendText(Integer.toString(flowEvents.size())).appendText(" events");
    return false;
  }
  boolean matched = true;

  for (int i = 0; i < matchers.size(); i++) {
    Matcher<FlowEvent<T>> matcher = matchers.get(i);
    FlowEvent<T> flowEvent = flowEvents.get(i);
    if (!matcher.matches(flowEvent)) {
      matched = false;
      IndentationControl.newline(description)
          .appendText(Integer.toString(i))
          .appendText(": ");
      indent();
      matcher.describeMismatch(flowEvent, description);
      outdent();
    }
  }

  return matched;
}
 
开发者ID:poetix,项目名称:fluvius,代码行数:25,代码来源:AnEventHistory.java

示例4: testInvalidJsonObjectWithMultiConditionUpdatesDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidJsonObjectWithMultiConditionUpdatesDescription() {
	Conditions conditions = _builder.where(
		"apio", is(aJsonString(equalTo("Live long and prosper")))
	).where(
		"geek", is(aJsonBoolean(true))
	).build();

	Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);

	Description description = new StringDescription();

	stringMatcher.describeMismatch("{}", description);

	String expected =
		"was a JSON object {\n  apio: was null\n  geek: was null\n}";

	assertThat(description.toString(), is(expected));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:20,代码来源:IsJsonObjectStringMatcherTest.java

示例5: fail

import org.hamcrest.Matcher; //导入方法依赖的package包/类
static void fail(@Nullable Object actualValue, Matcher<?> matcher) {
  Description description =
      new StringDescription()
          .appendText("\nExpected: ")
          .appendDescriptionOf(matcher)
          .appendText("\n     but: ");
  matcher.describeMismatch(actualValue, description);
  AssertionError assertionError = new AssertionError(description.toString());
  assertionError.setStackTrace(ObjectChecker.trimStackTrace(assertionError.getStackTrace()));
  throw assertionError;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:ObjectChecker.java

示例6: assertThat

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Step("Matching Actual - {1} and Expected {2}")
public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
    if (!matcher.matches(actual)) {
        Description description = new StringDescription();
        description.appendText(reason)
                .appendText("\nExpected: ")
                .appendDescriptionOf(matcher)
                .appendText("\n     but: ");
        matcher.describeMismatch(actual, description);
        
        ScreenShotUtil.takeScreenShot();
        throw new AssertionError(description.toString());
    }
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:15,代码来源:UpdateAssert.java

示例7: propertyMatches

import org.hamcrest.Matcher; //导入方法依赖的package包/类
protected boolean propertyMatches(String propertyName, T propertyValue, Matcher<? super T> matcher, Description description) {
  if (matcher == null) {
    return true;
  }
  if (matcher.matches(propertyValue)) {
    return true;
  }
  newline(description).appendText(propertyName).appendText(": ");
  indent();
  matcher.describeMismatch(propertyValue, description);
  outdent();
  return false;
}
 
开发者ID:poetix,项目名称:fluvius,代码行数:14,代码来源:BasePropertyMatcher.java

示例8: testInvalidFunctionalListUpdatesDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidFunctionalListUpdatesDescription() {
	FunctionalList<Integer> functionalList = new FunctionalList<>(null, 1);

	Description description = new StringDescription();

	Matcher<FunctionalList<Integer>> functionalListMatcher =
		aFunctionalListThat(contains(2));

	functionalListMatcher.describeMismatch(functionalList, description);

	String expected = "was a functional list whose item 0: was <1>";

	assertThat(description.toString(), is(expected));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:16,代码来源:IsAFunctionalListTest.java

示例9: testInvalidJsonLongUpdatesValidDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidJsonLongUpdatesValidDescription() {
	JsonPrimitive jsonPrimitive = new JsonPrimitive(42L);

	Matcher<JsonElement> matcher = aJsonLong(equalTo(23L));

	Description description = new StringDescription();

	matcher.describeMismatch(jsonPrimitive, description);

	String expected = "was a number element with a value that was <42L>";

	assertThat(description.toString(), is(expected));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:15,代码来源:IsJsonLongMatcherTest.java

示例10: testInvalidJsonObjectUpdatesValidDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidJsonObjectUpdatesValidDescription() {
	Conditions conditions = _builder.build();

	Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);

	Description description = new StringDescription();

	stringMatcher.describeMismatch("{", description);

	assertThat(description.toString(), is("was not a JSON object"));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:13,代码来源:IsJsonObjectStringMatcherTest.java

示例11: testInvalidJsonBooleanUpdatesValidDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidJsonBooleanUpdatesValidDescription() {
	JsonPrimitive jsonPrimitive = new JsonPrimitive(true);

	Matcher<JsonElement> matcher = aJsonBoolean(false);

	Description description = new StringDescription();

	matcher.describeMismatch(jsonPrimitive, description);

	String expected = "was a boolean element with a value that was <true>";

	assertThat(description.toString(), is(expected));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:15,代码来源:IsJsonBooleanMatcherTest.java

示例12: testInvalidJsonIntUpdatesValidDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidJsonIntUpdatesValidDescription() {
	JsonPrimitive jsonPrimitive = new JsonPrimitive(42);

	Matcher<JsonElement> matcher = aJsonInt(equalTo(23));

	Description description = new StringDescription();

	matcher.describeMismatch(jsonPrimitive, description);

	String expected = "was a number element with a value that was <42>";

	assertThat(description.toString(), is(expected));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:15,代码来源:IsJsonIntMatcherTest.java

示例13: testInvalidJsonTextUpdatesValidDescription

import org.hamcrest.Matcher; //导入方法依赖的package包/类
@Test
public void testInvalidJsonTextUpdatesValidDescription() {
	JsonPrimitive jsonPrimitive = new JsonPrimitive("Live long");

	Matcher<JsonElement> matcher = aJsonString(equalTo("and prosper"));

	Description description = new StringDescription();

	matcher.describeMismatch(jsonPrimitive, description);

	String expected =
		"was a string element with a value that was \"Live long\"";

	assertThat(description.toString(), is(expected));
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:16,代码来源:IsJsonStringMatcherTest.java


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