AbstractJcrBackedUserRoleDao implements IUserRoleDao { public IPentahoUser createUser( Session session, final ITenant theTenant, final String userName, final String password, final String description, final String[] roles ) throws AuthorizableExistsException, RepositoryException { ITenant tenant = theTenant; String user = userName; if ( tenant == null ) { tenant = JcrTenantUtils.getTenant( userName, true ); user = JcrTenantUtils.getPrincipalName( userName, true ); } if ( tenant == null || tenant.getId() == null ) { tenant = JcrTenantUtils.getCurrentTenant(); } if ( !TenantUtils.isAccessibleTenant( tenant ) ) { throw new NotFoundException( Messages.getInstance().getString( "AbstractJcrBackedUserRoleDao.ERROR_0006_TENANT_NOT_FOUND", theTenant.getId() ) ); } String userId = tenantedUserNameUtils.getPrincipleId( tenant, user ); UserManager tenantUserMgr = getUserManager( tenant, session ); tenantUserMgr.createUser( userId, password, new PrincipalImpl( userId ), "" ); session.save(); setUserRolesForNewUser( session, tenant, user, roles ); setUserDescription( session, tenant, user, description ); session.save(); createUserHomeFolder( tenant, user, session ); session.save(); this.userDetailsCache.removeUserFromCache( userName ); return getUser( session, tenant, userName ); } AbstractJcrBackedUserRoleDao( ITenantedPrincipleNameResolver userNameUtils,
                                       ITenantedPrincipleNameResolver roleNameUtils, String authenticatedRoleName,
                                       String tenantAdminRoleName,
                                       String repositoryAdminUsername, IRepositoryFileAclDao repositoryFileAclDao,
                                       IRepositoryFileDao repositoryFileDao,
                                       final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper,
                                       final IRepositoryDefaultAclHandler defaultAclHandler,
                                       final List<String> systemRoles,
                                       final List<String> extraRoles, UserCache userDetailsCache ); void setRoleMembers( Session session, final ITenant theTenant, final String roleName,
                              final String[] memberUserNames ); void setUserRoles( Session session, final ITenant theTenant, final String userName, final String[] roles ); IPentahoRole createRole( Session session, final ITenant theTenant, final String roleName,
                                  final String description, final String[] memberUserNames ); IPentahoUser createUser( Session session, final ITenant theTenant, final String userName,
                                  final String password, final String description, final String[] roles ); void deleteRole( Session session, final IPentahoRole role ); void deleteUser( Session session, final IPentahoUser user ); List<IPentahoRole> getRoles( Session session ); List<IPentahoUser> getUsers( Session session ); void setRoleDescription( Session session, final ITenant theTenant, final String roleName,
                                  final String description ); void setUserDescription( Session session, final ITenant theTenant, final String userName,
                                  final String description ); void setPassword( Session session, final ITenant theTenant, final String userName, final String password ); ITenantedPrincipleNameResolver getTenantedUserNameUtils(); ITenantedPrincipleNameResolver getTenantedRoleNameUtils(); List<IPentahoRole> getRoles( Session session, ITenant tenant ); List<IPentahoRole> getRoles( Session session, ITenant theTenant, boolean includeSubtenants ); List<IPentahoUser> getUsers( Session session, ITenant tenant ); List<IPentahoUser> getUsers( Session session, ITenant theTenant, boolean includeSubtenants ); IPentahoRole getRole( Session session, final ITenant tenant, final String name ); IPentahoUser getUser( Session session, final ITenant tenant, final String name ); List<IPentahoUser> getRoleMembers( Session session, final ITenant theTenant, final String roleName ); List<IPentahoRole> getUserRoles( Session session, final ITenant theTenant, final String userName ); boolean isUseJackrabbitUserCache(); void setUseJackrabbitUserCache( boolean useJackrabbitUserCache );  }
@Test public void testCreateUser() throws Exception { String testUser = TEST_USER_NAME + "_create"; String password = "password"; setResolverMocks( testUser ); IPentahoUser newUser = abstractJcrBackedUserRoleDaoMock .createUser( adminSession, tenantMock, TEST_USER_NAME, password, TEST_USER_DEC, newRoles ); IPentahoUser existingUser = abstractJcrBackedUserRoleDaoMock.getUser( adminSession, tenantMock, TEST_USER_NAME ); assertThat( existingUser, is( newUser ) ); }