/** Test group space persistence */
  @Test
  public void simpleGroupWorkspaceDAOTest() throws Exception {

    TransactionStatus ts = tm.getTransaction(td);
    GroupWorkspace groupSpace = new GroupWorkspace("grouName", "groupDescription");
    groupWorkspaceDAO.makePersistent(groupSpace);
    tm.commit(ts);

    ts = tm.getTransaction(td);
    GroupWorkspace other = groupWorkspaceDAO.getById(groupSpace.getId(), false);
    assert other.equals(groupSpace) : "Group space " + other + " should equal " + groupSpace;
    tm.commit(ts);

    ts = tm.getTransaction(td);
    other = groupWorkspaceDAO.getById(groupSpace.getId(), false);
    groupWorkspaceDAO.makeTransient(other);
    assert groupWorkspaceDAO.getById(other.getId(), false) == null
        : "Should no longer be able to find groupSpace";
    tm.commit(ts);
  }
  /** Test adding onwer to group spaces */
  @Test
  public void addGroupWorkspaceOwnerDAOTest() throws Exception {

    TransactionStatus ts = tm.getTransaction(td);
    GroupWorkspace groupSpace = new GroupWorkspace("grouName", "groupDescription");

    // create a user who has their own folder
    UserManager userManager = new UserManager();
    IrUser user = userManager.createUser("passowrd", "userName");
    UserEmail userEmail = new UserEmail("user@email");
    user.addUserEmail(userEmail, true);
    user.setAccountExpired(true);
    user.setAccountLocked(true);
    user.setCredentialsExpired(true);

    // create the user and their folder.
    userDAO.makePersistent(user);

    groupSpace.add(user, true);

    groupWorkspaceDAO.makePersistent(groupSpace);
    tm.commit(ts);

    ts = tm.getTransaction(td);
    GroupWorkspace other = groupWorkspaceDAO.getById(groupSpace.getId(), false);
    GroupWorkspaceUser workspaceUser = other.getUser(user);
    assert workspaceUser != null : "Workspace user for " + user + " should not be null";
    assert workspaceUser.isOwner()
        : "Workspace user  " + workspaceUser + " should be owner of project but is not";
    List<GroupWorkspace> workspaces =
        groupWorkspaceDAO.getGroupWorkspacesForUser(user.getId(), 0, 20, OrderType.ASCENDING_ORDER);
    assert workspaces.size() == 1 : "Should find one workspace but found " + workspaces.size();
    assert workspaces.contains(other) : "List should contain " + other + " but does not";
    tm.commit(ts);

    ts = tm.getTransaction(td);
    other = groupWorkspaceDAO.getById(groupSpace.getId(), false);
    groupWorkspaceDAO.makeTransient(other);
    assert groupWorkspaceDAO.getById(other.getId(), false) == null
        : "Should no longer be able to find groupSpace";
    userDAO.makeTransient(userDAO.getById(user.getId(), false));
    tm.commit(ts);
  }