Class StringEndsWith

All Implemented Interfaces:
Matcher<String>, SelfDescribing

public class StringEndsWith extends SubstringMatcher
Tests if the argument is a string that ends with a specific substring.
  • Constructor Details

    • StringEndsWith

      public StringEndsWith(String suffix)
      Constructor, best used with endsWith(String).
      Parameters:
      suffix - the expected end of the string.
    • StringEndsWith

      public StringEndsWith(boolean ignoringCase, String suffix)
      Constructor, best used with endsWith(String) or endsWithIgnoringCase(String).
      Parameters:
      ignoringCase - whether to ignore case when matching
      suffix - the expected end of the string.
  • Method Details

    • evalSubstringOf

      protected boolean evalSubstringOf(String s)
      Description copied from class: SubstringMatcher
      Checks if the input matches the specific substring.
      Specified by:
      evalSubstringOf in class SubstringMatcher
      Parameters:
      s - the string to check
      Returns:
      the result of the match
    • endsWith

      public static Matcher<String> endsWith(String suffix)
      Creates a matcher that matches if the examined String ends with the specified String. For example:
      assertThat("myStringOfNote", endsWith("Note"))
      Parameters:
      suffix - the substring that the returned matcher will expect at the end of any examined string
      Returns:
      The matcher.
    • endsWithIgnoringCase

      public static Matcher<String> endsWithIgnoringCase(String suffix)
      Creates a matcher that matches if the examined String ends with the specified String, ignoring case. For example:
      assertThat("myStringOfNote", endsWithIgnoringCase("note"))
      Parameters:
      suffix - the substring that the returned matcher will expect at the end of any examined string
      Returns:
      The matcher.