Search in sources :

Example 16 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class MemberDaoTest method shouldCreateNewMemberOnMemberStoring.

@Test(dependsOnMethods = { "shouldGetMember", "shouldRemoveMember" })
public void shouldCreateNewMemberOnMemberStoring() throws Exception {
    final MemberImpl member = members[0];
    memberDao.remove(member.getUserId(), member.getOrganizationId());
    memberDao.store(member);
    assertEquals(memberDao.getMember(member.getOrganizationId(), member.getUserId()), new MemberImpl(member));
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Test(org.testng.annotations.Test)

Example 17 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class MemberDaoTest method shouldThrowServerExceptionOnStoringMemberForNonExistenceUser.

@Test(expectedExceptions = ServerException.class)
public void shouldThrowServerExceptionOnStoringMemberForNonExistenceUser() throws Exception {
    final MemberImpl toCreate = new MemberImpl("non-existence", members[0].getOrganizationId(), singletonList("read"));
    memberDao.store(toCreate);
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Test(org.testng.annotations.Test)

Example 18 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class MemberDaoTest method shouldGetMember.

@Test
public void shouldGetMember() throws Exception {
    final MemberImpl existedMember = members[0];
    final MemberImpl fetchedMember = memberDao.getMember(existedMember.getOrganizationId(), existedMember.getUserId());
    assertEquals(existedMember, fetchedMember);
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Test(org.testng.annotations.Test)

Example 19 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class JpaMemberDao method doRemove.

@Override
@Transactional
protected void doRemove(String organizationId, String userId) {
    final EntityManager manager = managerProvider.get();
    List<MemberImpl> members = manager.createNamedQuery("Member.getMember", MemberImpl.class).setParameter("userId", userId).setParameter("organizationId", organizationId).getResultList();
    if (!members.isEmpty()) {
        manager.remove(members.get(0));
        manager.flush();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) Transactional(com.google.inject.persist.Transactional)

Example 20 with MemberImpl

use of org.eclipse.che.multiuser.organization.spi.impl.MemberImpl in project che-server by eclipse-che.

the class OrganizationManager method removeMembers.

@VisibleForTesting
List<String> removeMembers(String organizationId) throws ServerException {
    List<String> removed = new ArrayList<>();
    Page<MemberImpl> membersPage;
    do {
        // skip count always equals to 0 because elements will be shifted after removing previous
        // items
        membersPage = memberDao.getMembers(organizationId, 100, 0);
        for (MemberImpl member : membersPage.getItems()) {
            removed.add(member.getUserId());
            memberDao.remove(member.getUserId(), member.getOrganizationId());
        }
    } while (membersPage.hasNextPage());
    return removed;
}
Also used : MemberImpl(org.eclipse.che.multiuser.organization.spi.impl.MemberImpl) ArrayList(java.util.ArrayList) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)36 Test (org.testng.annotations.Test)18 OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)14 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)8 TypeLiteral (com.google.inject.TypeLiteral)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)6 DBInitializer (org.eclipse.che.core.db.DBInitializer)6 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)6 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)6 MemberDao (org.eclipse.che.multiuser.organization.spi.MemberDao)6 OrganizationDao (org.eclipse.che.multiuser.organization.spi.OrganizationDao)6 OrganizationDistributedResourcesDao (org.eclipse.che.multiuser.organization.spi.OrganizationDistributedResourcesDao)6 OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)6 JpaMemberDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaMemberDao)6 JpaOrganizationDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDao)6 JpaOrganizationDistributedResourcesDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDistributedResourcesDao)6 UserDevfilePermissionImpl (org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl)6 Transactional (com.google.inject.persist.Transactional)4 HashMap (java.util.HashMap)4