This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use dummy organization service in register portlet unit tests
- Loading branch information
Showing
7 changed files
with
170 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
portal/ui/src/main/java/org/gatein/portal/ui/register/User.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
portal/ui/src/main/java/org/gatein/portal/ui/register/UserBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.gatein.portal.ui.register; | ||
|
||
import juzu.Mapped; | ||
import org.exoplatform.services.organization.User; | ||
|
||
@Mapped | ||
public class UserBean { | ||
public String userName; | ||
|
||
public String password; | ||
|
||
public String firstName; | ||
|
||
public String lastName; | ||
|
||
public String displayName; | ||
|
||
public String emailAddress; | ||
|
||
public UserBean(User user) { | ||
this.userName = user.getUserName(); | ||
this.password = ""; | ||
this.firstName = user.getFirstName(); | ||
this.lastName = user.getLastName(); | ||
this.displayName = user.getDisplayName(); | ||
this.emailAddress = user.getEmail(); | ||
} | ||
|
||
public UserBean() { | ||
} | ||
|
||
public UserBean(String userName, String password, String firstName, String lastName, String displayName, | ||
String emailAddress) { | ||
this.userName = userName; | ||
this.password = password; | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
this.displayName = displayName; | ||
this.emailAddress = emailAddress; | ||
} | ||
|
||
public void update(User user) { | ||
user.setDisplayName(displayName); | ||
user.setEmail(emailAddress); | ||
user.setFirstName(firstName); | ||
user.setLastName(lastName); | ||
user.setPassword(password); | ||
} | ||
|
||
public String toString() { | ||
return "User (userName = " + this.userName + ")"; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
portal/ui/src/main/java/org/gatein/portal/ui/register/UserManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2012 eXo Platform SAS. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.gatein.portal.ui.register; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import org.exoplatform.services.organization.OrganizationService; | ||
import org.exoplatform.services.organization.User; | ||
import org.exoplatform.services.organization.UserHandler; | ||
|
||
/** | ||
* Encapsulate operations with org service. | ||
* | ||
* @author Julien Viet | ||
*/ | ||
@Singleton | ||
public class UserManager { | ||
|
||
@Inject | ||
OrganizationService orgService; | ||
|
||
public UserBean getUser(String userName) throws Exception { | ||
UserHandler handler = orgService.getUserHandler(); | ||
User user = handler.findUserByName(userName); | ||
if (user != null) { | ||
return new UserBean(user); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public void saveUser(UserBean userBean) throws Exception { | ||
UserHandler handler = orgService.getUserHandler(); | ||
User user = handler.createUserInstance(userBean.userName); | ||
userBean.update(user); | ||
handler.saveUser(user, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<configuration | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd" | ||
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"> | ||
|
||
<component> | ||
<key>org.exoplatform.services.organization.OrganizationService</key> | ||
<type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type> | ||
</component> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters