Java Code Examples for org.hamcrest.Description#appendDescriptionOf()

The following examples show how to use org.hamcrest.Description#appendDescriptionOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UriMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Uri> hasParamWithName(final Matcher<String> paramName) {
  checkNotNull(paramName);

  return new TypeSafeMatcher<Uri>() {

    @Override
    public boolean matchesSafely(Uri uri) {
      return hasItem(paramName).matches(getQueryParameterNames(uri));
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("has param with name: ");
      description.appendDescriptionOf(paramName);
    }
  };
}
 
Example 2
Source File: UriMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Uri> hasHost(final Matcher<String> hostMatcher) {
  checkNotNull(hostMatcher);

  return new TypeSafeMatcher<Uri>() {

    @Override
    public boolean matchesSafely(Uri uri) {
      return hostMatcher.matches(uri.getHost());
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("has host: ");
      description.appendDescriptionOf(hostMatcher);
    }
  };
}
 
Example 3
Source File: IntentMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Intent> hasPackage(final Matcher<String> packageMatcher) {
  checkNotNull(packageMatcher);

  return new TypeSafeMatcher<Intent>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("has pkg: ");
      description.appendDescriptionOf(packageMatcher);
    }

    @Override
    public boolean matchesSafely(Intent intent) {
      return packageMatcher.matches(intent.getPackage());
    }
  };
}
 
Example 4
Source File: IntentMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Intent> hasType(final Matcher<String> typeMatcher) {
  checkNotNull(typeMatcher);

  return new TypeSafeMatcher<Intent>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("has type: ");
      description.appendDescriptionOf(typeMatcher);
    }

    @Override
    public boolean matchesSafely(Intent intent) {
      return typeMatcher.matches(intent.getType());
    }
  };
}
 
Example 5
Source File: UriMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Uri> hasSchemeSpecificPart(
    final Matcher<String> schemeMatcher, final Matcher<String> schemeSpecificPartMatcher) {
  checkNotNull(schemeMatcher);
  checkNotNull(schemeSpecificPartMatcher);

  return new TypeSafeMatcher<Uri>() {

    @Override
    public boolean matchesSafely(Uri uri) {
      return schemeMatcher.matches(uri.getScheme())
          && schemeSpecificPartMatcher.matches(uri.getSchemeSpecificPart());
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("has scheme specific part: scheme: ");
      description.appendDescriptionOf(schemeMatcher);
      description.appendText(" scheme specific part: ");
      description.appendDescriptionOf(schemeSpecificPartMatcher);
    }
  };
}
 
Example 6
Source File: IntentMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Intent> hasExtras(final Matcher<Bundle> bundleMatcher) {
  checkNotNull(bundleMatcher);

  return new TypeSafeMatcher<Intent>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("has extras: ");
      description.appendDescriptionOf(bundleMatcher);
    }

    @Override
    public boolean matchesSafely(Intent intent) {
      return bundleMatcher.matches(intent.getExtras());
    }
  };
}
 
Example 7
Source File: IntentMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
/**
 * Can match an intent by class name, package name or short class name.
 *
 * @param componentMatcher can be the value of {@link ComponentNameMatchers#hasClassName}, {@link
 *     ComponentNameMatchers#hasPackageName} or {@link ComponentNameMatchers#hasShortClassName}
 */
public static Matcher<Intent> hasComponent(final Matcher<ComponentName> componentMatcher) {
  checkNotNull(componentMatcher);

  return new TypeSafeMatcher<Intent>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("has component: ");
      description.appendDescriptionOf(componentMatcher);
    }

    @Override
    public boolean matchesSafely(Intent intent) {
      return componentMatcher.matches(intent.getComponent());
    }
  };
}
 
Example 8
Source File: IntentMatchers.java    From android-test with Apache License 2.0 6 votes vote down vote up
public static Matcher<Intent> hasAction(final Matcher<String> actionMatcher) {
  checkNotNull(actionMatcher);

  return new TypeSafeMatcher<Intent>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("has action: ");
      description.appendDescriptionOf(actionMatcher);
    }

    @Override
    public boolean matchesSafely(Intent intent) {
      return actionMatcher.matches(intent.getAction());
    }
  };
}
 
Example 9
Source File: Retry.java    From tool.accelerate.core with Apache License 2.0 5 votes vote down vote up
@Override
public void describeMismatch(Object item, Description description) {
    if (errorMatches(item)) {
        description.appendText("did match ");
        description.appendDescriptionOf(neverMatches);
        neverMatches.describeMismatch(item, description);
    } else {
        matcher.describeMismatch(item, description);
    }
}
 
Example 10
Source File: UriMatchers.java    From android-test with Apache License 2.0 5 votes vote down vote up
public static Matcher<Uri> hasParamWithValue(
    final Matcher<String> paramName, final Matcher<String> paramVal) {
  checkNotNull(paramName);
  checkNotNull(paramVal);
  final Matcher<QueryParamEntry> qpe = queryParamEntry(paramName, paramVal);
  final Matcher<Iterable<? super QueryParamEntry>> matcherImpl = hasItem(qpe);

  return new TypeSafeMatcher<Uri>() {

    @Override
    public boolean matchesSafely(Uri uri) {
      List<QueryParamEntry> qpes = new ArrayList<>();
      for (String name : getQueryParameterNames(uri)) {
        qpes.add(new QueryParamEntry(name, uri.getQueryParameters(name)));
      }
      return matcherImpl.matches(qpes);
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("has param with: name: ");
      description.appendDescriptionOf(paramName);
      description.appendText(" value: ");
      description.appendDescriptionOf(paramVal);
    }
  };
}
 
Example 11
Source File: Retry.java    From tool.accelerate.core with Apache License 2.0 5 votes vote down vote up
@Override
public void describeTo(Description description) {
    description.appendText("after waiting up to 3 minutes ");
    description.appendDescriptionOf(matcher);
    if (neverMatches != null) {
        description.appendText(" and not ");
        description.appendDescriptionOf(neverMatches);
    }
}
 
Example 12
Source File: TermSubQueryBuilderTest.java    From querqy with Apache License 2.0 5 votes vote down vote up
@Override
public void describeTo(Description description) {
    description.appendText("PRMSAndQuery: ");
    for (TypeSafeMatcher<PRMSQuery> clause: clauses) {
        description.appendDescriptionOf(clause);
    }
}
 
Example 13
Source File: EqualsVariableMap.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void describeTo(Description description) {
  description.appendText("EqualsVariableMap: {");
  for (Map.Entry<String, Matcher<?>> matcher : matchers.entrySet()) {
    description.appendText(matcher.getKey() + " => ");
    description.appendDescriptionOf(matcher.getValue());
  }
  description.appendText("}");

}
 
Example 14
Source File: ComponentNameMatchers.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public void describeTo(Description description) {
  description.appendText("has component with: class name: ");
  description.appendDescriptionOf(classNameMatcher);
  description.appendText(" package name: ");
  description.appendDescriptionOf(packageNameMatcher);
  description.appendText(" short class name: ");
  description.appendDescriptionOf(shortClassNameMatcher);
}
 
Example 15
Source File: ExampleContentTestSupport.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void describeTo(final Description description) {
  for (int i = 0; i < extractors.size(); i++) {
    if (i > 0) {
      description.appendText(" AND ");
    }
    description.appendDescriptionOf(is(extractors.get(i).apply(expected)));
  }
}
 
Example 16
Source File: ProcessTaskTest.java    From amazon-kinesis-client with Apache License 2.0 4 votes vote down vote up
@Override
public void describeTo(Description description) {
    description.appendDescriptionOf(matchers);
}
 
Example 17
Source File: ThrowableMessageMatcher.java    From ogham with Apache License 2.0 4 votes vote down vote up
public void describeTo(Description description) {
	description.appendText("exception with message ");
	description.appendDescriptionOf(messageMatcher);
}
 
Example 18
Source File: IsInstanceThat.java    From batfish with Apache License 2.0 4 votes vote down vote up
@Override
public void describeTo(Description description) {
  description.appendDescriptionOf(_subMatcher);
}
 
Example 19
Source File: CauseMatcher.java    From crate with Apache License 2.0 4 votes vote down vote up
public void describeTo(Description description) {
    description.appendText("exception with cause of cause ");
    description.appendDescriptionOf(fMatcher);
}
 
Example 20
Source File: StringUriMatcher.java    From material-activity-chooser with Apache License 2.0 4 votes vote down vote up
@Override
public void describeTo(Description description) {
    description.appendDescriptionOf(mStringUriMatcher);
}