I wish to make my own ' user ' entity to log in the application.
what I want to know is that if it's possible and if it is possible then where should I take precaution, which points should I consider and which files I would need to modify?
You need create a userclass by implementing UserDetailsService like
#Transactional
#Override
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {
MyUser details = userDao.getUser(username);
Collection<simplegrantedauthority> authorities = new ArrayList<simplegrantedauthority>();
SimpleGrantedAuthority userAuthority = new SimpleGrantedAuthority(
"ROLE_USER");
SimpleGrantedAuthority adminAuthority = new SimpleGrantedAuthority(
"ROLE_ADMIN");
if (details.getRole().equals("user"))
authorities.add(userAuthority);
else if (details.getRole().equals("admin")) {
authorities.add(userAuthority);
authorities.add(adminAuthority);
}
UserDetails user = new User(details.getUsername(),
details.getPassword(), true, true, true, true, authorities);
return user;
}
}
an then configure spring to use your customuser object... like
<authentication-manager>
<authentication-provider user-service-ref="authService">
</authentication-provider>
</authentication-manager>
Full example can be found at Spring Custom User with DAO and Entity
You could create a user service extending UserDetailsService, and then create your UserDetail object.
It would be similar to this.
Create you User class:
public class MyUserDetails implements UserDetails {
private UserEntity user;
private List<GrantedAuthority> authorities;
/**
* Constructor
*/
public MyUserDetails(UserEntity user) {
this.user = user;
this.authorities = Arrays.asList(new SimpleGrantedAuthority(user.getRole().name()));
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#getAuthorities()
*/
#Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#getPassword()
*/
#Override
public String getPassword() {
return user.getPassword();
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#getUsername()
*/
#Override
public String getUsername() {
return user.getEmail();
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#isAccountNonExpired()
*/
#Override
public boolean isAccountNonExpired() {
return true;
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#isAccountNonLocked()
*/
#Override
public boolean isAccountNonLocked() {
return !user.isLocked();
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#isCredentialsNonExpired()
*/
#Override
public boolean isCredentialsNonExpired() {
return !user.isExpired();
}
/* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetails#isEnabled()
*/
#Override
public boolean isEnabled() {
return user.isEnabled();
}
/**
* #return the user
*/
public UserEntity getUser() {
return user;
}
/**
* #param user the user to set
*/
public void setUser(UserEntity user) {
this.user = user;
}
}
Then you should create your UserDetailsService:
#Service
public class MyUserDetailsService implements UserDetailsService {
#Autowired
private UserRepository userRepo;
/*
* (non-Javadoc)
* #see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
*/
#Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserEntity user = userDao.findByEmail(username);
if (user == null) {
LOGGER.warn("User {} does not exist in our database", username);
throw new UsernameNotFoundException("User not found.");
}
return new MyUserDetails(user);
}
}
And finally you should add the configuration for Spring security to use your service:
#Configuration
#EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
private MyUserDetailsService userDetailsService;
#Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(new Md5PasswordEncoder());
}
}
Related
Am new to Springboot, I have develop the resource to delete the record by ID, now I like delete selected multiple records.
Example: I like to delete 3 records out of 10 records in single request
Controller class:
#ApiHeader(
apiOperation = "delete a Content Manage by id",
apiOperationNotes = "delete a Content Manage by id"
)
#PostMapping(value = UriConstants.CONTENT_MANAGE_DELETE)
#ResponseStatus(HttpStatus.OK)
public void deleteContentManage(#PathVariable("content_manage_id") int contentmanageId) {
contentManageService.deleteContentManage(contentmanageId);
}
Service Class:
#Transactional(rollbackFor = Exception.class)
public void deleteContentManage(int contentmanageId) {
Optional<UserContentManage> optional = userContentManageRepository.findById(contentmanageId);
if(!optional.isPresent()){
log.error("Exception occurs while not found content manage ({}) in deletion. ", contentmanageId);
throw new GenericBadException(StaffNotificationExceptionEnum.CONTENT_MANAGE_NOT_FOUND_EXCEPTION);
}
userContentManageRepository.deleteById(contentmanageId);
}
JPA Class:
public interface UserContentManageRepository extends JpaRepository<UserContentManage, Integer> {
}
please suggest me how do I delete selected multiple records.
You can add method in Repository like
#Modifying
#Transactional
#Query("delete from UserContentManagep where u.id in(:integers)")
void deleteByIdIn(List<Integer> integers);
If you have implemented soft delete in project you can do soft delete like below:
#Modifying
#Transactional
#Query("update UserContentManagep u set u.active = false where u.id in(:integers)")
void softDeleteAllIds(List<Integer> integers);
And from service class you can try to call as
public void deleteAllBYIds(List<Integer> integers) {
personRepository.deleteByIdIn(integers);
}
Fully working example:
#RestController
#RequestMapping("/person")
public class PersonController {
private final PersonService personService;
#Autowired
public PersonController(PersonService personService) {
this.personService = personService;
}
#GetMapping
public Iterable<Person> list() {
return personService.list();
}
#PostMapping
public Person create(#RequestBody Person car) {
return personService.save(car);
}
#DeleteMapping
public String delete(#RequestParam("ids") List<Integer> ids) {
System.out.println("deleting");
personService.deleteAllBYIds(ids);
return String.join(",", ids.stream().map(value -> Integer.toString(value)).collect(Collectors.toList()));
}
}
#Getter
#Setter
#ToString
#Entity
#Where(clause = "active = true") // selecting only items which are active
class Person {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private boolean active = true;
}
#Service
class PersonService {
private final PersonRepository personRepository;
#Autowired
PersonService(PersonRepository personRepository) {
this.personRepository = personRepository;
}
#Transactional
public Person save(Person person) {
return personRepository.save(person);
}
#Transactional(readOnly = true)
public Iterable<Person> list() {
return personRepository.findAll();
}
#Transactional(readOnly = true)
public PersonDTO findPersonByName(String name) {
return personRepository.findPersonsByName(name);
}
public void deleteAllBYIds(List<Integer> integers) {
// personRepository.deleteByIdIn(new ArrayList<>(integers));
personRepository.softDeleteAllIds(integers);
System.out.println("deleted adnlakdjakldlas");
}
}
interface PersonDTO {
String getName();
Collection<String> getPersonEvents();
}
#Repository
interface PersonRepository extends CrudRepository<Person, Integer> {
PersonDTO findPersonsByName(String name);
#Modifying
#Transactional
#Query("delete from Person p where p.id in(:integers)")
void deleteByIdIn(List<Integer> integers);
#Modifying
#Transactional
#Query("update Person p set p.active = false where p.id in(:integers)")
void softDeleteAllIds(List<Integer> integers);
}
First of all you need to create a jpa query method that brings all records belong to id.
public interface UserContentManageRepository extends JpaRepository<UserContentManage, Integer> {
List<UserContentManage> findAllById(Integer id);
}
After that you can do deleteAll() operation on List.
#Transactional(rollbackFor = Exception.class)
public void deleteContentManage(int contentmanageId) {
List<UserContentManage> userContentManageList = userContentManageRepository.findAllById(contentmanageId);
if(userContentManageList == null){
log.error("Exception occurs while not found content manage ({}) in deletion. ");
throw new GenericBadException(StaffNotificationExceptionEnum.CONTENT_MANAGE_NOT_FOUND_EXCEPTION);
}
userContentManageRepository.deleteAll(userContentManageList );
}
I have added Hibernate filters on my entities . These filters are applied on queries which fetch Collection of entity but not applied on queries which fetch single entity. Below is my code.
AOrganization.java
#MappedSuperclass
#FilterDef(name = "OrgFilter", parameters = { #ParamDef(name = "allowedOrgIdList", type = "long") })
#Filter(name = "OrgFilter", condition = "org_id in (:allowedOrgIdList)")
public class AOrganization implements Serializable {
#ManyToOne()
#JoinColumn(name = "org_id", nullable = true)
private Organization organization;
public Organization getOrganization() {
return organization;
}
public void setOrganization(Organization organization) {
this.organization = organization;
}
}
Site.java
#Data
#Entity
#Table(name = "site")
public class Site extends AOrganization{
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "id")
private long id;
#Column(name = "site_name")
private String siteName;
#Override
public String toString() {
return "Site [id=" + id + ", siteName=" + siteName + "]";
}
}
SiteService.java
public interface SiteService {
public List<Site> getAllSites();
public List<Site> getSiteBySiteName(String siteName);
public Site updateSiteName(Long id, String siteName);
}
SiteRepository.java
#Repository
public interface SiteRepository extends AOrganizationRepository<Site, Long> {
public List<Site> findBySiteName(String siteName);
public List<Site> findByOrganization_Id(Long orgId);
}
AOrganizationRepository.java
#NoRepositoryBean
public interface AOrganizationRepository<T, ID extends java.io.Serializable> extends CrudRepository<T, ID> {
}
SiteServiceImpl.java
#Service
public class SiteServiceImpl implements SiteService {
#Autowired
private EntityManager entityManager;
#Autowired
private SiteRepository siteRepository;
#Override
public List<Site> getAllSites() {
Iterable<Site> sites = siteRepository.findAll();
List<Site> allSites = new ArrayList<>();
sites.forEach(allSites::add);
return allSites;
}
#Override
public List<Site> getSiteBySiteName(String siteName) {
List<Site> allSites = siteRepository.findBySiteName(siteName);
return allSites;
}
#Override
public Site updateSiteName(Long id,String siteName) {
Site site = siteRepository.findById(id).get();
if(site == null)
return null;
site.setSiteName(siteName);
siteRepository.save(site);
return site;
}
}
AOrganizationAspect.java
#Aspect
#Component
#Slf4j
public class AOrganizationAspect {
#PersistenceContext
private EntityManager entityManager;
#Pointcut("execution(public * com.harshal.springboot.springfilter.repository.AOrganizationRepository+.*(..))")
protected void aOrganizationRepositoryRepositoryMethod() {
log.info("aOrganizationRepositoryRepositoryMethod");
}
#Around(value = "aOrganizationRepositoryRepositoryMethod()")
public Object enableOwnerFilter(ProceedingJoinPoint joinPoint) throws Throwable {
// Variable holding the session
Session session = null;
try {
// Get the Session from the entityManager in current persistence context
session = entityManager.unwrap(Session.class);
// Enable the filter
Filter filter = session.enableFilter("OrgFilter");
// Set the parameter from the session
List<Long> orgList = getAllowedOrgIdList();
filter.setParameterList("allowedOrgIdList", orgList);
} catch (Exception ex) {
// Log the error
log.error("Error enabling OrgFilter : Reason -" + ex.getMessage());
}
// Proceed with the joint point
Object obj = joinPoint.proceed();
// If session was available
if (session != null) {
// Disable the filter
session.disableFilter("OrgFilter");
}
// Return
return obj;
}
private List<Long> getAllowedOrgIdList() {
return Arrays.asList(2l);
}
}
So , hibernate filters are applied if method getSiteBySiteName is called and filters are not applied if findById method is called.
Below are queries :
For getSiteBySiteName :
select site0_.id as id1_2_, site0_.org_id as org_id3_2_,
site0_.site_name as site_nam2_2_ from site site0_ where site0_.org_id
in (?) and site0_.site_name=?
Please help . Thanks in advance.
For findById
select site0_.id as id1_2_0_, site0_.org_id as org_id3_2_0_,
site0_.site_name as site_nam2_2_0_, organizati1_.id as id1_1_1_,
organizati1_.address as address2_1_1_, organizati1_.org_name as
org_name3_1_1_ from site site0_ left outer join organization
organizati1_ on site0_.org_id=organizati1_.id where site0_.id=?
findById is using the EntityManager.find method and do not create a query.
Plus Hibernate Filters only work on queries.
You should write a query instead of using findById
I am trying to implement a basic chat application with Spring boot & Stomp Protocol. I am not able to send message to specific user via SimpMessagingTemplate.convertAndSendToUser
All of my messages are pushed to all connected sockets.
my controller:
#Controller
public class MessageController {
private final SimpMessagingTemplate simpMessagingTemplate;
/**
* Constructor for object
*
* #param simpMessagingTemplate
*/
public MessageController(final SimpMessagingTemplate simpMessagingTemplate) {
this.simpMessagingTemplate = simpMessagingTemplate;
}
/**
* Responsible for sharing message through web socket.s
*
* #param message
* to share with audience.
* #return
*/
#MessageMapping("/message")
#SendTo("/topic/message")
public Message send(Message message) {
String time = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
message.setTime(time);
simpMessagingTemplate.convertAndSendToUser(message.getTo(), "/topic/message", message);
return message;
}
}
web socket configuration:
#EnableWebSocketMessageBroker
#Configuration
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
private static final int MESSAGE_BUFFER_SIZE = 8192;
private static final long SECOND_IN_MILLIS = 1000L;
private static final long HOUR_IN_MILLIS = SECOND_IN_MILLIS * 60 * 60;
/*
* (non-Javadoc)
*
* #see org.springframework.web.socket.config.annotation.
* AbstractWebSocketMessageBrokerConfigurer#configureMessageBroker(org.
* springframework.messaging.simp.config.MessageBrokerRegistry)
*/
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
// simple broker is applicable for first setup.
// To scale application enableStompBrokerRelay has to be configured.
// documentation :
// https://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-handle-broker-relay
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
/*
* (non-Javadoc)
*
* #see org.springframework.web.socket.config.annotation.
* WebSocketMessageBrokerConfigurer#registerStompEndpoints(org.
* springframework.web.socket.config.annotation.StompEndpointRegistry)
*/
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/chat");
registry.addEndpoint("/chat").withSockJS();
}
/**
* Bean for servlet container configuration. Sets message buffer size and
* idle timeout.
*
* #return
*/
#Bean
public ServletServerContainerFactoryBean createWebSocketContainer() {
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
container.setMaxTextMessageBufferSize(MESSAGE_BUFFER_SIZE);
container.setMaxBinaryMessageBufferSize(MESSAGE_BUFFER_SIZE);
container.setMaxSessionIdleTimeout(HOUR_IN_MILLIS);
container.setAsyncSendTimeout(SECOND_IN_MILLIS);
return container;
}
}
basic security configuration:
#Configuration
#EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("1").password("1").roles("USER");
auth.inMemoryAuthentication().withUser("2").password("2").roles("USER");
auth.inMemoryAuthentication().withUser("3").password("3").roles("USER");
}
}
and javascript code snippet:
dataStream = $websocket('ws://localhost:8080/chat');
stomp = Stomp.over(dataStream.socket);
var startListener = function() {
connected = true;
stomp.subscribe('/topic/message', function(data) {
messages.push(JSON.parse(data.body));
listener.notify();
});
};
stomp.connect({
'Login' : name,
passcode : name,
'client-id' : name
}, startListener);
send = function(request) {
stomp.send('/app/message', {}, JSON.stringify(request));
}
You should subscribe the special destination.
stomp.subscribe('/topic/message' + client_id, function(data) {
messages.push(JSON.parse(data.body));
listener.notify();
});
#SendTo("/topic/message") with return will send message to all client subscribe to "/topic/message", meanwhile follow code send message to all client subsribe to "/topic/message/{message.getTo()}":
simpMessagingTemplate.convertAndSendToUser(message.getTo(), "/topic/message", message);
Does Sonata admin work self generated entity ids? I have the following entity which uses the Uuid library to generate its own id but when I try to create a new Group using Sonata admin it gets confused and thinks I am editing an existing entity and not creating a new one.
<?php declare(strict_types=1);
namespace App\Entity;
use App\Value\StartEndTime;
use App\Exception\GroupInactiveException;
use Ramsey\Uuid\Uuid;
use Assert\Assertion;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
class Group
{
/** #var string */
private $id;
/** #var string */
private $title;
/** #var string */
private $description;
/** #var User */
private $admin;
/** #var Collection */
private $members;
/** #var Collection */
private $invites;
/** #var StartEndTime */
private $startEndTime;
/** #var StartEndTime */
private $eventStartEndTime;
public function __construct()
{
$this->id = Uuid::uuid4()->toString();
$this->members = new ArrayCollection();
$this->invites = new ArrayCollection();
}
public function getId(): string
{
return $this->id;
}
public function getTitle()
{
return $this->title;
}
public function setTitle(string $title)
{
Assertion::notEmpty($title, 'Title is not specified');
$this->title = $title;
return $this;
}
public function getDescription()
{
return $this->description;
}
public function setDescription(string $description)
{
Assertion::notEmpty($description, 'Description is not specified');
$this->description = $description;
return $this;
}
public function getStartEndTime()
{
return $this->startEndTime;
}
public function setStartEndTime(StartEndTime $startEndTime)
{
$this->startEndTime = $startEndTime;
return $this;
}
public function getEventStartEndTime()
{
return $this->eventStartEndTime;
}
public function setEventStartEndTime(StartEndTime $startEndTime)
{
$this->eventStartEndTime = $startEndTime;
return $this;
}
}
I'm worring about JDO in GAE (Google App Engine). (GWT 2.4 and GAE 1.6.3 SDK and JDO 2.3)
I have a class "Users" which should save a Collection of "User" in a List, but it doesn't work.
When i save my Users-Class, then it creates the "Users"-Object in the Datebase and it also creates the User-Object in the List users. But when i load the Users-Object from the Database, the List users is empty...
Do i have to load the list by my self? I guess that JDO schould load the list directy, when i load the Users-Object.
I need your Help here! Thanks in previous!
Could it be a Problem that i create the Key in abstract class PersistentUser and PersistentUsers?
Could the LinkedList be the Problem?
My Code:
#PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
#Version(strategy=VersionStrategy.VERSION_NUMBER)
public class Users extends PersistentUsers implements Serializable{
/**
*
*/
private static final long serialVersionUID = -21666269538993247L;
/**
* Mapped from Operator X
*/
#Persistent
private String operatorId;
#Persistent(mappedBy="userlist")
#Element(dependent = "true")
private List<User> users;
/**
*
* List of Ids of Users
*
*/
#Persistent(serialized = "true")
#Element(dependent = "true")
private List<String> userIds;
/**
* #return the users
*/
public List<User> getUsers() {
return users;
}
/**
* #param users the users to set
*/
public void setUsers(List<User> users) {
this.users = users;
}
...
}
The User Class:
#PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
#Version(strategy=VersionStrategy.VERSION_NUMBER)
public class User extends PersistentUser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 6899284258473985914L;
#Persistent
private String emailAddress;
#Persistent
private UserRole role;
/**
*
* Mapped from Userlist X from Operator Y
*/
#Persistent
private Users userlist;
public User(String email, UserRole role){
this.emailAddress = email;
this.role = role;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public UserRole getRole() {
return role;
}
public void setRole(UserRole role) {
this.role = role;
}
/**
* #return the userlist
*/
public Users getUserlist() {
return userlist;
}
/**
* #param userlist the userlist to set
*/
public void setUserlist(Users userlist) {
this.userlist = userlist;
}
}
PersistentUser and PersistentUsers Class are the same content (but because of JDO-AppEngine Inheritance Problem two seperate classes:
#PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
#Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
#Version(strategy=VersionStrategy.VERSION_NUMBER)
public abstract class PersistentUsers implements IPersitentObject {
/**
* Id
*
* Autogenerated String id of the Database
*
*/
#PrimaryKey
#Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
protected Key encodedKey;
#Persistent
protected String username;
#Override
public String getId() {
if(encodedKey == null) return null;
return KeyFactory.keyToString(encodedKey);
}
/*public void setId(String id) {
this.encodedKey = id;
}*/
/**
* Helper function - get Version from DB
*/
#Override
public Long getVersion(){
...
}
/**
* Helper function - will save this instance in DB
*/
public void persist(){
...
}
/**
* Helper function - will remove this instance from DB
*/
public void delete(){
...
}
#Override
public final boolean checkUsername() {
...
}
}
Create User Code:
...
if(RequestFactoryServlet.getThreadLocalRequest().getUserPrincipal() != null){
//Create New User
String email = RequestFactoryServlet.getThreadLocalRequest().getUserPrincipal().getName();
User u = UserFactory.getUser(email, UserRole.ADMINISTRATOR);
//u.persist();
//Create New Userlist
Users users = UserFactory.getUsers();
//Get Uids (normally empty)
LinkedList<String> uids = (LinkedList<String>) users.getUserIds();
if(uids==null){
uids = new LinkedList<String>();
}
uids.add(u.getId());
//Get DB-Userlist of current User-List
LinkedList<User> userlist = (LinkedList<User>) users.getUsers();
if(userlist==null){
userlist = new LinkedList<User>();
}
userlist.add(u);
users.setUserIds(uids);
users.setUsers(userlist);
u.setUserlist(users);
//Persit Userlist and Persist User
users.persist();
this.userlistId = users.getId();
}
...
Persistence Code:
public static void persist(IPersitentObject o){
PersistenceManager pm = Pmf.get().getPersistenceManager();
try{
pm.makePersistent(o);
} catch (Exception e) {
e.printStackTrace();
}finally {
pm.close();
}
}
I found the problem/solution
It's my stupid brain thinking i could fetch it while debugging.
My code is correct, but the information is not in the object while debugging!
Test it in a TestCase showed, that it works.
public class UsersTest {
private PersistenceManager pm;
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
private String userlistId;
private String userId;
#Before
public void setUp() throws Exception {
helper.setUp();
pm = ch.zhaw.ams.server.core.persistance.Pmf.get().getPersistenceManager();
}
#After
public void tearDown() throws Exception {
}
#Test
public void testNewUsers() {
//New UserList
//Create New Userlist
Users users = UserFactory.getUsers();
//Create New User
String email = "ss";
User u = UserFactory.getUser(email, UserRole.ADMINISTRATOR);
users.getUsers().add(u);
users.persist();
this.userlistId = users.getId();
this.userId = users.getUsers().get(0).getId();
//Test Users
pm = ch.zhaw.ams.server.core.persistance.Pmf.get().getPersistenceManager();
Users ul= pm.getObjectById(Users.class, this.userlistId);
assertNotNull(ul);
assertNotNull(ul.getUsers().get(0));
assertTrue(ul.getUsers().get(0).getId().equals(this.userId));
pm.close();
}
}