[Suiviobsmer-commits] r824 - in trunk: wao-business/src/main/java/fr/ifremer/wao/bean wao-business/src/main/java/fr/ifremer/wao/entity wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/xmi wao-business/src/test/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/base wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/webapp wao-ui/src/test/java/test/fr/ifremer/wao/ui
Author: bleny Date: 2010-12-08 16:13:54 +0000 (Wed, 08 Dec 2010) New Revision: 824 Log: UI improvement for managing user ; tests issues remaining Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ConnectedUserImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Connexion.java trunk/wao-ui/src/main/webapp/Administration.tml trunk/wao-ui/src/main/webapp/Connexion.tml trunk/wao-ui/src/test/java/test/fr/ifremer/wao/ui/AbstractApplicationTest.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ConnectedUserImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ConnectedUserImpl.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ConnectedUserImpl.java 2010-12-08 16:13:54 UTC (rev 824) @@ -88,4 +88,9 @@ return test; } + + @Override + public boolean isAdminAndCanWrite() { + return ! isReadOnly() && isAdmin(); + } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java 2010-12-08 16:13:54 UTC (rev 824) @@ -71,12 +71,26 @@ @Override public String getDescription() { StringBuilder result = new StringBuilder(); - result.append(getUserRole().getLabel()); + if (getUserRoleOrdinal() == null) { + result.append("<no user role>"); + } else { + result.append(getUserRole().getLabel()); + } result.append(" sur "); - result.append(getObsProgram().getLabel()); - if (isReadOnly()) { + if (getObsProgramOrdinal() == null) { + result.append("<no program>"); + } else { + result.append(getObsProgram().getLabel()); + } + if (getCanWrite() == null) { + result.append("<no write access specified>"); + } else if (isReadOnly()) { result.append(" (lecture seule)"); } return result.toString(); } + + public String toString() { + return getDescription() + " " + getTopiaId(); + } } \ No newline at end of file Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-12-08 16:13:54 UTC (rev 824) @@ -56,6 +56,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -196,62 +197,100 @@ } WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); + UserProfileDAO userProfileDAO = WaoDAOHelper.getUserProfileDAO(transaction); - boolean newUser = context.prepareTopiaId(WaoUser.class, user); + WaoUser actualUser = user; - // Check for a new user if login already exists + boolean newUser = user.getTopiaId() == null; + if (newUser) { + context.prepareTopiaId(WaoUser.class, actualUser); WaoUser existUser = dao.findByLogin(user.getLogin()); + // Check for a new user if login already exists if (existUser != null) { throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(), "Un utilisateur existe déjà avec ce login " + user.getLogin()); } + + if (actualUser.getUserProfile() != null) { + for (UserProfile userProfile : actualUser.getUserProfile()) { + log.debug(userProfile + " to save : " + userProfile.getDescription()); + context.prepareTopiaId(UserProfile.class, userProfile); + userProfileDAO.update(userProfile); + } + } + } else { + actualUser = dao.findByTopiaId(user.getTopiaId()); + + Collection<UserProfile> oldProfiles; + if (actualUser.getUserProfile() == null) { + oldProfiles = Collections.EMPTY_LIST; + } else { + oldProfiles = new ArrayList<UserProfile>(actualUser.getUserProfile()); + } + + if (log.isDebugEnabled()) { + log.debug("old profiles : " + oldProfiles); + } + + // set may be buggy + // actualUser.setUserProfile(user.getUserProfile()); + actualUser.clearUserProfile(); + actualUser.addAllUserProfile(user.getUserProfile()); + + if (log.isDebugEnabled()) { + log.debug("new profiles : " + actualUser.getUserProfile()); + } + + for (UserProfile userProfile : actualUser.getUserProfile()) { + if (log.isDebugEnabled()) { + log.debug("is " + userProfile + " in " + oldProfiles + " ? " + + oldProfiles.contains(userProfile)); + } + if (oldProfiles.contains(userProfile)) { + // this profile was already attributed to this user, don't + // remove it : just keep it from being removed + if (log.isDebugEnabled()) { + log.debug("profile " + userProfile + " was already given to user"); + } + oldProfiles.remove(userProfile); + } else { + // this profile was added to the user + if (log.isDebugEnabled()) { + log.debug("profile " + userProfile + " is new for user"); + } + context.prepareTopiaId(UserProfile.class, userProfile); + userProfileDAO.create(userProfile); + } + } + + // now, oldProfiles contains user has no longer, we must remove them + if (log.isDebugEnabled()) { + log.debug("will remove deleted profiles : " + oldProfiles); + } + for (UserProfile userProfile : oldProfiles) { + userProfileDAO.delete(userProfile); + } } - String password = user.getPassword(); + String password = actualUser.getPassword(); if (generatePassword) { password = context.createRandomString(8); - user.setPasswordChanged(true); + actualUser.setPasswordChanged(true); } // For a password set manually by user or generated - if (user.isPasswordChanged()) { + if (actualUser.isPasswordChanged()) { String passwordEncoded = context.encodeString(password); - user.setPassword(passwordEncoded); + actualUser.setPassword(passwordEncoded); } - WaoQueryHelper.UserProfileProperty userProfileProperty = WaoQueryHelper.newUserProfileProperty(); - WaoQueryHelper.WaoUserProperty waoUserProperty = WaoQueryHelper.newWaoUserProperty(); - TopiaQuery query = dao.createQuery(waoUserProperty.$alias()) - .setSelect(userProfileProperty.$alias()) - .addJoin(waoUserProperty.userProfile(), userProfileProperty.$alias(), false) - .addEquals(waoUserProperty.$alias(), user); - if (log.isDebugEnabled()) { - log.debug("query to find old profiles for user is " + query); - } + log.debug("will store " + actualUser.getTopiaId()); + dao.update(actualUser); + log.debug("had stored " + actualUser.getTopiaId()); - UserProfileDAO userProfileDAO = WaoDAOHelper.getUserProfileDAO(transaction); - List<UserProfile> oldProfiles = userProfileDAO.findAllByQuery(query); - - if (log.isDebugEnabled()) { - log.debug("profiles for user was " + oldProfiles); - } - for (UserProfile userProfile : oldProfiles) { - userProfileDAO.delete(userProfile); - } - - if (user.getUserProfile() != null) { - for (UserProfile userProfile : user.getUserProfile()) { - log.debug(userProfile + " to save : " + userProfile.getDescription()); - context.prepareTopiaId(UserProfile.class, userProfile); - userProfileDAO.update(userProfile); - } - } - - dao.update(user); - transaction.commitTransaction(); try { Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java 2010-12-08 16:13:54 UTC (rev 824) @@ -25,6 +25,7 @@ package fr.ifremer.wao.service; import fr.ifremer.wao.TestManager; +import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.bean.ObsProgram; import fr.ifremer.wao.bean.UserRole; @@ -45,6 +46,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.LinkedList; import java.util.List; /** @@ -101,10 +103,48 @@ /** * Test of createUpdateUser method, of class ServiceUserImpl. + * + * This test is not complete : it doesn't check if given data are well + * registered. For profile updating, it only checks that no exception is + * raised. */ - //@Test + @Test public void testCreateUpdateUser() throws Exception { System.out.println("createUpdateUser"); + + // create a user with no role + WaoUser user = new WaoUserImpl(); + user.setLogin("login"); + service.createUpdateUser(user, false); + + // now, update user with or without adding, removing, a profile to + // see if an error is raised + List<UserProfile> profiles = new LinkedList<UserProfile>(); + user.setUserProfile(profiles); + + UserProfile adminProfile = new UserProfileImpl(ObsProgram.OBSMER, UserRole.ADMIN, true); + UserProfile coordinatorProfile = new UserProfileImpl(ObsProgram.OBSMER, UserRole.COORDINATOR, true); + + profiles.add(adminProfile); + + log.debug("trying to store " + user.getTopiaId()); + service.createUpdateUser(user, false); + + profiles.add(coordinatorProfile); + service.createUpdateUser(user, false); + + profiles.remove(adminProfile); + service.createUpdateUser(user, false); + + // check that creating two user with the same login is not allowed + try { + user = new WaoUserImpl(); + user.setLogin("login"); + service.createUpdateUser(user, false); + Assert.fail("an exception should have been raised"); + } catch (WaoBusinessException e) { + Assert.assertEquals(WaoBusinessException.Type.ALREADY_EXISTS, e.getType()); + } } /** Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-12-08 16:13:54 UTC (rev 824) @@ -143,9 +143,6 @@ @Persist private boolean programSelect; - - - public void onSelectedFromAddSampleRowCode() { if (sampleRowId != null) { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-12-08 16:13:54 UTC (rev 824) @@ -415,6 +415,11 @@ layout.addError(eee.getMessage()); } } + + // reset : if user change, its profiles change + editedUserProfiles = null; + editedProfile = null; + if (log.isDebugEnabled()) { log.debug("'User id : " + userId); } @@ -483,8 +488,14 @@ @Log void onValidateFormFromUserForm() { userForm.clearErrors(); - if (CollectionUtils.isEmpty(userEdited.getUserProfile())) { + + if (CollectionUtils.isEmpty(getEditedUserProfiles())) { userForm.recordError("L'utilisateur doit au minimum avoir un rôle."); + } else { + // set may be buggy + // getUserEdited().setUserProfile(getEditedUserProfiles()); + getUserEdited().clearUserProfile(); + getUserEdited().addAllUserProfile(getEditedUserProfiles()); } } @@ -524,6 +535,7 @@ private SelectModel userRoleSelectModel; + @Persist private List<UserProfile> editedUserProfiles; @Persist @@ -546,6 +558,7 @@ @Property private boolean refreshUserRoleZone; + @Log public UserProfile getEditedProfile() { if (editedProfile == null) { editedProfile = new UserProfileImpl(); @@ -558,6 +571,7 @@ return editedProfile; } + @Log public SelectModel getUserRoleSelectModel() { if (userRoleSelectModel == null) { List<OptionModel> options = new ArrayList<OptionModel>(); @@ -572,16 +586,16 @@ } return userRoleSelectModel; } - + private OptionModel newUserRoleOption(UserRole role) { return new OptionModelImpl(role.getLabel(), role); } @Log void onChangeFromUserRole(String value) { - // XXX 20101203 bleny, what if value="" ? field is not reset and can't - // be reset - if (StringUtils.isNotEmpty(value)) { + if (StringUtils.isEmpty(value)) { + getEditedProfile().setUserRole(null); + } else { getEditedProfile().setUserRole(UserRole.valueOf(value)); } } @@ -591,17 +605,23 @@ getEditedProfile().setCanWrite( ! value); } + @Log public List<UserProfile> getEditedUserProfiles() { if (editedUserProfiles == null) { - editedUserProfiles = new ArrayList<UserProfile>(getUserEdited().getUserProfile()); - getUserEdited().setUserProfile(editedUserProfiles); + if (getUserEdited() != null && getUserEdited().getUserProfile() != null) { + editedUserProfiles = new ArrayList<UserProfile>(getUserEdited().getUserProfile()); + } else { + editedUserProfiles = new ArrayList<UserProfile>(); + } } return editedUserProfiles; } @Log Object onActionFromAddRole() { - if (getEditedProfile() != null && getEditedProfile().getUserRole() != null) { + if (getEditedProfile() != null && + getEditedProfile().getUserRoleOrdinal() != null) { + getEditedProfile().setCanWrite( ! readOnly); if (log.isDebugEnabled()) { log.debug("Add user profile : " + getEditedProfile().getDescription()); } @@ -617,8 +637,16 @@ @Log Object onActionFromRemoveRole(int roleIndex) { + if (log.isDebugEnabled()) { + log.debug("edited profiles before remove : " + getEditedUserProfiles()); + } + getEditedUserProfiles().remove(roleIndex); + if (log.isDebugEnabled()) { + log.debug("edited profiles after remove : " + getEditedUserProfiles()); + } + // Refresh the zone refreshUserRoleZone = true; return userRoleZone; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Connexion.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Connexion.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Connexion.java 2010-12-08 16:13:54 UTC (rev 824) @@ -29,22 +29,20 @@ import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.service.ServiceUser; import fr.ifremer.wao.ui.components.FeedBack; +import fr.ifremer.wao.ui.data.GenericSelectModel; import fr.ifremer.wao.ui.data.TapestryUtil; import fr.ifremer.wao.ui.services.RequiresAuthenticationFilter; import fr.ifremer.wao.ui.services.ServiceAuthentication; import org.apache.tapestry5.Link; -import org.apache.tapestry5.OptionModel; import org.apache.tapestry5.PersistenceConstants; -import org.apache.tapestry5.SelectModel; import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.corelib.components.Form; -import org.apache.tapestry5.internal.OptionModelImpl; -import org.apache.tapestry5.internal.SelectModelImpl; import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.ioc.services.PropertyAccess; import org.apache.tapestry5.services.PageRenderLinkSource; import org.slf4j.Logger; @@ -100,6 +98,9 @@ @InjectComponent private Form connexionForm; + @Inject + private PropertyAccess propertyAccess; + void onActivate(Object... activationContext) { if (logger.isDebugEnabled()) { logger.debug("Activiation context : " + Arrays.toString(activationContext)); @@ -241,33 +242,33 @@ } } - private SelectModel profileSelectModel; + private GenericSelectModel<UserProfile> profileSelectModel; @Property private UserProfile userProfile; + @Property + private String userProfileId; + /** * Retrieve the SelectModel for user roles. Will be loaded only if user is * already connected. This list is useful if user as more than one role. * * @return the SelectModel for user roles */ - public SelectModel getProfileSelectModel() { + public GenericSelectModel<UserProfile> getProfileSelectModel() throws WaoException { if (serviceAuthentication.existConnectedUser()) { WaoUser user = serviceAuthentication.getConnectedUser().getUser(); if (logger.isDebugEnabled()) { logger.debug("Load user roles for " + user.getLogin()); } - - List<OptionModel> options = new ArrayList<OptionModel>(); - for (UserProfile profile : user.getUserProfile()) { - OptionModel option = new OptionModelImpl(profile.getDescription(), profile); - options.add(option); - } - profileSelectModel = new SelectModelImpl(null, options); + List<UserProfile> profiles = new ArrayList<UserProfile>(user.getUserProfile()); + profileSelectModel = new GenericSelectModel<UserProfile>(profiles, + UserProfile.class, "Description", "topiaId", propertyAccess); } else if (profileSelectModel == null) { - profileSelectModel = new SelectModelImpl(new OptionModelImpl(null)); + profileSelectModel = new GenericSelectModel<UserProfile>(new ArrayList<UserProfile>(), + UserProfile.class, "Description", "topiaId", propertyAccess); } return profileSelectModel; } @@ -281,6 +282,7 @@ * @see #getRedirectLink() */ Link onSuccessFromRoleForm() { + userProfile = getProfileSelectModel().findObject(userProfileId); if (logger.isDebugEnabled()) { logger.debug("Connection with role : " + userProfile.getDescription()); } Modified: trunk/wao-ui/src/main/webapp/Administration.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Administration.tml 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-ui/src/main/webapp/Administration.tml 2010-12-08 16:13:54 UTC (rev 824) @@ -126,7 +126,7 @@ <img src="${asset:context:img/add-16px.png}" /> </a> <ul> - <li t:type="loop" t:source="userEdited.userProfile" t:value="profile" t:index="profileIndex" t:volatile="true"> + <li t:type="loop" t:source="editedUserProfiles" t:value="profile" t:index="profileIndex" t:volatile="true"> ${profile.description} <a t:type="actionlink" t:id="removeRole" t:context="profileIndex" title="Supprimer ce rôle" t:zone="so-admin-userRoleZone"> <img src="${asset:context:img/remove-22px.png}" /> @@ -185,7 +185,7 @@ <!-- ALL ACTUAL VALUES FOR INDICATORS OF GLOBAL SYNTHESIS --> <t:loop t:source="globalSynthesisParameters.parameters" t:value="indicator" t:volatile="true"> - <t:indicatorLevels t:indicator="indicator" editable="currentUser.admin" /> + <t:indicatorLevels t:indicator="indicator" editable="currentUser.adminAndCanWrite" /> </t:loop> <table class="indicatorLevels"> @@ -202,7 +202,7 @@ </td> </tr> <tr> - <t:if test="currentUser.admin"> + <t:if test="currentUser.adminAndCanWrite"> <td t:type="loop" t:source="globalSynthesisParameters.globalIndicator.indicatorLevel" t:value="indicatorLevel" volatile="true"> [ <input type="text" size="3" value="${indicatorLevel.lowerBound}" disabled="disabled" /> ; <span t:type="ck/Tooltip" t:value="Attention à bien utiliser ',' et non '.' pour les décimales" t:effect="appear"> @@ -230,18 +230,20 @@ </tr> </table> - <div> - <p><label>Commentaire sur la modification* :</label></p> - <p><input t:type="textarea" t:id="comment" cols="50" rows="5" value="comment"/></p> - </div> + <t:if test="currentUser.adminAndCanWrite"> + <div> + <p><label>Commentaire sur la modification* :</label></p> + <p><input t:type="textarea" t:id="comment" cols="50" rows="5" value="comment"/></p> + </div> - <div class="fright"> - <a t:type="pagelink" page="IndicatorsHistory"> - <img src="${asset:context:/img/clock.png}" alt="Historique" title="Voir l'historique des modifications des indicateurs" /> - </a> - <input t:type="submit" t:id="saveData" class="ico save" value="Save" title="Enregistrer les modifications" /> - <input type="reset" class="ico undo" value="Annuler les modificationss" title="Annuler les modifications" /> - </div> + <div class="fright"> + <a t:type="pagelink" page="IndicatorsHistory"> + <img src="${asset:context:/img/clock.png}" alt="Historique" title="Voir l'historique des modifications des indicateurs" /> + </a> + <input t:type="submit" t:id="saveData" class="ico save" value="Save" title="Enregistrer les modifications" /> + <input type="reset" class="ico undo" value="Annuler les modificationss" title="Annuler les modifications" /> + </div> + </t:if> </form> </t:zone> Modified: trunk/wao-ui/src/main/webapp/Connexion.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Connexion.tml 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-ui/src/main/webapp/Connexion.tml 2010-12-08 16:13:54 UTC (rev 824) @@ -72,8 +72,8 @@ t:title="literal:Choisissez dans la liste votre profil de connexion : "> <form t:id="roleForm" t:type="form" action="tapestry"> <p class="roleSelect"> - <select t:type="select" t:id="userProfile" t:value="userProfile" t:model="profileSelectModel" - onChange="this.form.submit()" t:volatile="true" /> + <select t:type="select" t:id="userProfile" t:value="userProfileId" t:model="profileSelectModel" + onChange="this.form.submit()" /> </p> </form> </div> Modified: trunk/wao-ui/src/test/java/test/fr/ifremer/wao/ui/AbstractApplicationTest.java =================================================================== --- trunk/wao-ui/src/test/java/test/fr/ifremer/wao/ui/AbstractApplicationTest.java 2010-12-07 15:58:04 UTC (rev 823) +++ trunk/wao-ui/src/test/java/test/fr/ifremer/wao/ui/AbstractApplicationTest.java 2010-12-08 16:13:54 UTC (rev 824) @@ -26,8 +26,15 @@ import com.formos.tapestry.testify.core.TapestryTester; import com.formos.tapestry.testify.junit4.TapestryTest; import fr.ifremer.wao.bean.ConnectedUser; +import fr.ifremer.wao.bean.ConnectedUserImpl; +import fr.ifremer.wao.bean.ObsProgram; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; +import fr.ifremer.wao.entity.CompanyImpl; +import fr.ifremer.wao.entity.UserProfile; +import fr.ifremer.wao.entity.UserProfileImpl; +import fr.ifremer.wao.entity.WaoUser; +import fr.ifremer.wao.entity.WaoUserImpl; import fr.ifremer.wao.ui.services.AppModule; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.ApplicationStateManager; @@ -71,6 +78,7 @@ private ApplicationStateManager stateManager; protected void prepareObserverUser(boolean contributeSession) { + /* Company company = mock(Company.class); when(company.getName()).thenReturn("TARTANPION"); @@ -78,8 +86,22 @@ when(user.isAdmin()).thenReturn(false); when(user.getRole()).thenReturn(UserRole.OBSERVER); when(user.getCompany()).thenReturn(company); + */ + + Company company = new CompanyImpl(); + company.setName("TARTANPION"); + WaoUser user = new WaoUserImpl(); + user.setFirstName("Jean"); + user.setLastName("Michmuche"); + UserProfile observerProfile = new UserProfileImpl(ObsProgram.OBSMER, UserRole.OBSERVER, true); + user.addUserProfile(observerProfile); + + ConnectedUser connectedUser = new ConnectedUserImpl(); + connectedUser.setUser(user); + connectedUser.setProfile(observerProfile); + if (contributeSession) { - stateManager.set(ConnectedUser.class, user); + stateManager.set(ConnectedUser.class, connectedUser); } }
participants (1)
-
bleny@users.labs.libre-entreprise.org