Пример #1
0
  @Factory
  public static Matcher<String> endsWithStripNewLines(final String expected) {
    final String strippedExpected = StringExtensions.stripNewLines(expected);
    return new StringEndsWith(strippedExpected) {
      @Override
      public boolean matchesSafely(final String actual) {
        return super.matchesSafely(StringExtensions.stripNewLines(actual));
      }

      @Override
      public void describeTo(final Description description) {
        description
            .appendText("a string (ignoring new lines) ending with")
            .appendValue(strippedExpected);
      }
    };
  }
Пример #2
0
  @Factory
  public static Matcher<String> equalToStripNewLines(final String expected) {
    final String strippedExpected = StringExtensions.stripNewLines(expected);
    return new IsEqual<String>(strippedExpected) {
      @Override
      public boolean matches(final Object actualObj) {
        final String actual = (String) actualObj;
        return super.matches(StringExtensions.stripNewLines(actual));
      }

      @Override
      public void describeTo(final Description description) {
        description
            .appendText("a string (ignoring new lines) equal to")
            .appendValue(strippedExpected);
      }
    };
  }