com.atlassian.crowd.test.matchers
Class UserMatcher<E extends User>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeMatcher<E>
          extended by 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
UserMatcher(org.hamcrest.Matcher<String> nameMatcher, org.hamcrest.Matcher<Boolean> activeMatcher, org.hamcrest.Matcher<String> externalIdMatcher)
           
 
Method Summary
 void describeTo(org.hamcrest.Description description)
           
protected  boolean matchesSafely(E item)
           
static
<T extends User>
UserMatcher<T>
user()
          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>
userNamed(String name)
          A matcher that matches a user with the given name.
 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.
 UserMatcher<E> withExternalIdMatching(org.hamcrest.Matcher<String> externalIdMatcher)
          Builds a new specialised matcher to match on the externalId.
 UserMatcher<E> withExternalIdOf(String externalId)
          Builds a new specialised matcher to match the given externalId.
 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.
 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.
 
Methods inherited from class org.hamcrest.TypeSafeMatcher
matches
 
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserMatcher

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

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)


Copyright © 2013 Atlassian. All Rights Reserved.