[kune-commits] r1494 - in trunk/src: main/java/cc/kune/core/server/manager main/java/cc/kune/core/server/manager/impl main/java/cc/kune/core/server/rpc main/java/cc/kune/wave/server test/java/cc/kune/core/server test/java/cc/kune/core/server/manager test/java/cc/kune/wave/server

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Sun Aug 14 03:21:47 CEST 2011


Author: vjrj_
Date: 2011-08-14 03:21:47 +0200 (Sun, 14 Aug 2011)
New Revision: 1494

Modified:
   trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
   trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
   trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
   trunk/src/main/java/cc/kune/wave/server/KuneAgent.java
   trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java
   trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java
   trunk/src/test/java/cc/kune/core/server/PersistencePreLoadedDataTest.java
   trunk/src/test/java/cc/kune/core/server/manager/GroupManagerDefaultTest.java
   trunk/src/test/java/cc/kune/core/server/manager/UserManagerDefaultTest.java
   trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java
Log:
NEW - # 85: When user registration fails (for any reason) sometimes we don't clean the welcome wave and similars 
http://kune.ourproject.org/issues/ticket/85

Modified: trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/UserManager.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/main/java/cc/kune/core/server/manager/UserManager.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -39,11 +39,12 @@
    * @param country
    * @param language
    * @param timezone
+   * @param wantPersonalHomepage
    * @return User
    * @throws I18nNotFoundException
    */
   User createUser(String shortName, String longName, String email, String passwd, String language,
-      String country, String timezone) throws I18nNotFoundException;
+      String country, String timezone, boolean wantPersonalHomepage) throws I18nNotFoundException;
 
   void createWaveAccount(String shortName, PasswordDigest passwdDigest);
 

Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -37,10 +37,12 @@
 import org.jivesoftware.smack.packet.RosterPacket.ItemType;
 import org.waveprotocol.box.server.authentication.PasswordDigest;
 import org.waveprotocol.box.server.persistence.AccountStore;
+import org.waveprotocol.wave.model.waveref.WaveRef;
 
 import cc.kune.core.client.errors.GroupNameInUseException;
 import cc.kune.core.client.errors.I18nNotFoundException;
 import cc.kune.core.client.errors.UserRegistrationException;
+import cc.kune.core.server.manager.GroupManager;
 import cc.kune.core.server.manager.I18nCountryManager;
 import cc.kune.core.server.manager.I18nLanguageManager;
 import cc.kune.core.server.manager.UserManager;
@@ -70,13 +72,13 @@
   private final ChatProperties chatProperties;
   private final I18nCountryManager countryManager;
   private final UserFinder finder;
+  private final GroupManager groupManager;
   private final I18nTranslationService i18n;
   private final KuneWaveManager kuneWaveManager;
   private final I18nLanguageManager languageManager;
   private final ParticipantUtils participantUtils;
   private final KuneBasicProperties properties;
   private final AccountStore waveAccountStore;
-  // private final PropertiesManager propManager;
   private final CustomUserRegistrationServlet waveUserRegister;
   private final XmppManager xmppManager;
 
@@ -86,7 +88,8 @@
       final XmppManager xmppManager, final ChatProperties chatProperties,
       final I18nTranslationService i18n, final CustomUserRegistrationServlet waveUserRegister,
       final AccountStore waveAccountStore, final KuneWaveManager kuneWaveManager,
-      final ParticipantUtils participantUtils, final KuneBasicProperties properties) {
+      final ParticipantUtils participantUtils, final KuneBasicProperties properties,
+      final GroupManager groupManager) {
     super(provider, User.class);
     this.finder = finder;
     this.languageManager = languageManager;
@@ -99,12 +102,13 @@
     this.kuneWaveManager = kuneWaveManager;
     this.participantUtils = participantUtils;
     this.properties = properties;
+    this.groupManager = groupManager;
   }
 
   @Override
   public User createUser(final String shortName, final String longName, final String email,
-      final String passwd, final String langCode, final String countryCode, final String timezone)
-      throws I18nNotFoundException {
+      final String passwd, final String langCode, final String countryCode, final String timezone,
+      final boolean wantPersonalHomepage) throws I18nNotFoundException {
     I18nLanguage language;
     I18nCountry country;
     TimeZone tz;
@@ -137,20 +141,28 @@
     // }
     // final Properties userProp = new Properties(userPropGroup);
     // propManager.persist(userProp);
+    WaveRef welcome = null;
     try {
       final User user = new User(shortName, longName, email, passwd, passwdDigest.getDigest(),
           passwdDigest.getSalt(), language, country, tz);
 
       final String defWave = properties.getWelcomewave();
       if (defWave != null) {
-        kuneWaveManager.createWave(
+        welcome = kuneWaveManager.createWave(
             ContentConstants.WELCOME_WAVE_CONTENT_TITLE.replaceAll("\\[%s\\]",
                 properties.getDefaultSiteName()), "", defWave, null,
             participantUtils.of(properties.getAdminShortName()), participantUtils.of(shortName));
       }
+      groupManager.createUserGroup(user, wantPersonalHomepage);
+      // Is this necessary? try to remove (used when we were setting the def
+      // content
+      // contentManager.save(userGroup.getDefaultContent());
       return user;
     } catch (final RuntimeException e) {
       try {
+        if (welcome != null) {
+          kuneWaveManager.delParticipants(welcome, properties.getAdminShortName(), shortName);
+        }
         // Try to remove wave account
         waveAccountStore.removeAccount(participantUtils.of(shortName));
       } catch (final Exception e2) {

Modified: trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -95,13 +95,14 @@
   @Transactional(rollbackOn = DefaultException.class)
   public void createUser(final UserDTO userDTO, final boolean wantPersonalHomepage)
       throws DefaultException {
-    final User user = userManager.createUser(userDTO.getShortName(), userDTO.getName(),
-        userDTO.getEmail(), userDTO.getPassword(), userDTO.getLanguage().getCode(),
-        userDTO.getCountry().getCode(), userDTO.getTimezone().getId());
-    final Group userGroup = groupManager.createUserGroup(user, wantPersonalHomepage);
-    // Is this necessary? try to remove (used when we were setting the def
-    // content
-    contentManager.save(userGroup.getDefaultContent());
+    userManager.createUser(userDTO.getShortName(), userDTO.getName(), userDTO.getEmail(),
+        userDTO.getPassword(), userDTO.getLanguage().getCode(), userDTO.getCountry().getCode(),
+        userDTO.getTimezone().getId(), wantPersonalHomepage);
+    // final Group userGroup = groupManager.createUserGroup(user,
+    // wantPersonalHomepage);
+    // // Is this necessary? try to remove (used when we were setting the def
+    // // content
+    // contentManager.save(userGroup.getDefaultContent());
   }
 
   @Override

Modified: trunk/src/main/java/cc/kune/wave/server/KuneAgent.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/KuneAgent.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/main/java/cc/kune/wave/server/KuneAgent.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -100,6 +100,12 @@
   }
 
   @Override
+  public void delParticipants(final WaveRef waveName, final String whoDel, final String... participants) {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
   public Wavelet fetchWave(final WaveId waveId, final WaveletId waveletId, final String author) {
     // TODO Auto-generated method stub
     return null;

Modified: trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/main/java/cc/kune/wave/server/KuneWaveManager.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -33,7 +33,7 @@
 
   void addGadget(WaveRef waveName, String author, String gadgetUrl);
 
-  void addParticipants(WaveRef waveName, String author, String userWhoAdd, String... newParticipant);
+  void addParticipants(WaveRef waveName, String author, String userWhoAdd, String... newParticipants);
 
   WaveRef createWave(String message, ParticipantId participants);
 
@@ -44,6 +44,8 @@
 
   WaveRef createWave(String title, String message, URL gadgetUrl, ParticipantId... participantsArray);
 
+  void delParticipants(WaveRef waveName, String whoDel, String... participants);
+
   Wavelet fetchWave(WaveId waveId, WaveletId waveletId, String author);
 
   Wavelet fetchWave(WaveRef waveRef, String author);

Modified: trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -310,6 +310,29 @@
     return createWave(title, message, NO_WAVE_TO_COPY, gadgetUrl, participantsArray);
   }
 
+  @Override
+  public void delParticipants(final WaveRef waveName, final String whoDel, final String... participants) {
+    final Wavelet wavelet = fetchWave(waveName, whoDel);
+    final OperationQueue opQueue = new OperationQueue();
+
+    for (final String participant : participants) {
+      final String partWithDomain = participantUtils.of(participant).toString();
+      boolean mustDel = false;
+      for (final String current : wavelet.getParticipants()) {
+        if (current.equals(partWithDomain)) {
+          mustDel = true;
+          break;
+        }
+      }
+      if (mustDel) {
+        opQueue.removeParticipantFromWavelet(wavelet, partWithDomain);
+      }
+    }
+    if (opQueue.getPendingOperations().size() > 0) {
+      doOperation(whoDel, opQueue, "add participant");
+    }
+  }
+
   private void doOperation(final String author, final OperationQueue opQueue, final String logComment) {
     final OperationContextImpl context = new OperationContextImpl(waveletProvider,
         converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil);

Modified: trunk/src/test/java/cc/kune/core/server/PersistencePreLoadedDataTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/PersistencePreLoadedDataTest.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/test/java/cc/kune/core/server/PersistencePreLoadedDataTest.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -107,12 +107,12 @@
     gb = new I18nCountry(Long.valueOf(75), "GB", "GBP", ".", "£%n", "", ".", "United Kingdom",
         "western", ",");
     countryManager.persist(gb);
-    user = userManager.createUser(USER_SHORT_NAME, USER_LONG_NAME, USER_EMAIL, USER_PASSWORD, "en",
-        "GB", TimeZone.getDefault().getID());
     defLicense = new License("by-sa-v3.0", "Creative Commons Attribution-ShareAlike", "",
         "http://creativecommons.org/licenses/by-sa/3.0/", true, true, false, "", "");
     licenseManager.persist(defLicense);
-    groupManager.createUserGroup(user, true);
+    user = userManager.createUser(USER_SHORT_NAME, USER_LONG_NAME, USER_EMAIL, USER_PASSWORD, "en",
+        "GB", TimeZone.getDefault().getID(), true);
+    // groupManager.createUserGroup(user, true);
     content = new Content();
     content.setLanguage(english);
     contentManager.persist(content);

Modified: trunk/src/test/java/cc/kune/core/server/manager/GroupManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/manager/GroupManagerDefaultTest.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/test/java/cc/kune/core/server/manager/GroupManagerDefaultTest.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -38,166 +38,154 @@
 import cc.kune.domain.AccessLists;
 import cc.kune.domain.Group;
 import cc.kune.domain.SocialNetwork;
-import cc.kune.domain.User;
 
 public class GroupManagerDefaultTest extends PersistencePreLoadedDataTest {
 
-    private static final String PUBLIC_DESCRIP = "Some public descrip";
+  private static final String PUBLIC_DESCRIP = "Some public descrip";
 
-    @Test
-    public void createdGroupShoudHaveValidSocialNetwork() throws Exception {
-        final Group group = new Group("short", "longName", defLicense, GroupType.PROJECT);
-        groupManager.createGroup(group, user, PUBLIC_DESCRIP);
-        final SocialNetwork socialNetwork = group.getSocialNetwork();
-        final AccessLists lists = socialNetwork.getAccessLists();
-        assertTrue(lists.getAdmins().includes(user.getUserGroup()));
-        assertTrue(lists.getEditors().isEmpty());
-        assertTrue(lists.getViewers().isEmpty());
-        closeTransaction();
-    }
+  @Test
+  public void createdGroupShoudHaveValidSocialNetwork() throws Exception {
+    final Group group = new Group("short", "longName", defLicense, GroupType.PROJECT);
+    groupManager.createGroup(group, user, PUBLIC_DESCRIP);
+    final SocialNetwork socialNetwork = group.getSocialNetwork();
+    final AccessLists lists = socialNetwork.getAccessLists();
+    assertTrue(lists.getAdmins().includes(user.getUserGroup()));
+    assertTrue(lists.getEditors().isEmpty());
+    assertTrue(lists.getViewers().isEmpty());
+    closeTransaction();
+  }
 
-    @Test
-    public void createGroup() throws Exception {
-        final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
-                GroupType.PROJECT);
-        groupManager.createGroup(group, user, PUBLIC_DESCRIP);
-        final Group otherGroup = groupManager.findByShortName("ysei");
+  @Test
+  public void createGroup() throws Exception {
+    final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+        GroupType.PROJECT);
+    groupManager.createGroup(group, user, PUBLIC_DESCRIP);
+    final Group otherGroup = groupManager.findByShortName("ysei");
 
-        assertEquals(group.getLongName(), otherGroup.getLongName());
-        assertEquals(group.getShortName(), otherGroup.getShortName());
-        closeTransaction();
-    }
+    assertEquals(group.getLongName(), otherGroup.getLongName());
+    assertEquals(group.getShortName(), otherGroup.getShortName());
+    closeTransaction();
+  }
 
-    @Test
-    public void createGroupAndSearch() throws Exception, ParseException {
-        final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
-                GroupType.PROJECT);
-        groupManager.createGroup(group, user, PUBLIC_DESCRIP);
-        groupManager.reIndex();
-        final SearchResult<Group> result = groupManager.search("ysei");
-        assertEquals(1, result.getSize());
-        assertEquals("ysei", result.getList().get(0).getShortName());
-        rollbackTransaction();
-    }
+  @Test
+  public void createGroupAndSearch() throws Exception, ParseException {
+    final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+        GroupType.PROJECT);
+    groupManager.createGroup(group, user, PUBLIC_DESCRIP);
+    groupManager.reIndex();
+    final SearchResult<Group> result = groupManager.search("ysei");
+    assertEquals(1, result.getSize());
+    assertEquals("ysei", result.getList().get(0).getShortName());
+    rollbackTransaction();
+  }
 
-    @Test(expected = GroupNameInUseException.class)
-    public void createGroupWithExistingLongName() throws Exception {
-        final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
-                GroupType.PROJECT);
-        groupManager.createGroup(group, user, PUBLIC_DESCRIP);
+  @Test(expected = GroupNameInUseException.class)
+  public void createGroupWithExistingLongName() throws Exception {
+    final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+        GroupType.PROJECT);
+    groupManager.createGroup(group, user, PUBLIC_DESCRIP);
 
-        final Group group2 = new Group("ysei2", "Yellow Submarine Environmental Initiative", defLicense,
-                GroupType.PROJECT);
-        group2.setDefaultLicense(defLicense);
-        groupManager.createGroup(group2, user, PUBLIC_DESCRIP);
+    final Group group2 = new Group("ysei2", "Yellow Submarine Environmental Initiative", defLicense,
+        GroupType.PROJECT);
+    group2.setDefaultLicense(defLicense);
+    groupManager.createGroup(group2, user, PUBLIC_DESCRIP);
 
-        rollbackTransaction();
-    }
+    rollbackTransaction();
+  }
 
-    @Test(expected = GroupNameInUseException.class)
-    public void createGroupWithExistingShortName() throws Exception {
-        final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
-                GroupType.PROJECT);
-        groupManager.createGroup(group, user, PUBLIC_DESCRIP);
+  @Test(expected = GroupNameInUseException.class)
+  public void createGroupWithExistingShortName() throws Exception {
+    final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+        GroupType.PROJECT);
+    groupManager.createGroup(group, user, PUBLIC_DESCRIP);
 
-        final Group group2 = new Group("ysei", "Yellow Submarine Environmental Initiative 2", defLicense,
-                GroupType.PROJECT);
-        groupManager.createGroup(group2, user, PUBLIC_DESCRIP);
+    final Group group2 = new Group("ysei", "Yellow Submarine Environmental Initiative 2", defLicense,
+        GroupType.PROJECT);
+    groupManager.createGroup(group2, user, PUBLIC_DESCRIP);
 
-        rollbackTransaction();
-    }
+    rollbackTransaction();
+  }
 
-    private void createTestGroup(final int number) throws Exception {
-        final Group g = new Group("ysei" + number, "Yellow Submarine Environmental Initiative " + number, defLicense,
-                GroupType.PROJECT);
-        groupManager.createGroup(g, user, PUBLIC_DESCRIP);
-    }
+  private void createTestGroup(final int number) throws Exception {
+    final Group g = new Group("ysei" + number, "Yellow Submarine Environmental Initiative " + number,
+        defLicense, GroupType.PROJECT);
+    groupManager.createGroup(g, user, PUBLIC_DESCRIP);
+  }
 
-    @Test(expected = EmailAddressInUseException.class)
-    public void createUserExistingEmail() throws I18nNotFoundException, GroupNameInUseException,
-            EmailAddressInUseException {
-        final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
-                "GB", "GMT");
-        groupManager.createUserGroup(user1);
-        final User user2 = userManager.createUser("test2", "test 2 name", "test1 at example.com", "some password", "en",
-                "GB", "GMT");
-        groupManager.createUserGroup(user2);
-    }
+  @Test(expected = EmailAddressInUseException.class)
+  public void createUserExistingEmail() throws I18nNotFoundException, GroupNameInUseException,
+      EmailAddressInUseException {
+    userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en", "GB",
+        "GMT", true);
+    userManager.createUser("test2", "test 2 name", "test1 at example.com", "some password", "en", "GB",
+        "GMT", true);
+  }
 
-    @Test(expected = GroupNameInUseException.class)
-    public void createUserExistingLongName() throws I18nNotFoundException, GroupNameInUseException,
-            EmailAddressInUseException {
-        final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
-                "GB", "GMT");
-        groupManager.createUserGroup(user1);
-        final User user2 = userManager.createUser("test2", "test 1 name", "test2 at example.com", "some password", "en",
-                "GB", "GMT");
-        groupManager.createUserGroup(user2);
-    }
+  @Test(expected = GroupNameInUseException.class)
+  public void createUserExistingLongName() throws I18nNotFoundException, GroupNameInUseException,
+      EmailAddressInUseException {
+    userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en", "GB",
+        "GMT", true);
+    userManager.createUser("test2", "test 1 name", "test2 at example.com", "some password", "en", "GB",
+        "GMT", true);
+  }
 
-    @Test(expected = GroupNameInUseException.class)
-    public void createUserExistingShortName() throws I18nNotFoundException, GroupNameInUseException,
-            EmailAddressInUseException {
-        final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
-                "GB", "GMT");
-        groupManager.createUserGroup(user1);
-        final User user2 = userManager.createUser("test", "test 2 name", "test2 at example.com", "some password", "en",
-                "GB", "GMT");
-        groupManager.createUserGroup(user2);
-    }
+  @Test(expected = GroupNameInUseException.class)
+  public void createUserExistingShortName() throws I18nNotFoundException, GroupNameInUseException,
+      EmailAddressInUseException {
+    userManager.createUser("test", "test 1 name", "test21 at example.com", "some password", "en", "GB",
+        "GMT", true);
+    userManager.createUser("test", "test 2 name", "test22 at example.com", "some password", "en", "GB",
+        "GMT", true);
+  }
 
-    @Test(expected = EmailAddressInUseException.class)
-    public void createUserWithExistingEmail() throws Exception {
-        final User user2 = userManager.createUser("username2", "the user name 2", USER_EMAIL, "userPassword", "en",
-                "GB", TimeZone.getDefault().getID());
-        groupManager.createUserGroup(user2);
-        rollbackTransaction();
-    }
+  @Test(expected = EmailAddressInUseException.class)
+  public void createUserWithExistingEmail() throws Exception {
+    userManager.createUser("username2", "the user name 2", USER_EMAIL, "userPassword", "en", "GB",
+        TimeZone.getDefault().getID(), true);
+    rollbackTransaction();
+  }
 
-    @Test(expected = GroupNameInUseException.class)
-    public void createUserWithExistingLongName() throws Exception {
-        final User user2 = userManager.createUser("username2", USER_LONG_NAME, "email2 at example.com", "userPassword",
-                "en", "GB", TimeZone.getDefault().getID());
-        groupManager.createUserGroup(user2);
-        rollbackTransaction();
-    }
+  @Test(expected = GroupNameInUseException.class)
+  public void createUserWithExistingLongName() throws Exception {
+    userManager.createUser("username2", USER_LONG_NAME, "email2 at example.com", "userPassword", "en",
+        "GB", TimeZone.getDefault().getID(), true);
+    rollbackTransaction();
+  }
 
-    @Test(expected = GroupNameInUseException.class)
-    public void createUserWithExistingShortName() throws Exception {
-        final User user2 = userManager.createUser(USER_SHORT_NAME, "the user name 2", "email2 at example.com",
-                "userPassword", "en", "GB", TimeZone.getDefault().getID());
-        groupManager.createUserGroup(user2);
-        rollbackTransaction();
-    }
+  @Test(expected = GroupNameInUseException.class)
+  public void createUserWithExistingShortName() throws Exception {
+    userManager.createUser(USER_SHORT_NAME, "the user name 2", "email2 at example.com", "userPassword",
+        "en", "GB", TimeZone.getDefault().getID(), true);
+    rollbackTransaction();
+  }
 
-    @Test(expected = UserRegistrationException.class)
-    public void createUserWithIncorrectShortName() throws Exception {
-        final User user2 = userManager.createUser("u s", "the user name 2", "email2 at example.com", "userPassword", "en",
-                "GB", TimeZone.getDefault().getID());
-        groupManager.createUserGroup(user2);
-        rollbackTransaction();
-    }
+  @Test(expected = UserRegistrationException.class)
+  public void createUserWithIncorrectShortName() throws Exception {
+    userManager.createUser("u s", "the user name 2", "email2 at example.com", "userPassword", "en", "GB",
+        TimeZone.getDefault().getID(), true);
+    rollbackTransaction();
+  }
 
-    @Test(expected = InvalidStateException.class)
-    public void createUserWithVeryShortName() throws Exception {
-        final User user2 = userManager.createUser("us", "the user name 2", "email2 at example.com", "userPassword", "en",
-                "GB", TimeZone.getDefault().getID());
-        groupManager.createUserGroup(user2);
-        rollbackTransaction();
-    }
+  @Test(expected = InvalidStateException.class)
+  public void createUserWithVeryShortName() throws Exception {
+    userManager.createUser("us", "the user name 2", "email2 at example.com", "userPassword", "en", "GB",
+        TimeZone.getDefault().getID(), true);
+    rollbackTransaction();
+  }
 
-    @Test
-    public void groupSearchPagination() throws Exception, ParseException {
-        for (int i = 1; i < 10; i++) {
-            createTestGroup(i);
-        }
-        groupManager.reIndex();
-        final SearchResult<Group> result = groupManager.search("Yellow", 0, 5);
-        assertEquals(9, result.getSize());
-        assertEquals(5, result.getList().size());
-        final SearchResult<Group> result2 = groupManager.search("Yellow", 5, 5);
-        assertEquals(9, result2.getSize());
-        assertEquals(4, result2.getList().size());
-        rollbackTransaction();
+  @Test
+  public void groupSearchPagination() throws Exception, ParseException {
+    for (int i = 1; i < 10; i++) {
+      createTestGroup(i);
     }
+    groupManager.reIndex();
+    final SearchResult<Group> result = groupManager.search("Yellow", 0, 5);
+    assertEquals(9, result.getSize());
+    assertEquals(5, result.getList().size());
+    final SearchResult<Group> result2 = groupManager.search("Yellow", 5, 5);
+    assertEquals(9, result2.getSize());
+    assertEquals(4, result2.getList().size());
+    rollbackTransaction();
+  }
 }

Modified: trunk/src/test/java/cc/kune/core/server/manager/UserManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/manager/UserManagerDefaultTest.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/test/java/cc/kune/core/server/manager/UserManagerDefaultTest.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -42,105 +42,105 @@
 import com.google.inject.Inject;
 
 public class UserManagerDefaultTest extends PersistencePreLoadedDataTest {
-    @Inject
-    Group groupFinder;
+  @Inject
+  Group groupFinder;
 
-    @Test
-    public void emailCorrect() {
-        user = new User("test1", "test1 name", "test at example.com", "some passwd", "somediggest".getBytes(),
-                "some salt".getBytes(), english, gb, getTimeZone());
-        persist(user);
-    }
+  @Test
+  public void emailCorrect() {
+    user = new User("test1", "test1 name", "test at example.com", "some passwd", "somediggest".getBytes(),
+        "some salt".getBytes(), english, gb, getTimeZone());
+    persist(user);
+  }
 
-    @Test(expected = PersistenceException.class)
-    public void emailEmpty() {
-        user = new User("test1", "test1 name", null, "some passwd", "somediggest".getBytes(), "some salt".getBytes(),
-                english, gb, getTimeZone());
-        persist(user);
-    }
+  @Test(expected = PersistenceException.class)
+  public void emailEmpty() {
+    user = new User("test1", "test1 name", null, "some passwd", "somediggest".getBytes(),
+        "some salt".getBytes(), english, gb, getTimeZone());
+    persist(user);
+  }
 
-    @Test(expected = InvalidStateException.class)
-    public void emailIncorrect() {
-        user = new User("test1", "test1 name", "falseEmail@", "some passwd", "somediggest".getBytes(),
-                "some salt".getBytes(), english, gb, getTimeZone());
-        persist(user);
-    }
+  @Test(expected = InvalidStateException.class)
+  public void emailIncorrect() {
+    user = new User("test1", "test1 name", "falseEmail@", "some passwd", "somediggest".getBytes(),
+        "some salt".getBytes(), english, gb, getTimeZone());
+    persist(user);
+  }
 
-    private TimeZone getTimeZone() {
-        return TimeZone.getDefault();
-    }
+  private TimeZone getTimeZone() {
+    return TimeZone.getDefault();
+  }
 
-    @Test
-    public void loginIncorrect() {
-        final User result = userManager.login("test", "test");
-        assertNull(result);
-    }
+  @Test
+  public void loginIncorrect() {
+    final User result = userManager.login("test", "test");
+    assertNull(result);
+  }
 
-    @Test
-    public void loginWithEmailCorrect() {
-        final User result = userManager.login(USER_EMAIL, USER_PASSWORD);
-        assertNotNull(result.getId());
-    }
+  @Test
+  public void loginWithEmailCorrect() {
+    final User result = userManager.login(USER_EMAIL, USER_PASSWORD);
+    assertNotNull(result.getId());
+  }
 
-    @Test
-    public void loginWithNickCorrect() {
-        final User result = userManager.login(USER_SHORT_NAME, USER_PASSWORD);
-        assertNotNull(result.getId());
-    }
+  @Test
+  public void loginWithNickCorrect() {
+    final User result = userManager.login(USER_SHORT_NAME, USER_PASSWORD);
+    assertNotNull(result.getId());
+  }
 
-    @Test(expected = InvalidStateException.class)
-    public void passwdLengthIncorrect() {
-        user = new User("test1", "test1 name", "test at example.com", "pass", "diggest".getBytes(), "salt".getBytes(),
-                english, gb, getTimeZone());
-        persist(user);
-    }
+  @Test(expected = InvalidStateException.class)
+  public void passwdLengthIncorrect() {
+    user = new User("test1", "test1 name", "test at example.com", "pass", "diggest".getBytes(),
+        "salt".getBytes(), english, gb, getTimeZone());
+    persist(user);
+  }
 
-    /**
-     * This was not working:
-     * http://opensource.atlassian.com/projects/hibernate/browse/EJB-382
-     */
-    @Test(expected = GroupNameInUseException.class)
-    public void testUserExist() throws I18nNotFoundException {
-        final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
-                "GB", "GMT");
-        persist(user1);
-        final User user2 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
-                "GB", "GMT");
-        persist(user2);
-    }
+  /**
+   * This was not working:
+   * http://opensource.atlassian.com/projects/hibernate/browse/EJB-382
+   */
+  @Test(expected = GroupNameInUseException.class)
+  public void testUserExist() throws I18nNotFoundException {
+    final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com",
+        "some password", "en", "GB", "GMT", true);
+    persist(user1);
+    final User user2 = userManager.createUser("test", "test 1 name", "test1 at example.com",
+        "some password", "en", "GB", "GMT", true);
+    persist(user2);
+  }
 
-    @Test(expected = InvalidStateException.class)
-    public void userNameLengthIncorrect() {
-        user = new User("test1", "te", "test at example.com", "some passwd", "diggest".getBytes(), "salt".getBytes(),
-                english, gb, getTimeZone());
-        persist(user);
-    }
+  @Test(expected = InvalidStateException.class)
+  public void userNameLengthIncorrect() {
+    user = new User("test1", "te", "test at example.com", "some passwd", "diggest".getBytes(),
+        "salt".getBytes(), english, gb, getTimeZone());
+    persist(user);
+  }
 
-    @Test
-    public void userSearch() throws Exception, ParseException {
-        userManager.reIndex();
-        final SearchResult<User> result = userManager.search(USER_SHORT_NAME);
-        assertEquals(1, result.getSize());
-        assertEquals(USER_SHORT_NAME, result.getList().get(0).getShortName());
-        rollbackTransaction();
-    }
+  @Test
+  public void userSearch() throws Exception, ParseException {
+    userManager.reIndex();
+    final SearchResult<User> result = userManager.search(USER_SHORT_NAME);
+    assertEquals(1, result.getSize());
+    assertEquals(USER_SHORT_NAME, result.getList().get(0).getShortName());
+    rollbackTransaction();
+  }
 
-    @Test(expected = InvalidStateException.class)
-    public void userShortNameIncorrect() {
-        user = new User("test1A", "test1 name", "test at example.com", "some passwd", "diggest".getBytes(),
-                "salt".getBytes(), english, gb, getTimeZone());
-        persist(user);
-    }
+  @Test(expected = InvalidStateException.class)
+  public void userShortNameIncorrect() {
+    user = new User("test1A", "test1 name", "test at example.com", "some passwd", "diggest".getBytes(),
+        "salt".getBytes(), english, gb, getTimeZone());
+    persist(user);
+  }
 
-    @Test
-    public void visibilityPersist() {
-        user = new User("test1", "test1 name", "test at example.com", "some passwd", "somediggest".getBytes(),
-                "some salt".getBytes(), english, gb, getTimeZone());
-        for (final UserSNetVisibility visibility : UserSNetVisibility.values()) {
-            user.setSNetVisibility(visibility);
-            persist(user);
-            assertEquals(user.getSNetVisibility(), visibility);
-        }
+  @Test
+  public void visibilityPersist() {
+    user = new User("test1", "test1 name", "test at example.com", "some passwd", "somediggest".getBytes(),
+        "some salt".getBytes(), english, gb, getTimeZone());
+    for (final UserSNetVisibility visibility : UserSNetVisibility.values()) {
+      user.setSNetVisibility(visibility);
+      persist(user);
+      assertEquals(user.getSNetVisibility(), visibility);
     }
+  }
 
 }

Modified: trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java	2011-08-13 15:59:10 UTC (rev 1493)
+++ trunk/src/test/java/cc/kune/wave/server/KuneWaveManagerDefaultTest.java	2011-08-14 01:21:47 UTC (rev 1494)
@@ -20,6 +20,7 @@
 package cc.kune.wave.server;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -51,6 +52,29 @@
   ParticipantUtils participantUtils;
 
   @Test
+  public void addAndRemoveParticipant() throws IOException {
+    doLogin();
+    final String whoDels = getSiteAdminShortName();
+    final WaveRef waveletName = createTestWave();
+    assertNotNull(waveletName);
+    manager.addParticipants(waveletName, getSiteAdminShortName(), whoDels, NEW_PARTICIPANT);
+    final Wavelet fetchWavelet = manager.fetchWave(waveletName, getSiteAdminShortName());
+    assertNotNull(fetchWavelet);
+    assertEquals(2, fetchWavelet.getParticipants().size());
+    assertTrue(manager.isParticipant(fetchWavelet, NEW_PARTICIPANT));
+    assertTrue(manager.isParticipant(fetchWavelet, getSiteAdminShortName()));
+    manager.delParticipants(waveletName, whoDels, NEW_PARTICIPANT);
+    final Wavelet fetchDelWavelet = manager.fetchWave(waveletName, getSiteAdminShortName());
+    assertNotNull(fetchDelWavelet);
+    assertEquals(1, fetchDelWavelet.getParticipants().size());
+    assertTrue(manager.isParticipant(fetchDelWavelet, getSiteAdminShortName()));
+    assertFalse(manager.isParticipant(fetchDelWavelet, NEW_PARTICIPANT));
+    manager.addParticipants(waveletName, getSiteAdminShortName(), whoDels, NEW_PARTICIPANT);
+    // Del all
+    manager.delParticipants(waveletName, whoDels, getSiteAdminShortName(), NEW_PARTICIPANT);
+  }
+
+  @Test
   public void addGadget() throws DefaultException, IOException {
     doLogin();
     final WaveRef waveletName = createTestWave();
@@ -66,8 +90,8 @@
     final Wavelet fetchWavelet = manager.fetchWave(waveletName, getSiteAdminShortName());
     assertNotNull(fetchWavelet);
     assertEquals(2, fetchWavelet.getParticipants().size());
-    manager.isParticipant(fetchWavelet, NEW_PARTICIPANT);
-    manager.isParticipant(fetchWavelet, "newparti");
+    assertTrue(manager.isParticipant(fetchWavelet, NEW_PARTICIPANT));
+    assertTrue(manager.isParticipant(fetchWavelet, getSiteAdminShortName()));
   }
 
   @Test
@@ -84,8 +108,8 @@
     final Wavelet fetchWavelet = manager.fetchWave(waveletName, getSiteAdminShortName());
     assertNotNull(fetchWavelet);
     assertEquals(2, fetchWavelet.getParticipants().size());
-    manager.isParticipant(fetchWavelet, NEW_PARTICIPANT);
-    manager.isParticipant(fetchWavelet, "newparti");
+    assertTrue(manager.isParticipant(fetchWavelet, NEW_PARTICIPANT));
+    assertTrue(manager.isParticipant(fetchWavelet, getSiteAdminShortName()));
   }
 
   @Test




More information about the kune-commits mailing list