Package org.hamcrest

Examples of org.hamcrest.StringDescription.appendText()


   */
  public static <T> void assertThat(String reason, T actual, Matcher<T> matcher) {
    if (!matcher.matches(actual)) {
      Description description = new StringDescription();
      description.appendText(reason);
      description.appendText("\nExpected: ");
      description.appendDescriptionOf(matcher);
      if (describeMismatchMethod != null) {
        description.appendText("\n     but: ");
        // matcher.describeMismatch(actual, description);
        ReflectionUtils.invokeMethod(describeMismatchMethod, matcher, actual, description);
View Full Code Here


      Description description = new StringDescription();
      description.appendText(reason);
      description.appendText("\nExpected: ");
      description.appendDescriptionOf(matcher);
      if (describeMismatchMethod != null) {
        description.appendText("\n     but: ");
        // matcher.describeMismatch(actual, description);
        ReflectionUtils.invokeMethod(describeMismatchMethod, matcher, actual, description);
      }
      else {
        description.appendText("\n     got: ");
View Full Code Here

        description.appendText("\n     but: ");
        // matcher.describeMismatch(actual, description);
        ReflectionUtils.invokeMethod(describeMismatchMethod, matcher, actual, description);
      }
      else {
        description.appendText("\n     got: ");
        description.appendValue(actual);
        description.appendText("\n");
      }
      throw new AssertionError(description.toString());
    }
View Full Code Here

        ReflectionUtils.invokeMethod(describeMismatchMethod, matcher, actual, description);
      }
      else {
        description.appendText("\n     got: ");
        description.appendValue(actual);
        description.appendText("\n");
      }
      throw new AssertionError(description.toString());
    }
  }
View Full Code Here

     * @throws AssertionError if the condition is not satisfied
     */
    public static void assertThat(Condition condition) {
        if(condition.isSatisfied()) return;
        Description description = new StringDescription();
        description.appendText("\nExpected: ")
                    .appendDescriptionOf(condition)
                    .appendText("\n     but: ");
        condition.describeDissatisfactionTo(description);
        throw new AssertionError(description.toString());
    }
View Full Code Here

  @Override
  public boolean isSatisfied(Description mismatchDescription) {
    StringBuilder sb = new StringBuilder();
    StringDescription description = new StringDescription(sb);
    description.appendText(serverName + ":<" + getPort() + ">:\n");
   
    boolean allSatisfied = true;
   
    for (Expectation expectation : expectations) {
      allSatisfied &= isExpectationSatisfied(expectation, description);
View Full Code Here

  private final String msg;

  @Override
  public void is(Matcher<? super T> matching) {
    Description message = new StringDescription();
    message.appendText("expecting ");
    matching.describeTo(message);
    message.appendText(" but ");
    T obj = provider.get();
    if (!matching.matches(obj)) {
      matching.describeMismatch(obj, message);
View Full Code Here

  @Override
  public void is(Matcher<? super T> matching) {
    Description message = new StringDescription();
    message.appendText("expecting ");
    matching.describeTo(message);
    message.appendText(" but ");
    T obj = provider.get();
    if (!matching.matches(obj)) {
      matching.describeMismatch(obj, message);
      if (assertion) {
        throw new AssertionError((msg == null ? "" : msg + "\n")
View Full Code Here

        if(!condition.isSatisfied()) fail(condition);
    }

    private static void fail(Condition condition) {
        Description description = new StringDescription();
        description.appendText("Expected: ");
        condition.describeTo(description);
        description.appendText("\n  but: ");
        condition.describeDissatisfactionTo(description);
        throw new AssertionError(description.toString());
    }
View Full Code Here

    private static void fail(Condition condition) {
        Description description = new StringDescription();
        description.appendText("Expected: ");
        condition.describeTo(description);
        description.appendText("\n  but: ");
        condition.describeDissatisfactionTo(description);
        throw new AssertionError(description.toString());
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.