public class UserMatcher<E extends User>
extends org.hamcrest.TypeSafeMatcher<E>
Constructor and Description |
---|
UserMatcher(org.hamcrest.Matcher<String> nameMatcher,
org.hamcrest.Matcher<Boolean> activeMatcher,
org.hamcrest.Matcher<String> externalIdMatcher) |
Modifier and Type | Method and Description |
---|---|
void |
describeTo(org.hamcrest.Description description) |
protected boolean |
matchesSafely(E item) |
static <T extends User> |
user()
A matcher that matches any user.
|
static <T extends User> |
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> |
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.
|
describeMismatch, describeMismatchSafely, matches
public static <T extends User> UserMatcher<T> user()
T
- type of user, to avoid castingpublic static <T extends User> UserMatcher<T> user(Class<T> type)
user()
but its argument is used to set the matcher type.T
- type of user, to avoid castingtype
- type of user, to avoid casting (this type is not checked at runtime).public static <T extends User> UserMatcher<T> userNamed(String name)
T
- type of user, to avoid castingpublic UserMatcher<E> withNameMatching(org.hamcrest.Matcher<String> nameMatcher)
nameMatcher
- matcher which must match the user's username in order for this matcher to matchpublic UserMatcher<E> withNameOf(String name)
name
- string which must equal the user's username in order for this matcher to matchpublic UserMatcher<E> withActive(boolean active)
active
- the status must equal the user's status (as per
User.isActive()
) in order for this matcher to matchpublic UserMatcher<E> withExternalIdMatching(org.hamcrest.Matcher<String> externalIdMatcher)
externalIdMatcher
- matcher which must match the user's externalId (as per
User.getExternalId()
()}) in order for this matcher to matchpublic UserMatcher<E> withExternalIdOf(String externalId)
externalId
- the provided externalId must equal the user's externalId (as per
User.getExternalId()
()}) in order for this matcher to matchprotected boolean matchesSafely(E item)
public void describeTo(org.hamcrest.Description description)
Copyright © 2020 Atlassian. All rights reserved.