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
Modifier and TypeMethodDescriptionintcompareTo(com.atlassian.crowd.embedded.api.User other) booleanlonggetKeys()getName()inthashCode()booleanisActive()AMockUseris always active by default.booleanisEmpty()booleansetActive(boolean active) voidsetDirectoryId(long id) voidsetIsMarkedAsDeleted(boolean isMarkedAsDeleted) toString()
-
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()AMockUseris always active by default.- Specified by:
isActivein interfacecom.atlassian.crowd.embedded.api.User
-
setActive
-
getEmailAddress
- Specified by:
getEmailAddressin interfacecom.atlassian.crowd.embedded.api.User
-
getDisplayName
- Specified by:
getDisplayNamein interfacecom.atlassian.crowd.embedded.api.User
-
setDirectoryId
public void setDirectoryId(long id) -
getDirectoryId
public long getDirectoryId()- Specified by:
getDirectoryIdin interfacecom.atlassian.crowd.embedded.api.User
-
getName
-
setIsMarkedAsDeleted
public void setIsMarkedAsDeleted(boolean isMarkedAsDeleted) -
isMarkedAsDeleted
public boolean isMarkedAsDeleted()- Specified by:
isMarkedAsDeletedin interfacecom.atlassian.crowd.embedded.api.User
-
toString
-
getValues
- Specified by:
getValuesin interfacecom.atlassian.crowd.embedded.api.Attributes
-
getValue
- Specified by:
getValuein interfacecom.atlassian.crowd.embedded.api.Attributes
-
getKeys
- Specified by:
getKeysin interfacecom.atlassian.crowd.embedded.api.Attributes
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacecom.atlassian.crowd.embedded.api.Attributes
-
equals
-
hashCode
public int hashCode() -
compareTo
public int compareTo(com.atlassian.crowd.embedded.api.User other) - Specified by:
compareToin interfaceComparable<com.atlassian.crowd.embedded.api.User>- Specified by:
compareToin interfacecom.atlassian.crowd.embedded.api.User
-