Class UserMatcher<E extends User>

java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<E>
com.atlassian.crowd.test.matchers.UserMatcher<E>
All Implemented Interfaces:
org.hamcrest.Matcher<E>, org.hamcrest.SelfDescribing

public class UserMatcher<E extends User> extends org.hamcrest.TypeSafeMatcher<E>
  • Constructor Summary

    Constructors
    Constructor
    Description
    UserMatcher(org.hamcrest.Matcher<String> nameMatcher, org.hamcrest.Matcher<Boolean> activeMatcher, org.hamcrest.Matcher<String> externalIdMatcher)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    describeTo(org.hamcrest.Description description)
     
    protected boolean
     
    static <T extends User>
    UserMatcher<T>
    A matcher that matches any user.
    static <T extends User>
    UserMatcher<T>
    user(Class<T> type)
    A matcher that matches any user; synonymous with user() but its argument is used to set the matcher type.
    static <T extends User>
    UserMatcher<T>
    A matcher that matches a user with the given name.
    withActive(boolean active)
    Builds a new specialised matcher to match the given active status; the returned matcher will only match if all this matcher's non-username constraints are matched AND the given status is equal to the user's active status.
    withExternalIdMatching(org.hamcrest.Matcher<String> externalIdMatcher)
    Builds a new specialised matcher to match on the externalId.
    Builds a new specialised matcher to match the given externalId.
    withNameMatching(org.hamcrest.Matcher<String> nameMatcher)
    Builds a new specialised matcher to match on username; the returned matcher will only match if all this matcher's non-username constraints are matched AND the given matcher matches the user's username.
    Builds a new specialised matcher to match the given username exactly; the returned matcher will only match if all this matcher's non-username constraints are matched AND the given string is equal to the user's username.

    Methods inherited from class org.hamcrest.TypeSafeMatcher

    describeMismatch, describeMismatchSafely, matches

    Methods inherited from class org.hamcrest.BaseMatcher

    _dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UserMatcher

      public UserMatcher(@Nullable org.hamcrest.Matcher<String> nameMatcher, @Nullable org.hamcrest.Matcher<Boolean> activeMatcher, @Nullable org.hamcrest.Matcher<String> externalIdMatcher)
  • Method Details

    • user

      public static <T extends User> UserMatcher<T> user()
      A matcher that matches any user.
      Type Parameters:
      T - type of user, to avoid casting
      Returns:
      a matcher which matches any user
    • user

      public static <T extends User> UserMatcher<T> user(Class<T> type)
      A matcher that matches any user; synonymous with user() but its argument is used to set the matcher type.
      Type Parameters:
      T - type of user, to avoid casting
      Parameters:
      type - type of user, to avoid casting (this type is not checked at runtime).
      Returns:
      a matcher which matches any user
    • userNamed

      public static <T extends User> UserMatcher<T> userNamed(String name)
      A matcher that matches a user with the given name.
      Type Parameters:
      T - type of user, to avoid casting
      Returns:
      a matcher which matches a user with the given name.
    • withNameMatching

      public UserMatcher<E> withNameMatching(org.hamcrest.Matcher<String> nameMatcher)
      Builds a new specialised matcher to match on username; the returned matcher will only match if all this matcher's non-username constraints are matched AND the given matcher matches the user's username. Any existing username constraint is discarded.
      Parameters:
      nameMatcher - matcher which must match the user's username in order for this matcher to match
      Returns:
      a matcher will only match if all this matcher's non-username constraints are matched AND the given matcher matches the user's username
    • withNameOf

      public UserMatcher<E> withNameOf(String name)
      Builds a new specialised matcher to match the given username exactly; the returned matcher will only match if all this matcher's non-username constraints are matched AND the given string is equal to the user's username. Any existing username constraint is discarded.
      Parameters:
      name - string which must equal the user's username in order for this matcher to match
      Returns:
      a matcher will only match if all this matcher's non-username constraints are matched AND the given string is equal to the user's username
    • withActive

      public UserMatcher<E> withActive(boolean active)
      Builds a new specialised matcher to match the given active status; the returned matcher will only match if all this matcher's non-username constraints are matched AND the given status is equal to the user's active status.
      Parameters:
      active - the status must equal the user's status (as per User.isActive()) in order for this matcher to match
      Returns:
      a matcher will only match if all this matcher's non-active-status constraints are matched AND the given status is equal to the user's active status
    • withExternalIdMatching

      public UserMatcher<E> withExternalIdMatching(org.hamcrest.Matcher<String> externalIdMatcher)
      Builds a new specialised matcher to match on the externalId.
      Parameters:
      externalIdMatcher - matcher which must match the user's externalId (as per User.getExternalId() ()}) in order for this matcher to match
      Returns:
      a matcher
    • withExternalIdOf

      public UserMatcher<E> withExternalIdOf(String externalId)
      Builds a new specialised matcher to match the given externalId.
      Parameters:
      externalId - the provided externalId must equal the user's externalId (as per User.getExternalId() ()}) in order for this matcher to match
      Returns:
      a matcher
    • matchesSafely

      protected boolean matchesSafely(E item)
      Specified by:
      matchesSafely in class org.hamcrest.TypeSafeMatcher<E extends User>
    • describeTo

      public void describeTo(org.hamcrest.Description description)