Package com.atlassian.jira.user
Class MockUser
java.lang.Object
com.atlassian.jira.user.MockUser
- All Implemented Interfaces:
com.atlassian.crowd.embedded.api.Attributes
,com.atlassian.crowd.embedded.api.User
,com.atlassian.crowd.embedded.api.UserWithAttributes
,Serializable
,Comparable<com.atlassian.crowd.embedded.api.User>
,Principal
public class MockUser
extends Object
implements com.atlassian.crowd.embedded.api.UserWithAttributes, Serializable
A convenient mock for
User
that supplies reasonable behaviour for unit tests.
Note that creating a MockUser
does not automatically ensure that it can be
resolved by the UserManager
or UserKeyService
, so unit tests may need
to provide mocks for one or both of those services as well.- Since:
- v4.3
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConvenience constructor that is equivalent toMockUser(username, "", null, null)
.Convenience constructor that is equivalent toMockUser(username, "", null, directoryId)
.Convenience constructor that is equivalent toMockUser(username, fullName, email, null)
.Creates a new mock user with the specified information. -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.atlassian.crowd.embedded.api.User
isMarkedAsDeleted
-
Field Details
-
MOCK_DIRECTORY_ID
public static final long MOCK_DIRECTORY_ID- See Also:
-
-
Constructor Details
-
MockUser
Convenience constructor that is equivalent toMockUser(username, "", null, null)
. -
MockUser
Convenience constructor that is equivalent toMockUser(username, "", null, directoryId)
.- Parameters:
directoryId
- : -1L represents that this is a fake user.
-
MockUser
Convenience constructor that is equivalent toMockUser(username, fullName, email, null)
. -
MockUser
-
MockUser
Creates a new mock user with the specified information.- Parameters:
username
- the value to be returned forgetName()
fullName
- the value to be returned forgetDisplayName()
email
- the value to be returned forgetEmailAddress()
values
- a map to provide user attributes, such as are returned bygetKeys()
andgetValues(String)
. May benull
, in which case an empty map is used.
-
-
Method Details
-
isActive
public boolean isActive()AMockUser
is always active by default.- Specified by:
isActive
in interfacecom.atlassian.crowd.embedded.api.User
-
setActive
-
getEmailAddress
- Specified by:
getEmailAddress
in interfacecom.atlassian.crowd.embedded.api.User
-
getDisplayName
- Specified by:
getDisplayName
in interfacecom.atlassian.crowd.embedded.api.User
-
setDirectoryId
public void setDirectoryId(long id) -
getDirectoryId
public long getDirectoryId()- Specified by:
getDirectoryId
in interfacecom.atlassian.crowd.embedded.api.User
-
getName
-
toString
-
getValues
- Specified by:
getValues
in interfacecom.atlassian.crowd.embedded.api.Attributes
-
getValue
- Specified by:
getValue
in interfacecom.atlassian.crowd.embedded.api.Attributes
-
getKeys
- Specified by:
getKeys
in interfacecom.atlassian.crowd.embedded.api.Attributes
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfacecom.atlassian.crowd.embedded.api.Attributes
-
equals
-
hashCode
public int hashCode() -
compareTo
public int compareTo(com.atlassian.crowd.embedded.api.User other) - Specified by:
compareTo
in interfaceComparable<com.atlassian.crowd.embedded.api.User>
- Specified by:
compareTo
in interfacecom.atlassian.crowd.embedded.api.User
-