public class MockUser extends Object implements com.atlassian.crowd.embedded.api.UserWithAttributes, Serializable
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.| Modifier and Type | Field and Description | 
|---|---|
| static long | MOCK_DIRECTORY_ID | 
| Constructor and Description | 
|---|
| MockUser(String username)Convenience constructor that is equivalent to
  MockUser(username, "", null, null). | 
| MockUser(String username,
        long directoryId)Convenience constructor that is equivalent to
  MockUser(username, "", null, directoryId). | 
| MockUser(String username,
        String fullName,
        String email)Convenience constructor that is equivalent to
  MockUser(username, fullName, email, null). | 
| MockUser(String username,
        String fullName,
        String email,
        long directoryId) | 
| MockUser(String username,
        String fullName,
        String email,
        Map<String,Set<String>> values)Creates a new mock user with the specified information. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | compareTo(com.atlassian.crowd.embedded.api.User other) | 
| boolean | equals(Object o) | 
| long | getDirectoryId() | 
| String | getDisplayName() | 
| String | getEmailAddress() | 
| Set<String> | getKeys() | 
| String | getName() | 
| String | getValue(String key) | 
| Set<String> | getValues(String key) | 
| int | hashCode() | 
| boolean | isActive()A  MockUseris always active by default. | 
| boolean | isEmpty() | 
| MockUser | setActive(boolean active) | 
| void | setDirectoryId(long id) | 
| String | toString() | 
public static final long MOCK_DIRECTORY_ID
public MockUser(String username)
MockUser(username, "", null, null).public MockUser(String username, long directoryId)
MockUser(username, "", null, directoryId).directoryId: - -1L represents that this is a fake user.public MockUser(String username, String fullName, String email)
MockUser(username, fullName, email, null).public MockUser(String username, String fullName, String email, Map<String,Set<String>> values)
username - the value to be returned for getName()fullName - the value to be returned for getDisplayName()email - the value to be returned for getEmailAddress()values - a map to provide user attributes, such as are returned
                 by getKeys() and getValues(String).  May be
                 null, in which case an empty map is used.public boolean isActive()
MockUser is always active by default.isActive in interface com.atlassian.crowd.embedded.api.Userpublic MockUser setActive(boolean active)
public String getEmailAddress()
getEmailAddress in interface com.atlassian.crowd.embedded.api.Userpublic String getDisplayName()
getDisplayName in interface com.atlassian.crowd.embedded.api.Userpublic void setDirectoryId(long id)
public long getDirectoryId()
getDirectoryId in interface com.atlassian.crowd.embedded.api.Userpublic String toString()
public Set<String> getValues(String key)
getValues in interface com.atlassian.crowd.embedded.api.Attributespublic String getValue(String key)
getValue in interface com.atlassian.crowd.embedded.api.Attributespublic Set<String> getKeys()
getKeys in interface com.atlassian.crowd.embedded.api.Attributespublic boolean isEmpty()
isEmpty in interface com.atlassian.crowd.embedded.api.Attributespublic boolean equals(Object o)
public int hashCode()
public int compareTo(com.atlassian.crowd.embedded.api.User other)
compareTo in interface com.atlassian.crowd.embedded.api.UsercompareTo in interface Comparable<com.atlassian.crowd.embedded.api.User>Copyright © 2002-2021 Atlassian. All Rights Reserved.