Package org.hamcrest

Examples of org.hamcrest.StringDescription


@SuppressWarnings("unchecked")
public class MatchersPrinter {
   
    public String getArgumentsLine(List<Matcher> matchers, PrintSettings printSettings) {
        Description result = new StringDescription();
        result.appendList("(", ", ", ");", applyPrintSettings(matchers, printSettings));
        return result.toString();
    }
View Full Code Here


        result.appendList("(", ", ", ");", applyPrintSettings(matchers, printSettings));
        return result.toString();
    }

    public String getArgumentsBlock(List<Matcher> matchers, PrintSettings printSettings) {
        Description result = new StringDescription();
        result.appendList("(\n    ", ",\n    ", "\n);", applyPrintSettings(matchers, printSettings));
        return result.toString();
    }
View Full Code Here

    public static void assertThat(Condition condition) {
        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

    public PollTimeoutException(Condition condition) {
        super(explainTimeoutOf(condition));
    }

    private static String explainTimeoutOf(Condition condition) {
        Description description = new StringDescription();
        description.appendText("Timed out waiting until ");
        condition.describeTo(description);
        description.appendText("\n   because ");
        condition.describeDissatisfactionTo(description);
        return description.toString();
    }
View Full Code Here

    /**
     * The reason the condition was dissatisfied.
     */
    public String reason() {
        Description description = new StringDescription();
        condition.describeDissatisfactionTo(description);
        return description.toString();
    }
View Full Code Here

  public void testMatchesPropertyAndValue() {
    assertMatches("property with value", hasProperty( "property", anything()), beanWithInfo);
  }
 
  public void testDoesNotWriteMismatchIfPropertyMatches() {
    Description description = new StringDescription();
    hasProperty( "property", anything()).describeMismatch(beanWithInfo, description);
    assertEquals("Expected mismatch description", "", description.toString());
  }
View Full Code Here

        String listenersText = text.replaceAll("time=-?\\d+", "time=SOME_TIME_AGO").replaceAll("x=\\d+", "x=X_CO_ORDINATE").replaceAll("y=\\d+", "y=Y_CO_ORDINATE").replaceAll("keyLocation=\\d+ ", "");
        return matcher.matches(listenersText);
      }

      public String getFailureMessage() {
        Description description = new StringDescription();
        description.appendText("\nExpected:\n").appendDescriptionOf(matcher).appendText("\ngot:\n").appendValue(text).appendText("\n");
        return description.toString();
      }
    });
  }
View Full Code Here

        }
        return this;
    }

    private StringDescription descriptionOf(Matcher<?> matcher) {
        StringDescription description = new StringDescription();
        matcher.describeTo(description);
        return description;
    }
View Full Code Here

    @Override
    public ResultValidator expectReturnValue(Matcher<?> matcher) {
        if (matcher == null) {
            return expectReturnValue(nullValue());
        }
        StringDescription description = new StringDescription();
        matcher.describeTo(description);
        if (actualException != null) {
            reporter.reportUnexpectedException(actualException, description);
        } else if (!matcher.matches(actualReturnValue)) {
            reporter.reportWrongResult(actualReturnValue, description);
View Full Code Here

        return expectException(instanceOf(expectedException));
    }

    @Override
    public ResultValidator expectException(Matcher<?> matcher) {
        StringDescription description = new StringDescription();
        matcher.describeTo(description);
        if (actualException == null) {
            reporter.reportUnexpectedReturnValue(actualReturnValue, description);
        }
        if (!matcher.matches(actualException)) {
View Full Code Here

TOP

Related Classes of org.hamcrest.StringDescription

Copyright © 2018 www.massapicom. 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.